@refinitiv-ui/efx-grid 6.0.44 → 6.0.46

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. package/lib/column-selection-dialog/lib/column-selection-dialog.d.ts +3 -1
  2. package/lib/column-selection-dialog/lib/column-selection-dialog.js +24 -3
  3. package/lib/column-selection-dialog/themes/base.less +23 -12
  4. package/lib/column-selection-dialog/themes/elemental/dark/column-selection-dialog.js +1 -1
  5. package/lib/column-selection-dialog/themes/elemental/dark/es5/all-elements.js +1 -1
  6. package/lib/column-selection-dialog/themes/elemental/light/column-selection-dialog.js +1 -1
  7. package/lib/column-selection-dialog/themes/elemental/light/es5/all-elements.js +1 -1
  8. package/lib/column-selection-dialog/themes/halo/dark/column-selection-dialog.js +1 -1
  9. package/lib/column-selection-dialog/themes/halo/dark/es5/all-elements.js +1 -1
  10. package/lib/column-selection-dialog/themes/halo/light/column-selection-dialog.js +1 -1
  11. package/lib/column-selection-dialog/themes/halo/light/es5/all-elements.js +1 -1
  12. package/lib/column-selection-dialog/themes/solar/charcoal/column-selection-dialog.js +1 -1
  13. package/lib/column-selection-dialog/themes/solar/charcoal/es5/all-elements.js +1 -1
  14. package/lib/column-selection-dialog/themes/solar/pearl/column-selection-dialog.js +1 -1
  15. package/lib/column-selection-dialog/themes/solar/pearl/es5/all-elements.js +1 -1
  16. package/lib/core/dist/core.js +204 -186
  17. package/lib/core/dist/core.min.js +1 -1
  18. package/lib/core/es6/data/DataView.d.ts +2 -0
  19. package/lib/core/es6/data/DataView.js +170 -81
  20. package/lib/core/es6/data/Segment.d.ts +2 -0
  21. package/lib/core/es6/data/Segment.js +6 -0
  22. package/lib/core/es6/grid/Core.d.ts +0 -4
  23. package/lib/core/es6/grid/Core.js +28 -105
  24. package/lib/grid/index.js +1 -1
  25. package/lib/index.d.ts +0 -4
  26. package/lib/index.js +0 -4
  27. package/lib/tr-grid-printer/es6/GridPrinter.js +5 -5
  28. package/lib/tr-grid-printer/es6/index.js +1 -1
  29. package/lib/tr-grid-row-filtering/es6/RowFiltering.d.ts +5 -0
  30. package/lib/tr-grid-row-filtering/es6/RowFiltering.js +30 -1
  31. package/lib/tr-grid-util/es6/CoralItems.js +2 -2
  32. package/lib/tr-grid-util/es6/ElfDate.js +1 -1
  33. package/lib/tr-grid-util/es6/ElfUtil.js +2 -2
  34. package/lib/tr-grid-util/es6/ExpanderIcon.js +1 -1
  35. package/lib/tr-grid-util/es6/GridPlugin.js +1 -1
  36. package/lib/tr-grid-util/es6/Icon.js +3 -3
  37. package/lib/tr-grid-util/es6/MultiTableManager.js +3 -3
  38. package/lib/tr-grid-util/es6/RowPainter.js +6 -2
  39. package/lib/tr-grid-util/es6/jet/Adc.d.ts +9 -0
  40. package/lib/tr-grid-util/es6/jet/Adc.js +268 -0
  41. package/lib/tr-grid-util/es6/jet/MockQuotes2.js +96 -7
  42. package/lib/tr-grid-util/es6/jet/MockUtil.d.ts +7 -0
  43. package/lib/tr-grid-util/es6/jet/MockUtil.js +25 -0
  44. package/lib/tr-grid-util/es6/jet/mockDataAPI.d.ts +2 -3
  45. package/lib/tr-grid-util/es6/jet/mockDataAPI.js +3 -288
  46. package/lib/types/es6/Core/data/DataView.d.ts +2 -0
  47. package/lib/types/es6/Core/data/Segment.d.ts +2 -0
  48. package/lib/types/es6/Core/grid/Core.d.ts +0 -4
  49. package/lib/types/es6/RowFiltering.d.ts +5 -0
  50. package/lib/utils/index.d.ts +5 -3
  51. package/lib/utils/index.js +5 -3
  52. package/lib/versions.json +3 -5
  53. package/lib/window-exporter.js +5 -0
  54. package/package.json +1 -1
