@refinitiv-ui/efx-grid 6.0.33 → 6.0.35
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.
- package/lib/column-dragging/es6/ColumnDragging.js +50 -40
- package/lib/core/dist/core.js +210 -38
- package/lib/core/dist/core.min.js +1 -1
- package/lib/core/es6/data/DataTable.d.ts +3 -1
- package/lib/core/es6/data/DataTable.js +27 -9
- package/lib/core/es6/data/DataView.d.ts +2 -0
- package/lib/core/es6/data/DataView.js +12 -1
- package/lib/core/es6/data/Segment.d.ts +2 -0
- package/lib/core/es6/data/Segment.js +16 -0
- package/lib/core/es6/data/SegmentCollection.d.ts +1 -3
- package/lib/core/es6/data/SegmentCollection.js +25 -18
- package/lib/core/es6/grid/Core.d.ts +12 -0
- package/lib/core/es6/grid/Core.js +64 -2
- package/lib/core/es6/grid/plugins/SortableTitlePlugin.js +13 -7
- package/lib/grid/index.js +1 -1
- package/lib/grid/themes/halo/dark/efx-grid.js +1 -1
- package/lib/grid/themes/halo/dark/es5/all-elements.js +1 -1
- package/lib/grid/themes/halo/efx-grid.less +3 -1
- package/lib/grid/themes/halo/light/efx-grid.js +1 -1
- package/lib/grid/themes/halo/light/es5/all-elements.js +1 -1
- package/lib/rt-grid/dist/rt-grid.js +766 -293
- package/lib/rt-grid/dist/rt-grid.min.js +1 -1
- package/lib/rt-grid/es6/ColumnDefinition.js +13 -8
- package/lib/rt-grid/es6/DataConnector.js +3 -2
- package/lib/rt-grid/es6/Grid.d.ts +3 -1
- package/lib/rt-grid/es6/Grid.js +148 -40
- package/lib/rt-grid/es6/RowDefSorter.d.ts +5 -5
- package/lib/rt-grid/es6/RowDefSorter.js +165 -71
- package/lib/rt-grid/es6/RowDefinition.d.ts +7 -2
- package/lib/rt-grid/es6/RowDefinition.js +48 -10
- package/lib/rt-grid/es6/SnapshotFiller.d.ts +1 -0
- package/lib/rt-grid/es6/SnapshotFiller.js +1 -11
- package/lib/tr-grid-column-selection/es6/ColumnSelection.js +66 -0
- package/lib/tr-grid-column-stack/es6/ColumnStack.d.ts +2 -0
- package/lib/tr-grid-column-stack/es6/ColumnStack.js +38 -13
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.d.ts +12 -5
- package/lib/tr-grid-conditional-coloring/es6/ConditionalColoring.js +128 -42
- package/lib/tr-grid-heat-map/es6/HeatMap.d.ts +3 -3
- package/lib/tr-grid-heat-map/es6/HeatMap.js +13 -2
- package/lib/tr-grid-row-dragging/es6/RowDragging.d.ts +2 -1
- package/lib/tr-grid-row-dragging/es6/RowDragging.js +153 -17
- package/lib/tr-grid-rowcoloring/es6/RowColoring.js +3 -2
- package/lib/tr-grid-textformatting/es6/TextFormatting.d.ts +20 -20
- package/lib/tr-grid-textformatting/es6/TextFormatting.js +37 -138
- package/lib/tr-grid-util/es6/CellPainter.d.ts +1 -1
- package/lib/tr-grid-util/es6/CellPainter.js +56 -55
- package/lib/tr-grid-util/es6/DragUI.js +7 -3
- package/lib/tr-grid-util/es6/FieldFormatter.js +6 -2
- package/lib/tr-grid-util/es6/NumberFormatter.js +23 -11
- package/lib/tr-grid-util/es6/Util.d.ts +3 -0
- package/lib/tr-grid-util/es6/Util.js +53 -0
- package/lib/tr-grid-util/es6/jet/DataGenerator.js +36 -33
- package/lib/types/es6/ColumnStack.d.ts +2 -0
- package/lib/types/es6/ConditionalColoring.d.ts +12 -5
- package/lib/types/es6/Core/data/DataTable.d.ts +3 -1
- package/lib/types/es6/Core/data/DataView.d.ts +2 -0
- package/lib/types/es6/Core/data/Segment.d.ts +2 -0
- package/lib/types/es6/Core/data/SegmentCollection.d.ts +1 -3
- package/lib/types/es6/Core/grid/Core.d.ts +4 -0
- package/lib/types/es6/Core/grid/plugins/SortableTitlePlugin.d.ts +1 -0
- package/lib/types/es6/HeatMap.d.ts +3 -3
- package/lib/types/es6/RealtimeGrid/Grid.d.ts +3 -1
- package/lib/types/es6/RealtimeGrid/RowDefSorter.d.ts +5 -5
- package/lib/types/es6/RealtimeGrid/RowDefinition.d.ts +7 -2
- package/lib/types/es6/RealtimeGrid/SnapshotFiller.d.ts +1 -0
- package/lib/types/es6/RowDragging.d.ts +2 -1
- package/lib/types/es6/TextFormatting.d.ts +20 -20
- package/lib/versions.json +9 -9
- package/package.json +1 -1
@@ -7,30 +7,30 @@ import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
|
|
7
7
|
declare namespace TextFormattingPlugin {
|
8
8
|
|
9
9
|
type FormatOptions = {
|
10
|
-
formatType?: string,
|
11
|
-
type?: string,
|
12
|
-
field?: string,
|
13
|
-
decimalPlaces?: number,
|
14
|
-
precisionEnabled?: boolean,
|
15
|
-
plusSign?: boolean,
|
16
|
-
separator?: boolean,
|
17
|
-
percentSign?: boolean,
|
18
|
-
scalingUnit?: string,
|
19
|
-
multiplyBy100?: boolean,
|
20
|
-
mutiplyBy100?: boolean,
|
21
|
-
dateTimeFormat?: string,
|
22
|
-
useUTCTime?: boolean,
|
23
|
-
autoTextFormatting?: boolean,
|
24
|
-
formatLogic?: ((...params: any[]) => any)
|
10
|
+
formatType?: string|null,
|
11
|
+
type?: string|null,
|
12
|
+
field?: string|null,
|
13
|
+
decimalPlaces?: number|null,
|
14
|
+
precisionEnabled?: boolean|null,
|
15
|
+
plusSign?: boolean|null,
|
16
|
+
separator?: boolean|null,
|
17
|
+
percentSign?: boolean|null,
|
18
|
+
scalingUnit?: string|null,
|
19
|
+
multiplyBy100?: boolean|null,
|
20
|
+
mutiplyBy100?: boolean|null,
|
21
|
+
dateTimeFormat?: string|null,
|
22
|
+
useUTCTime?: boolean|null,
|
23
|
+
autoTextFormatting?: boolean|null,
|
24
|
+
formatLogic?: ((...params: any[]) => any)|null
|
25
25
|
};
|
26
26
|
|
27
27
|
type ColumnOptions = {
|
28
|
-
formatType?: (string|TextFormattingPlugin.FormatOptions),
|
29
|
-
autoTextFormatting?: boolean
|
28
|
+
formatType?: (string|TextFormattingPlugin.FormatOptions)|null,
|
29
|
+
autoTextFormatting?: boolean|null
|
30
30
|
};
|
31
31
|
|
32
32
|
type GridOptions = {
|
33
|
-
autoTextFormatting?: boolean
|
33
|
+
autoTextFormatting?: boolean|null
|
34
34
|
};
|
35
35
|
|
36
36
|
type FormatLogicArguments = {
|
@@ -40,7 +40,7 @@ declare namespace TextFormattingPlugin {
|
|
40
40
|
formattedText: string,
|
41
41
|
cell: any,
|
42
42
|
rowData: any,
|
43
|
-
format: ((...params: any[]) => any)
|
43
|
+
format: ((...params: any[]) => any)|null
|
44
44
|
};
|
45
45
|
|
46
46
|
}
|
@@ -61,7 +61,7 @@ declare class TextFormattingPlugin extends GridPlugin {
|
|
61
61
|
|
62
62
|
public getConfigObject(gridOptions?: any): any;
|
63
63
|
|
64
|
-
public setColumnFormat(colIndex: number, formatOptions: TextFormattingPlugin.FormatOptions): void;
|
64
|
+
public setColumnFormat(colIndex: number, formatOptions: TextFormattingPlugin.FormatOptions|null): void;
|
65
65
|
|
66
66
|
public getColumnFormatOptions(colIndex: number, options?: any): any;
|
67
67
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
2
|
-
|
3
2
|
import { Ext } from '../../tr-grid-util/es6/Ext.js';
|
4
3
|
import { GridPlugin } from '../../tr-grid-util/es6/GridPlugin.js';
|
5
4
|
import { NumberFormatter } from '../../tr-grid-util/es6/NumberFormatter.js';
|
6
5
|
import { FieldFormatter } from '../../tr-grid-util/es6/FieldFormatter.js';
|
7
6
|
import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
|
7
|
+
|
8
8
|
/** @event TextFormattingPlugin#formatChanged
|
9
9
|
* @description Fired only when a user click OK from the format dialog, that is generated from this extension
|
10
10
|
* @type {Object}
|
@@ -65,71 +65,60 @@ import { DateTime } from '../../tr-grid-util/es6/DateTime.js';
|
|
65
65
|
/** @constructor
|
66
66
|
* @extends {GridPlugin}
|
67
67
|
*/
|
68
|
-
|
69
68
|
var TextFormattingPlugin = function TextFormattingPlugin() {
|
70
69
|
this._onSectionBinding = this._onSectionBinding.bind(this);
|
71
70
|
this._onColumnAdded = this._onColumnAdded.bind(this);
|
72
71
|
this._hosts = [];
|
73
72
|
};
|
74
|
-
|
75
73
|
Ext.inherits(TextFormattingPlugin, GridPlugin);
|
74
|
+
|
76
75
|
/** @type {boolean}
|
77
76
|
* @private
|
78
77
|
*/
|
79
|
-
|
80
78
|
TextFormattingPlugin.prototype._noFormatting = true;
|
81
79
|
/** @type {boolean}
|
82
80
|
* @private
|
83
81
|
*/
|
84
|
-
|
85
82
|
TextFormattingPlugin.prototype._disabled = false;
|
86
83
|
/** @type {string}
|
87
84
|
* @private
|
88
85
|
*/
|
89
|
-
|
90
86
|
TextFormattingPlugin.prototype._idnSource = "";
|
87
|
+
|
91
88
|
/** @public
|
92
89
|
* @return {string}
|
93
90
|
*/
|
94
|
-
|
95
91
|
TextFormattingPlugin.prototype.getName = function () {
|
96
92
|
return "TextFormattingPlugin"; // Read Only
|
97
93
|
};
|
94
|
+
|
98
95
|
/** Plugin that has multi-table support means that it can have multiple hosts/tables and share its states across those hosts/tables.
|
99
96
|
* @public
|
100
97
|
* @return {boolean}
|
101
98
|
*/
|
102
|
-
|
103
|
-
|
104
99
|
TextFormattingPlugin.prototype.hasMultiTableSupport = function () {
|
105
100
|
return true;
|
106
101
|
};
|
102
|
+
|
107
103
|
/** @public
|
108
104
|
* @param {Object} host core grid instance
|
109
105
|
* @param {Object=} options
|
110
106
|
*/
|
111
|
-
|
112
|
-
|
113
107
|
TextFormattingPlugin.prototype.initialize = function (host, options) {
|
114
108
|
if (this._hosts.indexOf(host) >= 0) return;
|
115
|
-
|
116
109
|
this._hosts.push(host);
|
117
|
-
|
118
110
|
host.listen("postSectionDataBinding", this._onSectionBinding);
|
119
|
-
|
120
111
|
if (this._hosts.length === 1) {
|
121
112
|
host.listen("columnAdded", this._onColumnAdded);
|
122
113
|
this.config(options);
|
123
114
|
}
|
124
115
|
};
|
125
116
|
/** @override
|
117
|
+
* @ignore
|
126
118
|
*/
|
127
|
-
|
128
|
-
|
129
119
|
TextFormattingPlugin.prototype._afterInit = function () {
|
130
120
|
// WOWRKAROUND : In test-resource and tr-grid-util, avoid using static variables. duplicating DateTime
|
131
121
|
var rtGrid = this._realTimeGrid;
|
132
|
-
|
133
122
|
if (rtGrid && rtGrid.setDateTimeUtil) {
|
134
123
|
rtGrid.setDateTimeUtil(DateTime);
|
135
124
|
}
|
@@ -137,113 +126,89 @@ TextFormattingPlugin.prototype._afterInit = function () {
|
|
137
126
|
/** @public
|
138
127
|
* @param {Object} host core grid instance
|
139
128
|
*/
|
140
|
-
|
141
|
-
|
142
129
|
TextFormattingPlugin.prototype.unload = function (host) {
|
143
130
|
var at = this._hosts.indexOf(host);
|
144
|
-
|
145
131
|
if (at < 0) {
|
146
132
|
return;
|
147
133
|
}
|
148
|
-
|
149
134
|
host.unlisten("postSectionDataBinding", this._onSectionBinding);
|
150
135
|
host.unlisten("columnAdded", this._onColumnAdded);
|
151
|
-
|
152
136
|
this._hosts.splice(at, 1);
|
153
137
|
};
|
138
|
+
|
154
139
|
/** @public
|
155
140
|
* @param {Object=} options
|
156
141
|
*/
|
157
|
-
|
158
|
-
|
159
142
|
TextFormattingPlugin.prototype.config = function (options) {
|
160
143
|
if (!options) {
|
161
144
|
return;
|
162
145
|
}
|
163
|
-
|
164
146
|
this._idnSource = options["idnSource"] ? "idn" : "";
|
165
147
|
var bool = options["autoTextFormatting"];
|
166
|
-
|
167
148
|
if (bool != null) {
|
168
149
|
this._disabled = !bool;
|
169
150
|
}
|
170
|
-
|
171
151
|
var columns = options.columns;
|
172
|
-
|
173
152
|
if (!columns) {
|
174
153
|
return;
|
175
|
-
}
|
176
|
-
|
154
|
+
}
|
155
|
+
// WARNING: Name colliding between column definition and format option can occur
|
177
156
|
|
178
157
|
var dirty = 0;
|
179
158
|
var len = columns.length;
|
180
|
-
|
181
159
|
for (var i = 0; i < len; ++i) {
|
182
160
|
dirty |= this._setColumnFormat(i, columns[i]);
|
183
|
-
}
|
184
|
-
|
161
|
+
}
|
185
162
|
|
163
|
+
// WOWRKAROUND : In test-resource and tr-grid-util, avoid using static variables. duplicating DateTime
|
186
164
|
var lang = options["lang"];
|
187
|
-
|
188
165
|
if (lang) {
|
189
166
|
DateTime.setLocale(lang);
|
190
167
|
}
|
191
|
-
|
192
168
|
if (dirty) {
|
193
169
|
len = this._hosts.length;
|
194
|
-
|
195
170
|
for (i = 0; i < len; ++i) {
|
196
171
|
this._hosts[i]["requestRowRefresh"]();
|
197
172
|
}
|
198
173
|
}
|
199
174
|
};
|
175
|
+
|
200
176
|
/** @public
|
201
177
|
* @param {Object=} gridOptions
|
202
178
|
* @return {!Object}
|
203
179
|
*/
|
204
|
-
|
205
|
-
|
206
180
|
TextFormattingPlugin.prototype.getConfigObject = function (gridOptions) {
|
207
181
|
var obj = gridOptions || {};
|
208
|
-
|
209
182
|
if (this._idnSource) {
|
210
183
|
obj.idnSource = true;
|
211
184
|
}
|
212
|
-
|
213
185
|
if (this._disabled) {
|
214
186
|
obj.autoTextFormatting = false;
|
215
187
|
}
|
216
|
-
|
217
188
|
var columns = obj.columns;
|
218
|
-
|
219
189
|
if (!columns) {
|
220
190
|
columns = obj.columns = [];
|
221
191
|
}
|
222
|
-
|
223
192
|
var len = this.getColumnCount();
|
224
|
-
|
225
193
|
for (var i = 0; i < len; ++i) {
|
226
194
|
var column = columns[i];
|
227
|
-
|
228
195
|
if (!column) {
|
229
196
|
column = columns[i] = {};
|
230
197
|
}
|
231
|
-
|
232
198
|
this.getColumnFormatOptions(i, column);
|
199
|
+
// TODO: move the formatting option (column level) into formatting property (column extension option level)
|
233
200
|
}
|
234
201
|
|
235
202
|
return obj;
|
236
203
|
};
|
204
|
+
|
237
205
|
/** @public
|
238
206
|
* @param {number} colIndex
|
239
207
|
* @param {TextFormattingPlugin~FormatOptions} formatOptions
|
240
208
|
*/
|
241
|
-
|
242
|
-
|
243
209
|
TextFormattingPlugin.prototype.setColumnFormat = function (colIndex, formatOptions) {
|
244
210
|
if (this._setColumnFormat(colIndex, formatOptions)) {
|
245
211
|
var len = this._hosts.length;
|
246
|
-
|
247
212
|
for (var i = 0; i < len; ++i) {
|
248
213
|
this._hosts[i]["requestRowRefresh"]();
|
249
214
|
}
|
@@ -254,121 +219,101 @@ TextFormattingPlugin.prototype.setColumnFormat = function (colIndex, formatOptio
|
|
254
219
|
* @param {TextFormattingPlugin~FormatOptions} userObj This can be column configuration object or FormatTypeObject
|
255
220
|
* @return {boolean} Returns true if there is any change
|
256
221
|
*/
|
257
|
-
|
258
|
-
|
259
222
|
TextFormattingPlugin.prototype._setColumnFormat = function (colIndex, userObj) {
|
260
223
|
var colData = this._newColumnData(colIndex);
|
261
|
-
|
262
224
|
var colDef = userObj;
|
263
225
|
var fo = null; // Actual Format Options
|
264
226
|
|
265
227
|
var field;
|
266
|
-
|
267
228
|
if (colDef) {
|
268
229
|
// Extract field and format type
|
269
230
|
// Extract options from column definition object first
|
270
231
|
field = colDef["field"];
|
271
232
|
var autoTextFormatting = colDef["autoTextFormatting"];
|
272
|
-
|
273
233
|
if (autoTextFormatting != null) {
|
274
234
|
colData["autoTextFormatting"] = autoTextFormatting ? true : false;
|
275
235
|
}
|
276
|
-
|
277
236
|
var formatLogic = colDef["formatLogic"];
|
278
|
-
|
279
237
|
if (typeof formatLogic === "function") {
|
280
238
|
colData["formatLogic"] = formatLogic;
|
281
|
-
}
|
282
|
-
|
283
|
-
|
284
|
-
fo = colDef["formatType"] || colDef["type"]; // Format type may be an format option object at this point
|
239
|
+
}
|
285
240
|
|
241
|
+
// Fallback
|
242
|
+
fo = colDef["formatType"] || colDef["type"];
|
243
|
+
// Format type may be an format option object at this point
|
286
244
|
if (fo && _typeof(fo) === "object") {
|
287
245
|
// The formatType can be the format options (object) itself
|
288
246
|
if (fo["field"]) {
|
289
247
|
field = fo["field"];
|
290
248
|
}
|
291
|
-
|
292
249
|
autoTextFormatting = fo["autoTextFormatting"];
|
293
|
-
|
294
250
|
if (autoTextFormatting != null) {
|
295
251
|
colData["autoTextFormatting"] = autoTextFormatting ? true : false;
|
296
252
|
}
|
297
|
-
|
298
253
|
formatLogic = fo["formatLogic"];
|
299
|
-
|
300
254
|
if (typeof formatLogic === "function") {
|
301
255
|
colData["formatLogic"] = formatLogic;
|
302
256
|
}
|
303
257
|
} else {
|
304
|
-
fo = colDef;
|
258
|
+
fo = colDef;
|
259
|
+
// colDef = null;
|
305
260
|
}
|
306
261
|
}
|
307
262
|
|
308
263
|
var prevFO = colData["formatOptions"]; // For later use
|
309
|
-
// Clear previously stored data
|
310
264
|
|
265
|
+
// Clear previously stored data
|
311
266
|
colData["formatOptions"] = null;
|
312
267
|
colData["textFormatter"] = null;
|
313
|
-
colData["numberFormatter"] = null;
|
268
|
+
colData["numberFormatter"] = null;
|
314
269
|
|
270
|
+
// Check if the provided arguments are valid and sufficient
|
315
271
|
if (!fo) {
|
316
272
|
return prevFO ? true : false;
|
317
273
|
}
|
318
|
-
|
319
274
|
var fot = fo["formatType"] || fo["type"];
|
320
|
-
|
321
275
|
if (!fot || typeof fot != "string") {
|
322
276
|
// Format type must be string
|
323
277
|
return prevFO ? true : false;
|
324
278
|
}
|
325
|
-
|
326
279
|
fot = fot.toLowerCase(); // Guaranteed that all format types are case insensitive
|
327
|
-
|
328
280
|
if (fot === "general") {
|
329
281
|
// "general" type means no formatting
|
330
282
|
return prevFO ? true : false;
|
331
283
|
}
|
332
|
-
|
333
284
|
if (!field) {
|
334
285
|
// The field is not given try our best to get it
|
335
286
|
field = this._getField(colIndex);
|
336
|
-
|
337
287
|
if (!field) {
|
338
288
|
if (prevFO) {
|
339
289
|
field = prevFO["field"];
|
340
290
|
}
|
341
291
|
}
|
342
|
-
}
|
343
|
-
|
292
|
+
}
|
344
293
|
|
294
|
+
// Format option is valid after this point
|
345
295
|
this._noFormatting = false; // Quick workaround
|
346
|
-
// WARNING: We directly store and modify user data. This may inadvertently cause some bugs
|
347
296
|
|
297
|
+
// WARNING: We directly store and modify user data. This may inadvertently cause some bugs
|
348
298
|
fo["field"] = field;
|
349
299
|
fo["formatType"] = fot;
|
350
|
-
|
351
300
|
if (!fo["formattedField"]) {
|
352
301
|
fo["formattedField"] = field + "_FORMATTED";
|
353
302
|
}
|
354
|
-
|
355
303
|
if (fo["idnSource"] == null) {
|
356
304
|
fo["idnSource"] = this._idnSource;
|
357
305
|
}
|
358
|
-
|
359
306
|
var ff = new FieldFormatter(fo); // FieldFormatter will be used for rendering
|
360
|
-
|
361
307
|
var nf = null;
|
362
|
-
|
363
308
|
if (fot == "number" || fot == "scaled" || fot == "percent") {
|
364
309
|
nf = new NumberFormatter(fo);
|
365
310
|
ff.setNumberFormatter(nf.format);
|
366
311
|
}
|
367
|
-
|
368
312
|
colData["formatOptions"] = fo;
|
369
313
|
colData["textFormatter"] = ff;
|
370
|
-
colData["numberFormatter"] = nf;
|
314
|
+
colData["numberFormatter"] = nf;
|
371
315
|
|
316
|
+
// Everything is done. Request for re-rendering
|
372
317
|
return true;
|
373
318
|
};
|
374
319
|
/** @public
|
@@ -376,117 +321,85 @@ TextFormattingPlugin.prototype._setColumnFormat = function (colIndex, userObj) {
|
|
376
321
|
* @param {Object=} options Object for storing returned data
|
377
322
|
* @return {!Object}
|
378
323
|
*/
|
379
|
-
|
380
|
-
|
381
324
|
TextFormattingPlugin.prototype.getColumnFormatOptions = function (colIndex, options) {
|
382
325
|
if (!options) {
|
383
326
|
options = {};
|
384
327
|
}
|
385
|
-
|
386
328
|
var colData = this._getColumnData(colIndex);
|
387
|
-
|
388
329
|
if (colData) {
|
389
330
|
var formatOptions = colData["formatOptions"];
|
390
331
|
var textFormatter = colData["textFormatter"];
|
391
332
|
var numberFormatter = colData["numberFormatter"];
|
392
|
-
|
393
333
|
if (colData["autoTextFormatting"] != null) {
|
394
334
|
options["autoTextFormatting"] = colData["autoTextFormatting"];
|
395
335
|
}
|
396
|
-
|
397
336
|
if (formatOptions) {
|
398
337
|
options["formatType"] = formatOptions.formatType || formatOptions.type;
|
399
338
|
}
|
400
|
-
|
401
339
|
if (textFormatter) {
|
402
340
|
textFormatter.getOptions(options);
|
403
341
|
}
|
404
|
-
|
405
342
|
if (numberFormatter) {
|
406
343
|
numberFormatter.getOptions(options);
|
407
344
|
}
|
408
345
|
}
|
409
|
-
|
410
346
|
return options;
|
411
347
|
};
|
412
348
|
/** @private
|
413
349
|
* @param {Object} e
|
414
350
|
*/
|
415
|
-
|
416
|
-
|
417
351
|
TextFormattingPlugin.prototype._onColumnAdded = function (e) {
|
418
352
|
if (e.context) {
|
419
353
|
this._setColumnFormat(e.colIndex, e.context);
|
420
354
|
}
|
421
355
|
};
|
356
|
+
|
422
357
|
/** @private
|
423
358
|
* @param {Object} colData
|
424
359
|
* @return {boolean}
|
425
360
|
*/
|
426
|
-
|
427
|
-
|
428
361
|
TextFormattingPlugin._hasAutoFormatting = function (colData) {
|
429
362
|
if (colData) {
|
430
363
|
if (colData["autoTextFormatting"] === false || colData["percentBar"] || colData["rangeBar"]) {
|
431
364
|
return false;
|
432
365
|
}
|
433
|
-
|
434
366
|
return true;
|
435
367
|
}
|
436
|
-
|
437
368
|
return false;
|
438
369
|
};
|
370
|
+
|
439
371
|
/** @private
|
440
372
|
* @param {Object} e
|
441
373
|
*/
|
442
|
-
|
443
|
-
|
444
374
|
TextFormattingPlugin.prototype._onSectionBinding = function (e) {
|
445
375
|
if (this._noFormatting || this._disabled) {
|
446
376
|
return;
|
447
377
|
}
|
448
|
-
|
449
378
|
var section = e["section"];
|
450
379
|
var dataRows = e["dataRows"];
|
451
380
|
var colCount = section.getColumnCount();
|
452
|
-
var fromR =
|
453
|
-
/** @type{number} */
|
454
|
-
e["fromRowIndex"];
|
455
|
-
var toR =
|
456
|
-
/** @type{number} */
|
457
|
-
e["toRowIndex"];
|
381
|
+
var fromR = /** @type{number} */e["fromRowIndex"];
|
382
|
+
var toR = /** @type{number} */e["toRowIndex"];
|
458
383
|
var arg = {};
|
459
|
-
|
460
384
|
for (var c = 0; c < colCount; ++c) {
|
461
385
|
var colData = this._getColumnData(c); // will get column data from hosts[0] only
|
462
|
-
|
463
|
-
|
464
386
|
if (!TextFormattingPlugin._hasAutoFormatting(colData)) {
|
465
387
|
continue;
|
466
388
|
}
|
467
|
-
|
468
|
-
var formatOptions =
|
469
|
-
/** @type{TextFormattingPlugin~FormatOptions} */
|
470
|
-
colData["formatOptions"];
|
471
|
-
|
389
|
+
var formatOptions = /** @type{TextFormattingPlugin~FormatOptions} */colData["formatOptions"];
|
472
390
|
if (!formatOptions) {
|
473
391
|
continue;
|
474
392
|
}
|
475
|
-
|
476
393
|
var formatter = colData["textFormatter"];
|
477
394
|
var formatLogic = colData["formatLogic"];
|
478
395
|
arg.colIndex = c;
|
479
396
|
arg.field = formatter.getField();
|
480
397
|
arg.format = formatter.format; // WARNING: Accessing private member
|
481
|
-
|
482
398
|
for (var r = fromR; r < toR; ++r) {
|
483
399
|
var cell = section.getCell(c, r, false);
|
484
|
-
|
485
400
|
if (cell) {
|
486
401
|
var rowData = this._getRowData(dataRows[r]);
|
487
|
-
|
488
402
|
arg.formattedText = TextFormattingPlugin._getFormattedText(formatter, rowData, cell);
|
489
|
-
|
490
403
|
if (formatLogic) {
|
491
404
|
arg.rowIndex = r;
|
492
405
|
arg.cell = cell;
|
@@ -499,33 +412,29 @@ TextFormattingPlugin.prototype._onSectionBinding = function (e) {
|
|
499
412
|
}
|
500
413
|
}
|
501
414
|
};
|
415
|
+
|
502
416
|
/** @private
|
503
417
|
* @param {FieldFormatter} formatter
|
504
418
|
* @param {Object} rowData
|
505
419
|
* @param {Object} cell Grid cell instance
|
506
420
|
* @return {string}
|
507
421
|
*/
|
508
|
-
|
509
|
-
|
510
422
|
TextFormattingPlugin._getFormattedText = function (formatter, rowData, cell) {
|
511
423
|
if (rowData) {
|
512
424
|
return formatter.formatRowData(rowData);
|
513
425
|
} else {
|
514
426
|
var content = cell.getContent();
|
515
|
-
|
516
427
|
if (content) {
|
517
428
|
return formatter.formatValue(content.textContent);
|
518
429
|
}
|
519
430
|
}
|
520
|
-
|
521
431
|
return "";
|
522
432
|
};
|
433
|
+
|
523
434
|
/** @public
|
524
435
|
* @param {number} colIndex
|
525
436
|
* @return {FieldFormatter}
|
526
437
|
*/
|
527
|
-
|
528
|
-
|
529
438
|
TextFormattingPlugin.prototype.getFormatter = function (colIndex) {
|
530
439
|
return this._getColumnOption(colIndex, "textFormatter") || null;
|
531
440
|
};
|
@@ -535,28 +444,22 @@ TextFormattingPlugin.prototype.getFormatter = function (colIndex) {
|
|
535
444
|
* @param {*} obj The object can be string, number, boolean, or Date object
|
536
445
|
* @return {string}
|
537
446
|
*/
|
538
|
-
|
539
|
-
|
540
447
|
TextFormattingPlugin.prototype.formatText = function (colIndex, obj) {
|
541
448
|
if (obj != null) {
|
542
449
|
var formatter = this.getFormatter(colIndex);
|
543
450
|
return formatter ? formatter.formatValue(obj) : obj + "";
|
544
451
|
}
|
545
|
-
|
546
452
|
return "";
|
547
453
|
};
|
454
|
+
|
548
455
|
/** @public
|
549
456
|
* @param {number} colIndex
|
550
457
|
*/
|
551
|
-
|
552
|
-
|
553
458
|
TextFormattingPlugin.prototype.openDialog = function (colIndex) {
|
554
459
|
if (!this._formatDialog) {
|
555
460
|
this._formatDialog = document.createElement('tr-grid-format-dialog');
|
556
|
-
|
557
461
|
this._formatDialog.addEventListener('data-change', this._onFormatDialogDataChange.bind(this));
|
558
462
|
}
|
559
|
-
|
560
463
|
if (this._formatDialog.is === 'tr-grid-format-dialog') {
|
561
464
|
// Check that tr-grid-format-dialog is imported
|
562
465
|
var options = this.getColumnFormatOptions(colIndex);
|
@@ -564,23 +467,19 @@ TextFormattingPlugin.prototype.openDialog = function (colIndex) {
|
|
564
467
|
valueFormatTab: options
|
565
468
|
};
|
566
469
|
this._formatDialog.colIndex = colIndex;
|
567
|
-
|
568
470
|
this._formatDialog.show();
|
569
471
|
}
|
570
472
|
};
|
473
|
+
|
571
474
|
/** @private
|
572
475
|
* @param {Object} e
|
573
476
|
*/
|
574
|
-
|
575
|
-
|
576
477
|
TextFormattingPlugin.prototype._onFormatDialogDataChange = function (e) {
|
577
478
|
var colIndex = this._formatDialog.colIndex;
|
578
479
|
var obj = e.detail.data.valueFormatTab;
|
579
480
|
this.setColumnFormat(colIndex, obj);
|
580
481
|
obj.colIndex = colIndex;
|
581
|
-
|
582
482
|
this._dispatch("formatChanged", obj);
|
583
483
|
};
|
584
|
-
|
585
484
|
export default TextFormattingPlugin;
|
586
485
|
export { TextFormattingPlugin, TextFormattingPlugin as TextFormatting, TextFormattingPlugin as TextFormattingExtension };
|
@@ -79,7 +79,7 @@ declare class CellPainter {
|
|
79
79
|
|
80
80
|
public addHeatmapWithTheme(field: string, midPoint: number, opt_textMode?: (string|boolean)|null): any;
|
81
81
|
|
82
|
-
public addColorText(field: string,
|
82
|
+
public addColorText(field: string, upClass?: string|null, downClass?: string|null, levelClass?: string|null): any;
|
83
83
|
|
84
84
|
public addColorTextWithTheme(field: string): any;
|
85
85
|
|