@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
@@ -181,9 +181,9 @@ declare class Grid extends EventDispatcher {
181
181
 
182
182
  public _initDuplicateRicData(rowDef: RowDefinition|null): void;
183
183
 
184
- public insertRow(rowOption?: any, rowRef?: Grid.RowReference|null): any;
184
+ public insertRow(rowOption?: (RowDefinition.Options|string)|null, rowRef?: Grid.RowReference|null): RowDefinition|null;
185
185
 
186
- public insertRows(rowOptions: (any)[]|null, rowRef?: Grid.RowReference|null, opt_fields?: (string)[]|null): void;
186
+ public insertRows(rowOptions: (RowDefinition.Options|string)[]|null, rowRef?: Grid.RowReference|null, opt_fields?: (string)[]|null): void;
187
187
 
188
188
  public addStaticDataRows(dataRows: any[]|null, fields?: (string)[]|null): void;
189
189
 
@@ -323,7 +323,7 @@ declare class Grid extends EventDispatcher {
323
323
 
324
324
  public logDV(opt_options?: any): void;
325
325
 
326
- public replaceRow(rowRef: Grid.RowReference|null, rowOption?: any): any;
326
+ public replaceRow(rowRef: Grid.RowReference|null, rowOption?: (RowDefinition.Options|string)|null): RowDefinition|null;
327
327
 
328
328
  public scrollToColumn(colIndex: number, leftOfView?: boolean|null): boolean;
329
329
 
@@ -613,6 +613,14 @@ Grid.prototype.dispose = function() {
613
613
  this._grid.dispose();
614
614
  this._connector.reset();
615
615
 
616
+ if(!this._sharedDataSource) { // make sure that it is the final grid, and that it will be dispose data
617
+ if(this._dt) {
618
+ this._dt.dispose();
619
+ }
620
+ if(this._dv) {
621
+ this._dv.dispose();
622
+ }
623
+ }
616
624
  this._mainGrid = this._dt = this._dv = null;
617
625
 
618
626
  if(this._subs) {
@@ -1573,16 +1581,16 @@ Grid.prototype.replaceColumn = function (columnOption, colRef) {
1573
1581
  }
1574
1582
 
1575
1583
  var colDef = this.getColumnDefinition(colIndex);
1576
- if(colDef.getChildren()) { // Parent time series field doesn't provide hidden property
1584
+ if(colDef && colDef.getChildren().length > 0) { // Parent time series field doesn't provide hidden property
1577
1585
  colConfig["hidden"] = false;
1578
1586
  }
1579
1587
 
1580
- if(colConfig.id == null) {
1588
+ if(colDef && colConfig.id == null) {
1581
1589
  colConfig.id = colDef.getId(); // retain ID
1582
1590
  }
1583
1591
  this._grid.startBatch("reset");
1592
+ this.removeColumn(colIndex);
1584
1593
  this.insertColumn(colConfig, colIndex);
1585
- this.removeColumn(colIndex + 1); // remove existing column after insert
1586
1594
  this._grid.stopBatch("reset");
1587
1595
  };
1588
1596
 
@@ -2287,9 +2295,9 @@ Grid.prototype._initDuplicateRicData = function(rowDef) {
2287
2295
  }
2288
2296
  };
2289
2297
  /** @public
2290
- * @param {Object=} rowOption
2298
+ * @param {(RowDefinition~Options|string)=} rowOption
2291
2299
  * @param {Grid~RowReference=} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
2292
- * @returns {Object}
2300
+ * @returns {RowDefinition}
2293
2301
  * @example
2294
2302
  * var grid = new rt.Grid(grid_div, options);
2295
2303
  * grid.insertRow({"ric": "RIC"}, 0); // A new row is added at the top
@@ -2320,7 +2328,7 @@ Grid.prototype.insertRow = function(rowOption, rowRef) {
2320
2328
  return rowDef;
2321
2329
  };
2322
2330
  /** @public
2323
- * @param {Array.<Object>} rowOptions Array of row option object
2331
+ * @param {Array.<RowDefinition~Options|string>} rowOptions Array of row option object
2324
2332
  * @param {Grid~RowReference=} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
2325
2333
  * @param {Array.<string>=} opt_fields
2326
2334
  * @example
@@ -3970,8 +3978,8 @@ Grid.prototype._logData = function(rowDefs, options) {
3970
3978
  /** @public
3971
3979
  * @description Replace existing row with a new row. Row ID would be changed, after row is replaced.
3972
3980
  * @param {Grid~RowReference} rowRef Reference (i.e. row index, row id, or row definition) of the insert position
3973
- * @param {Object=} rowOption
3974
- * @returns {Object}
3981
+ * @param {(RowDefinition~Options|string)=} rowOption
3982
+ * @returns {RowDefinition}
3975
3983
  */
3976
3984
  Grid.prototype.replaceRow = function(rowRef, rowOption) {
3977
3985
  var rowId = this._getRowId(rowRef);
@@ -14,7 +14,9 @@ declare namespace ColumnStackPlugin {
14
14
  fields: (string)[]|null,
15
15
  stacks: (ColumnStackPlugin.StackDefinition)[]|null,
16
16
  autoStacking?: boolean|null,
17
- clicked?: ((...params: any[]) => any)|null
17
+ clicked?: ((...params: any[]) => any)|null,
18
+ menuElement?: Element|null,
19
+ menuItemClicked?: ((...params: any[]) => any)|null
18
20
  };
19
21
 
20
22
  type ColumnOptions = {
@@ -10,10 +10,12 @@ import { preventDefault } from "../../tr-grid-util/es6/EventDispatcher.js";
10
10
 
11
11
  /** @typedef {Object} ColumnStackPlugin~Options
12
12
  * @description Available options describing `columnStack` object specified in grid's option
13
- * @property {Array.<string>} fields Fields for stacking. The minimum is 2 fields.
13
+ * @property {Array.<string>} fields Fields for stacking. The minimum is 2 fields
14
14
  * @property {Array.<ColumnStackPlugin~StackDefinition>} stacks List of stacking configuration
15
15
  * @property {boolean=} autoStacking Deprecated. Stacks are automatically maintained as long as its members exist
16
16
  * @property {Function=} clicked=null Event handler when user clicks on stack/expanding icon
17
+ * @property {Element=} menuElement Element used to display a column selection list
18
+ * @property {Function=} menuItemClicked When the menuElement is specified and menu item is clicked, an event handler is called
17
19
  */
18
20
 
19
21
  /** @typedef {Object} ColumnStackPlugin~ColumnOptions
@@ -122,6 +124,7 @@ var ColumnStackPlugin = function () {
122
124
  this._onBeforeBatchOperation = this._onBeforeBatchOperation.bind(this);
123
125
  this._onAfterBatchOperation = this._onAfterBatchOperation.bind(this);
124
126
  this._onPinningChanged = this._onPinningChanged.bind(this);
127
+ this._onMenuItemClicked = this._onMenuItemClicked.bind(this);
125
128
 
126
129
  this._onStackButtonClicked = this._onStackButtonClicked.bind(this);
127
130
  this._updateUI = this._updateUI.bind(this);
@@ -165,6 +168,14 @@ ColumnStackPlugin.prototype._inResetting = false;
165
168
  * @private
166
169
  */
167
170
  ColumnStackPlugin.prototype._inPinning = false;
171
+ /** @type {Element}
172
+ * @private
173
+ */
174
+ ColumnStackPlugin.prototype._menuElement = null;
175
+ /** @type {Function}
176
+ * @private
177
+ */
178
+ ColumnStackPlugin.prototype._menuItemClicked = null;
168
179
 
169
180
  /** @type {number}
170
181
  * @private
@@ -201,12 +212,28 @@ ColumnStackPlugin.prototype.initialize = function (host, options) {
201
212
  if(this._hosts.indexOf(host) >= 0) { return; }
202
213
  this._hosts.push(host);
203
214
 
204
- if(options && options["icons"]) {
205
- var icons = options["icons"]["columnStack"];
206
- if(icons) {
207
- this._stackIconName = icons["stack"];
208
- this._expandIconName = icons["expand"];
209
- this._collapseIconName = icons["collapse"];
215
+ if(options) {
216
+ if(options["icons"]) {
217
+ var icons = options["icons"]["columnStack"];
218
+ if(icons) {
219
+ this._stackIconName = icons["stack"];
220
+ this._expandIconName = icons["expand"];
221
+ this._collapseIconName = icons["collapse"];
222
+ }
223
+ }
224
+
225
+ var opt = options["columnStack"];
226
+ if(opt && this._hosts.length === 1) {
227
+ var menuElement = opt["menuElement"];
228
+ if(menuElement && typeof menuElement === "object" && menuElement.nodeType === 1) {
229
+ menuElement.addEventListener("item-trigger", this._onMenuItemClicked);
230
+ this._menuElement = menuElement;
231
+ }
232
+
233
+ var menuItemClicked = opt["menuItemClicked"];
234
+ if(typeof menuItemClicked === "function") {
235
+ this._menuItemClicked = menuItemClicked;
236
+ }
210
237
  }
211
238
  }
212
239
 
@@ -242,6 +269,10 @@ ColumnStackPlugin.prototype.unload = function (host) {
242
269
  host.unlisten("preSectionRender", this._onPreSectionRender);
243
270
  host.unlisten("pinningChanged", this._onPinningChanged);
244
271
 
272
+ if(this._menuElement) {
273
+ this._menuElement.removeEventListener("item-trigger", this._onMenuItemClicked);
274
+ }
275
+
245
276
  if(this._hosts.length <= 0) {
246
277
  this._conflator.reset();
247
278
  this._groupDefs.removeAllGroups();
@@ -1608,7 +1639,8 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
1608
1639
  value: i,
1609
1640
  selected: i === activeIndex,
1610
1641
  label: this.getColumnName(colIndices[i]),
1611
- field: this.getColumnField(colIndices[i])
1642
+ field: this.getColumnField(colIndices[i]),
1643
+ colId: children[i]
1612
1644
  };
1613
1645
  }
1614
1646
  pos["menuData"] = menuData;
@@ -1622,9 +1654,33 @@ ColumnStackPlugin.prototype._onStackButtonClicked = function(e) {
1622
1654
  pos["stackId"] = colData.id;
1623
1655
 
1624
1656
  elem.focus();
1657
+
1658
+ if(this._menuElement && !colData.spreading) {
1659
+ // Populate stack member
1660
+ var button = pos.event.srcElement;
1661
+ var el = this._menuElement;
1662
+ el.data = pos["menuData"];
1663
+ el.positionTarget = button;
1664
+ el.opened = true;
1665
+ }
1625
1666
  this._dispatch("clicked", pos);
1626
1667
  };
1668
+ /** @private
1669
+ * @param {Object} e
1670
+ */
1671
+ ColumnStackPlugin.prototype._onMenuItemClicked = function(e) {
1672
+ if(e.detail) {
1673
+ var selectedIndex = parseInt(e.detail.value, 0);
1674
+ var menuData = this._menuElement.data[selectedIndex];
1675
+ var colId = menuData.colId;
1676
+ this.setActiveColumn(colId);
1677
+ }
1678
+ this._menuElement.opened = false;
1627
1679
 
1680
+ if(this._menuItemClicked) {
1681
+ this._menuItemClicked(e);
1682
+ }
1683
+ };
1628
1684
  /** @public
1629
1685
  * @description Get member column indices in a stack
1630
1686
  * @param {string} stackId
@@ -10,7 +10,7 @@ declare namespace TextFormattingPlugin {
10
10
  formatType?: string|null,
11
11
  type?: string|null,
12
12
  field?: string|null,
13
- decimalPlaces?: number|null,
13
+ decimalPlaces?: (number|boolean)|null,
14
14
  precisionEnabled?: boolean|null,
15
15
  plusSign?: boolean|null,
16
16
  separator?: boolean|null,
@@ -9,9 +9,9 @@ import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
9
9
  * @description Fired only when a user click OK from the format dialog, that is generated from this extension
10
10
  * @type {Object}
11
11
  * @property {number} colIndex
12
- * @property {string} formatType Available options are: number, scaled, percent, date, time and datetime
12
+ * @property {string} formatType Available options are: number, scaled, percent, and datetime
13
13
  * @property {string} field Field defined in the column
14
- * @property {number=} decimalPlaces=2
14
+ * @property {(number|boolean)=} decimalPlaces=2
15
15
  * @property {boolean=} plusSign
16
16
  * @property {boolean=} separator
17
17
  * @property {boolean=} percentSign
@@ -26,7 +26,7 @@ import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
26
26
  * @property {string=} formatType Available options are: number, scaled, percent, and datetime
27
27
  * @property {string=} type Alias to formatType
28
28
  * @property {string=} field Field is required but can be defined in the column definition object
29
- * @property {number=} decimalPlaces=2
29
+ * @property {(number|boolean)=} decimalPlaces=2
30
30
  * @property {boolean=} precisionEnabled=true If disabled, number of decimal will remain as original.
31
31
  * @property {boolean=} plusSign=false
32
32
  * @property {boolean=} separator=false Thousands separators
@@ -34,8 +34,8 @@ import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
34
34
  * @property {string=} scalingUnit Value can be million or billion
35
35
  * @property {boolean=} multiplyBy100=false
36
36
  * @property {boolean=} mutiplyBy100=false Alias of multiplyBy100
37
- * @property {string=} dateTimeFormat
38
- * @property {boolean=} useUTCTime
37
+ * @property {string=} dateTimeFormat="MM/DD/YYYY"
38
+ * @property {boolean=} useUTCTime=true
39
39
  * @property {boolean=} autoTextFormatting=true If disabled, the extension's automatic formatting will not be triggered, including `formatLogic`
40
40
  * @property {Function=} formatLogic=null If specified all default formatting will be prevented and replaced by the given function. This should be used when the column has custom rendering. The function must retrieve, format, and insert the data with the provided arguments (i.e., TextFormattingPlugin~FormatLogicArguments).
41
41
  */
@@ -306,6 +306,30 @@ TextFormattingPlugin.prototype._setColumnFormat = function (colIndex, userObj) {
306
306
  var ff = new FieldFormatter(fo); // FieldFormatter will be used for rendering
307
307
  var nf = null;
308
308
  if (fot == "number" || fot == "scaled" || fot == "percent") {
309
+ var precision = fo["decimalPlaces"];
310
+ var precisionEnabled = fo["precisionEnabled"];
311
+ if (typeof precision == "number") {
312
+ colData["precision"] = precision;
313
+ if (precisionEnabled == null) {
314
+ precisionEnabled = true;
315
+ }
316
+ } else if (precision == true) {
317
+ colData["precision"] = null;
318
+ precision = 2;
319
+ precisionEnabled = true;
320
+ } else if (precision === false) {
321
+ colData["precision"] = null;
322
+ precision = 0;
323
+ precisionEnabled = false;
324
+ } else {
325
+ colData["precision"] = null;
326
+ precision = 2;
327
+ if (precisionEnabled == null) {
328
+ precisionEnabled = true;
329
+ }
330
+ }
331
+ fo["decimalPlaces"] = precision;
332
+ fo["precisionEnabled"] = precisionEnabled;
309
333
  nf = new NumberFormatter(fo);
310
334
  ff.setNumberFormatter(nf.format);
311
335
  }
@@ -341,6 +365,12 @@ TextFormattingPlugin.prototype.getColumnFormatOptions = function (colIndex, opti
341
365
  }
342
366
  if (numberFormatter) {
343
367
  numberFormatter.getOptions(options);
368
+ var precision = colData["precision"];
369
+ if (precision != null) {
370
+ options["decimalPlaces"] = precision;
371
+ } else {
372
+ delete options["decimalPlaces"];
373
+ }
344
374
  }
345
375
  }
346
376
  return options;
@@ -38,7 +38,8 @@ ElementObserver._getNewId = function () {
38
38
  return id;
39
39
  };
40
40
 
41
- /** @private Observe any element
41
+ /** Observe any element
42
+ * @private
42
43
  * @param {Element} elem
43
44
  * @param {Function} listener
44
45
  * @param {Object=} opt_option
@@ -101,7 +102,8 @@ ElementObserver.addLanguageListener = function(element) {
101
102
  ElementObserver._addObserver(document.documentElement, _onLanguageMutated.bind(null, element));
102
103
  };
103
104
 
104
- /** @public Add a listener to a html attribute
105
+ /** Add a listener to a html attribute
106
+ * @public
105
107
  * @param {Element} element An element within the DOM tree to watch for changes
106
108
  * @param {Function} listener A function which will be called on each attribute change
107
109
  * @param {string=} attributeName If not specified, listener will be called on every attribute change
@@ -63,7 +63,8 @@ ElementWrapper.prototype.getMousePosition = function(e, retObj) {
63
63
  */
64
64
  ElementWrapper.prototype.addEventListener = function(type, listener) {
65
65
  ElementWrapper.base(this, "addEventListener", type, listener);
66
- if(this._elem["on" + type] != null) { // TODO: This won't work with Custom Element
66
+ // TODO: This won't work with Custom Element
67
+ if(this._elem["on" + type] !== undefined) { // eslint-disable-line
67
68
  this._elem.addEventListener(type, listener, false);
68
69
  }
69
70
  };
@@ -74,7 +75,7 @@ ElementWrapper.prototype.addEventListener = function(type, listener) {
74
75
  */
75
76
  ElementWrapper.prototype.removeEventListener = function(type, listener) {
76
77
  ElementWrapper.base(this, "removeEventListener", type, listener);
77
- if(this._elem["on" + type] != null) {
78
+ if(this._elem["on" + type] !== undefined) { // eslint-disable-line
78
79
  this._elem.removeEventListener(type, listener, false);
79
80
  }
80
81
  };
@@ -259,6 +259,11 @@ GridPlugin.prototype.getColumnIndex = function (colRef) {
259
259
  * @return {Array.<number>} column indices
260
260
  */
261
261
  GridPlugin.prototype.getColumnIndices = function (colRefs) {
262
+ var api = this.getGridApi();
263
+ if(api.getColumnIndices) {
264
+ return api.getColumnIndices(colRefs);
265
+ }
266
+
262
267
  // TODO: Unify the below logics
263
268
  if(this._compositeGrid) {
264
269
  var allFields = this._compositeGrid.getColumnFields();
@@ -30,9 +30,9 @@ declare class SubTable extends ElementWrapper {
30
30
 
31
31
  public getAllCells(): (Element)[];
32
32
 
33
- public getAllRows(): HTMLCollection|null;
33
+ public getAllRows(): (Element)[];
34
34
 
35
- public getRows(): HTMLCollection|null;
35
+ public getRows(): (Element)[];
36
36
 
37
37
  public getRow(r: number): Element|null;
38
38
 
@@ -70,5 +70,7 @@ declare class SubTable extends ElementWrapper {
70
70
 
71
71
  declare function tdElem(e: Event|null): number;
72
72
 
73
+ declare function trElem(colIndex: number, rowIndex?: number|null): number;
74
+
73
75
  export default SubTable;
74
76
  export { SubTable };