@@ -0,0 +1,268 @@
1
+ import { DataGenerator } from "./DataGenerator.js";
2
+ import { invalidFieldDict } from "./MockUtil.js";
3
+ import { DateTime } from "../DateTime.js";
4
+
5
+ var dataGen = new DataGenerator();
6
+
7
+ /** @private
8
+ * @namespace
9
+ */
10
+ var Adc = {};
11
+
12
+ /** @private
13
+ * @function
14
+ * @param {Object} payload
15
+ * @param {Object=} mockResponse
16
+ * @return {Promise}
17
+ */
18
+ Adc.request = function (payload, mockResponse) {
19
+ if (mockResponse) {
20
+ return Promise.resolve(JSON.stringify(mockResponse));
21
+ }
22
+
23
+ // build row header
24
+ var rows = [];
25
+ var i, f, len, row, j;
26
+ var identifiers, formula, fields, invalidDict;
27
+ if(payload.output === "Col,date|,Row,In|,va,T,NoEmptyTickers") {
28
+
29
+ identifiers = payload.identifiers;
30
+ formula = payload.formula.trim().split(/(?=,TR.)/);// TODO: check each field with another way, this doesn't work when user use some comma (,) formula
31
+ fields = [];
32
+
33
+ // invalidFieldDict is a dictionary of non exist field
34
+ // so we must remove invalid field to make "mocking api" return result more like a "real api".
35
+ invalidDict = invalidFieldDict;
36
+ for (i = 0; i < formula.length; i++) {
37
+ f = formula[i];
38
+ if (!invalidDict[f]) {
39
+ fields.push(f);
40
+ }
41
+ }
42
+
43
+ var fieldCount = fields.length;
44
+ // formula = payload.formula.trim().split(",TR"); // TODO: split wit
45
+
46
+ rows.push([
47
+ {
48
+ "h": true,
49
+ "i": "instrument",
50
+ "v": "Instrument"
51
+ },
52
+ {
53
+ "h": true,
54
+ "i": "date",
55
+ "v": "Date"
56
+ }
57
+ ]);
58
+
59
+ for (var index = 0; index < fieldCount; index++) {
60
+ var timeSeriesField = fields[index];
61
+
62
+ var regex = /TR.(.*)(?=\()/;
63
+ var result = timeSeriesField.match(regex);
64
+ var field = result[0].replace("TR.", "");
65
+ var phrase = timeSeriesField.toLowerCase();
66
+ var startDateRegex = /sdate=(.*)[,]/;
67
+ var endDateRegex = /edate=(.*)[)]/;
68
+ var startDateMatch = phrase.match(startDateRegex);
69
+ var endDateMatch = phrase.match(endDateRegex);
70
+
71
+ var startDate = startDateMatch ? startDateMatch[1] : DateTime.format(new Date(), "YYYY-MM-DD");
72
+ var endDate = endDateMatch[1];
73
+
74
+ var swapDateTmp;
75
+ if(startDate > endDate) {
76
+ swapDateTmp = startDate;
77
+ startDate = endDate;
78
+ endDate = swapDateTmp;
79
+ }
80
+
81
+ var msBetweenDate = (+new Date(endDate)) - (+new Date(startDate));
82
+
83
+ var msInDay = 1000 * 60 * 60 * 24;
84
+ var betweenDay = msBetweenDate / msInDay;
85
+ // var betweenDay = Math.floor(Math.random() * 10); // For random length
86
+
87
+
88
+ for (i = 0; i <= betweenDay; i++) {
89
+ var date = new Date(new Date(startDate).setDate(new Date(startDate).getDate() + i));
90
+ var fieldValue = {
91
+ "h": true,
92
+ "v": DateTime.format(date, "YYYY-MM-DDT00:00:00")
93
+ };
94
+ if(index === 0) { // add header 1 time
95
+ rows[0].push(fieldValue);
96
+ }
97
+ }
98
+
99
+ var rics = identifiers;
100
+ for (i = 0; i < rics.length; i++) {
101
+
102
+ var ric = rics[i];
103
+ var rowValue = [
104
+ ric,
105
+ field
106
+ ];
107
+ for (j = 1; j <= betweenDay + 1; j++) {
108
+ var generatedValue = DataGenerator.generateRecord(field);
109
+ rowValue.push(generatedValue[field]);
110
+
111
+ }
112
+ rows.push(rowValue);
113
+ }
114
+ // The example rows should be look like
115
+ /*
116
+ [
117
+ [
118
+ {
119
+ "h": true,
120
+ "i": "instrument",
121
+ "v": "Instrument"
122
+ },
123
+ {
124
+ "h": true,
125
+ "i": "date",
126
+ "v": "Date"
127
+ },
128
+ {
129
+ "h": true,
130
+ "v": "2011-08-11T00:00:00"
131
+ },
132
+ {
133
+ "h": true,
134
+ "v": "2011-08-12T00:00:00"
135
+ },
136
+ {
137
+ "h": true,
138
+ "v": "2011-08-15T00:00:00"
139
+ }
140
+ ],
141
+ [
142
+ "IBM",
143
+ "Price Close", // NOTE: this cannot be detech we join it with space Ex. PriceClose
144
+ 159.25449372,
145
+ 160.6585848,
146
+ 165.23382036
147
+ ],
148
+ [
149
+ "GOOGL.O",
150
+ "Price Close",
151
+ 14.066881653,
152
+ 14.107921423,
153
+ 13.944262828
154
+ ]
155
+ ]
156
+ */
157
+ }
158
+
159
+ } else {
160
+
161
+ identifiers = payload.identifiers;
162
+ formula = Adc.splitFields(payload.formula);
163
+ fields = [];
164
+
165
+ // invalidFieldDict is a dictionary of non exist field
166
+ // so we must remove invalid field to make "mocking api" return result more like a "real api".
167
+ invalidDict = invalidFieldDict;
168
+ for (i = 0; i < formula.length; i++) {
169
+ f = formula[i];
170
+ if (!invalidDict[f]) {
171
+ fields.push(f);
172
+ }
173
+ }
174
+
175
+ rows[0] = [{
176
+ "h": true,
177
+ "i": "instrument",
178
+ "v": "Instrument"
179
+ }];
180
+ for (i = 0; i < fields.length; i++) {
181
+ f = fields[i];
182
+ rows[0].push({
183
+ "h": true,
184
+ "r": f.toUpperCase().trim()
185
+ // "v": "Price Close", // Doesn't use
186
+ // "p": "I_TRP_PH_PriceClose" // Doesn't use this property
187
+ });
188
+ }
189
+
190
+ // build data
191
+ var rowMap = {};
192
+
193
+ len = identifiers.length;
194
+ var rowData = dataGen.generate(fields, len);
195
+ for (i = 0; i < len; ++i) {
196
+ var inst = identifiers[i];
197
+ row = rowMap[inst];
198
+ if (!row) {
199
+ row = rowMap[inst] = rowData[i];
200
+ row.unshift(inst); // prepend instrument on each row
201
+ }
202
+ rows.push(row);
203
+ }
204
+
205
+ // There is a chance that rtk will return multiple row data per instrument
206
+ // so we must create mock up for this case
207
+ if (rows.length > 0) {
208
+ var chance = dataGen.randInt(1, 10);
209
+ if (chance <= 3) { // chance 30%
210
+ var pos = dataGen.randInt(0, rows.length - 1); // random row pos
211
+ row = rows[pos];
212
+ len = row.length;
213
+ var mockupRow = new Array(len);
214
+ mockupRow[0] = row[0]; // 1st index is for instrument
215
+ for (i = 1; i < len; i++) {
216
+ mockupRow[i] = ''; // real case will return null or empty string
217
+ }
218
+ rows.splice(pos + 1, 0, mockupRow);
219
+ }
220
+ }
221
+ }
222
+
223
+
224
+ /*
225
+ response type is :
226
+ {
227
+ cols: number,
228
+ faults: Array<obj>,
229
+ rows: Array<obj>,
230
+ status: string
231
+ }
232
+ Currently, we use only the rows property for cache ADC data
233
+ */
234
+ return Promise.resolve(JSON.stringify({
235
+ rows: rows
236
+ // TODO : supports faults property
237
+ }));
238
+ };
239
+
240
+ /**
241
+ * Splits a string of comma-separated fields into an array of individual field names with optional parentheses and contents.
242
+ *
243
+ * @param {string} strFields - The string of comma-separated fields to split.
244
+ * @returns {Array<string>} - An array of individual field names with optional parentheses and contents.
245
+ */
246
+ Adc.splitFields = function(strFields) {
247
+ if(!strFields) {
248
+ return [];
249
+ }
250
+
251
+ // Split the input string using the regular expression
252
+ // regex is match commas that are not inside parentheses
253
+ /*
254
+ , - matches a comma
255
+ (?![^()]*\) - negative lookahead assertion that matches if the comma is not followed by:
256
+ [^()]* - any characters that are not opening or closing parentheses
257
+ \) - a closing parenthesis
258
+ ) - ending delimiter of the regular expression
259
+ */
260
+ var fields = strFields.split(/,(?![^()]*\))/);
261
+ fields = fields.map(function(field) {
262
+ return field.trim();
263
+ });
264
+
265
+ return fields;
266
+ };
267
+
268
+ export { Adc };
@@ -10,6 +10,46 @@ var _joinSubKeys = function(subA, subB) {
10
10
  return subA.ric + "_" + subB.ric;
11
11
  };
12
12
 
13
+ /** @private
14
+ * @param {string} ric
15
+ * @return {boolean}
16
+ */
17
+ var _isDynamicChain = function(ric) {
18
+ // Dynamic chain will be 2 . (dot) for example .PG.PA
19
+ return ric.match(/\./g).length > 1;
20
+ };
21
+
22
+ /** @private
23
+ * @param {Array<Object>} arr sub children
24
+ * @return {Array<Object>}
25
+ */
26
+ var _shuffleArray = function(arr) {
27
+ var arrayShuffled = arr; // Modify original array
28
+ var i, randNumber, tmp;
29
+ // Shuffle the array randomly using the Fisher-Yates algorithm
30
+ for (i = arrayShuffled.length - 1; i > 0; i--) {
31
+ randNumber = Math.floor(Math.random() * (i + 1)); // TODO: it can be use this._dataGen.randInt(min, max) range
32
+ tmp = arrayShuffled[i];
33
+ arrayShuffled[i] = arrayShuffled[randNumber];
34
+ arrayShuffled[randNumber] = tmp;
35
+ }
36
+
37
+ // TODO: merge into 1 loop
38
+ // Update the CHILD_ORDER property based on the new index
39
+ arrayShuffled.forEach(_assignChildOrder);
40
+ arrayShuffled = arrayShuffled.sort(_childOrderSort);
41
+
42
+ return arrayShuffled;
43
+ };
44
+
45
+ var _assignChildOrder = function(obj, index) {
46
+ obj["CHILD_ORDER"] = index;
47
+ };
48
+
49
+ var _childOrderSort = function(a, b) {
50
+ return a["CHILD_ORDER"] - b["CHILD_ORDER"];
51
+ };
52
+
13
53
  /** @constructor */
14
54
  var MockQuotes2 = function() {
15
55
 
@@ -442,7 +482,7 @@ MockSubscriptions.prototype._addSymbol = function(ric, asChain, subId) {
442
482
  childSub["dataId"] = subId + childSub["ric"];
443
483
  childSub["parent"] = sub; // This does not exist in real subscription
444
484
  sub["children"].push(childSub);
445
-
485
+ childSub["CHILD_ORDER"] = i;
446
486
  this._dataMap.addItem(_joinSubKeys(sub, childSub), childSub);
447
487
  }
448
488
  } else {
@@ -489,7 +529,7 @@ MockSubscriptions.simpleDigest = function(str) {
489
529
  MockSubscriptions.prototype._connect = function() {
490
530
  if(this._working && !this._timerId) {
491
531
  var delay = this._dataGen.randInt(this._minInterval, this._maxInterval);
492
- this._timerId = window.setTimeout(this._onSubscriptionResponse, delay);
532
+ this._timerId = window.setTimeout(this._onSubscriptionResponse, delay); // This will be async for fire event to user
493
533
  }
494
534
  };
495
535
 
@@ -498,7 +538,7 @@ MockSubscriptions.prototype._onSubscriptionResponse = function() {
498
538
  this._timerId = 0;
499
539
 
500
540
  var keys = this._dataMap.getAllKeys(); // list of all rics
501
- var len = keys ? keys.length : 0;
541
+ var len = keys ? keys.length : 0; // len include all row index (Constituent and normal ric)
502
542
  if(!len) { // No symbol has been added
503
543
  this._connect();
504
544
  return;
@@ -516,16 +556,63 @@ MockSubscriptions.prototype._onSubscriptionResponse = function() {
516
556
  var subs = this._dataMap.getItems(key); // Get all subs with the same RIC
517
557
 
518
558
  var sub = subs[0]; // Only the first sub is need to generate data
519
- var values = this._generateQuoteData(sub, fields);
559
+ var subParent = sub.parent;
560
+ var updatePosition = this._dataGen.randBoolean(); // Flag for change CHILD_ORDER position
561
+
562
+ var values, j, jLen;
563
+ if(_isDynamicChain(key) && subParent && updatePosition) { // subParent in header of dynamic chain is behavior like a normal ric
564
+ // TODO: support rate of ordering is changed
565
+ var children = subParent.children;
566
+
567
+ children = _shuffleArray(children);
568
+ var childrenLen = children.length;
569
+ var subIndex = children.indexOf(sub);
570
+ sub["CHILD_ORDER"] = subIndex;
571
+
572
+ values = this._generateQuoteData(sub, fields);
573
+
574
+ jLen = subs.length;
575
+ for(j = 0; j < jLen; ++j) { // It could be same ric and it need to dispatch with same ric number
576
+ for (var k = 0; k < childrenLen; k++) {
577
+ var child = children[k];
578
+ if(subs[j] === child) {
579
+ values["CHILD_ORDER"] = child["CHILD_ORDER"];
580
+ this._dispatchDataChanged(subs[j], values);
581
+ } else {
582
+ var currentChild = child["CHILD_ORDER"];
583
+ this._dispatchDataChanged(child, {
584
+ X_RIC_NAME: child.ric,
585
+ CHILD_ORDER: currentChild
586
+ });
587
+ }
588
+ }
589
+ this._dispatchPostUpdate({ childOrderChange: true });
590
+ }
520
591
 
521
- var jLen = subs.length;
522
- for(var j = 0; j < jLen; ++j) {
523
- this._dispatchDataChanged(subs[j], values);
592
+ } else {
593
+ values = this._generateQuoteData(sub, fields);
594
+ jLen = subs.length;
595
+ for(j = 0; j < jLen; ++j) { // It could be same ric and it need to dispatch with same ric number
596
+ var childOrder = subs[j]["CHILD_ORDER"];
597
+ if(childOrder != null) { // Children of chain will have a CHILD_ORDER
598
+ values["CHILD_ORDER"] = childOrder;
599
+ }
600
+ this._dispatchDataChanged(subs[j], values);
601
+ }
524
602
  }
525
603
  }
526
604
 
527
605
  this._connect();
528
606
  };
607
+
608
+ /** @private
609
+ * @param {Object} obj
610
+ */
611
+ MockSubscriptions.prototype._dispatchPostUpdate = function (obj) {
612
+ // TODO: handlded another property of "postUpdate" event
613
+ this._dispatch("postUpdate", obj);
614
+ };
615
+
529
616
  /** @private
530
617
  * @param {Object} sub
531
618
  * @param {Object} fields
@@ -605,6 +692,7 @@ MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
605
692
  for(i = 1; i < subCount; ++i) {
606
693
  var sub = subs[i];
607
694
  if(!sub["prevData"]) {
695
+ // TODO: check in duplicate dynamic chain
608
696
  this._dispatchDataChanged(sub, prevData);
609
697
  }
610
698
  }
@@ -630,6 +718,7 @@ MockSubscriptions.prototype._updateDuplicateSymbol = function(ric) {
630
718
  var childSub2 = this._getChildSubByRic(sub2, childRic);
631
719
  if(childSub && childSub2) {
632
720
  if(childSub["prevData"]) {
721
+ // TODO: check in duplicate dynamic chain
633
722
  this._dispatchDataChanged(childSub2, childSub["prevData"]);
634
723
  }
635
724
  }
@@ -0,0 +1,7 @@
1
+
2
+
3
+ declare const invalidFieldDict: any;
4
+
5
+ declare function setInvalidFields(fields: (string)[]|string|null): void;
6
+
7
+ export { invalidFieldDict, setInvalidFields };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @public
3
+ * @type {Object}
4
+ */
5
+ var invalidFieldDict = {
6
+ 'TR.NonExistField': true,
7
+ 'TR.NotExistField': true,
8
+ 'CF_IGNORE_FIELD': true
9
+ };
10
+
11
+ /** to mock invalid fields.
12
+ * @public
13
+ * @param {Array<string>|string} fields ex. TR.NonExistField, CF_IGNORE_FIELD
14
+ */
15
+ function setInvalidFields(fields) {
16
+ if (fields && typeof fields === 'string') {
17
+ invalidFieldDict[fields] = true;
18
+ } else if (Array.isArray(fields)) {
19
+ for (var i = 0; i < fields.length; i++) {
20
+ invalidFieldDict[fields[i]] = true;
21
+ }
22
+ }
23
+ }
24
+
25
+ export { invalidFieldDict, setInvalidFields };
@@ -1,12 +1,11 @@
1
+ import { Adc } from "./Adc.js";
1
2
  import { DataGenerator } from "./DataGenerator.js";
2
- import { DateTime } from "../DateTime.js";
3
+ import { invalidFieldDict, setInvalidFields } from "./MockUtil.js";
3
4
 
4
5
  declare namespace DataGrid {
5
6
 
6
7
  }
7
8
 
8
- declare function setInvalidFields(fields: (string)[]|string|null): void;
9
-
10
9
  declare function mockDataAPI(dataType: string): Promise<any>|null;
11
10
 
12
11
  export { mockDataAPI, DataGrid, Adc, setInvalidFields };