@refinitiv-ui/efx-grid 6.0.103 → 6.0.105

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.
@@ -1,5 +1,6 @@
1
1
  import { Ext } from '../../tr-grid-util/es6/Ext.js';
2
2
  import { GridPlugin } from '../../tr-grid-util/es6/GridPlugin.js';
3
+
3
4
  /** @typedef {Object} ColumnFitterPlugin~Options
4
5
  * @description The options can be specified by `columnFitting` property of the main grid's options
5
6
  * @property {boolean=} proportion=false Proportionally expand columns, if there is enough space
@@ -23,392 +24,331 @@ import { GridPlugin } from '../../tr-grid-util/es6/GridPlugin.js';
23
24
  * @param {ColumnFitterPlugin~Options=} options
24
25
  * @extends {GridPlugin}
25
26
  */
27
+ let ColumnFitterPlugin = function (options) {
28
+ this._onItemResizeThisColumnClicked = this._onItemResizeThisColumnClicked.bind(this);
29
+ this._onItemResizeAllColumnClicked = this._onItemResizeAllColumnClicked.bind(this);
30
+ this._onPostSectionDataBinding = this._onPostSectionDataBinding.bind(this);
31
+ this._onColumnAdded = this._onColumnAdded.bind(this);
32
+ this._onTimeout = this._onTimeout.bind(this);
26
33
 
27
- var ColumnFitterPlugin = function ColumnFitterPlugin(options) {
28
- this._onItemResizeThisColumnClicked = this._onItemResizeThisColumnClicked.bind(this);
29
- this._onItemResizeAllColumnClicked = this._onItemResizeAllColumnClicked.bind(this);
30
- this._onPostSectionDataBinding = this._onPostSectionDataBinding.bind(this);
31
- this._onColumnAdded = this._onColumnAdded.bind(this);
32
- this._onTimeout = this._onTimeout.bind(this);
33
- this._hosts = [];
34
- this._dummyCells = [];
35
- this._cellPaddings = [];
36
- this.config(options);
37
- };
34
+ this._hosts = [];
35
+ this._dummyCells = [];
36
+ this._cellPaddings = [];
38
37
 
38
+ this.config(options);
39
+ };
39
40
  Ext.inherits(ColumnFitterPlugin, GridPlugin);
41
+
40
42
  /** @type {number}
41
43
  * @private
42
44
  */
43
-
44
45
  ColumnFitterPlugin.prototype._paddingSize = 2;
45
46
  /** @type {boolean}
46
47
  * @private
47
48
  */
48
-
49
49
  ColumnFitterPlugin.prototype._defaultPadding = true;
50
50
  /** @type {boolean}
51
51
  * @private
52
52
  */
53
-
54
53
  ColumnFitterPlugin.prototype._autoAdjust = false;
55
54
  /** @type {boolean}
56
55
  * @private
57
56
  */
58
-
59
57
  ColumnFitterPlugin.prototype._constraint = false;
60
58
  /** @type {boolean}
61
59
  * @private
62
60
  */
63
-
64
61
  ColumnFitterPlugin.prototype._proportion = false;
65
62
  /** If true, include title sections into the calculation
66
63
  * @type {boolean}
67
64
  * @private
68
65
  */
69
-
70
66
  ColumnFitterPlugin.prototype._title = false;
71
67
  /** Column can be shrunken after initial fitting
72
68
  * @type {boolean}
73
69
  * @private
74
70
  */
75
-
76
71
  ColumnFitterPlugin.prototype._shrinkable = false;
72
+
77
73
  /** @type {number}
78
74
  * @private
79
75
  */
80
-
81
76
  ColumnFitterPlugin.prototype._interval = 300;
82
77
  /** @type {number}
83
78
  * @private
84
79
  */
85
-
86
80
  ColumnFitterPlugin.prototype._timerId = 0;
87
81
  /** @type {Array.<Element>}
88
82
  * @private
89
83
  */
90
-
91
84
  ColumnFitterPlugin.prototype._dummyCells = null;
92
85
  /** @type {Array.<number>}
93
86
  * @private
94
87
  */
95
-
96
88
  ColumnFitterPlugin.prototype._cellPaddings = null;
97
89
  /** @type {number}
98
90
  * @private
99
91
  */
100
-
101
92
  ColumnFitterPlugin.prototype._synchronousRendering = true;
93
+
94
+
102
95
  /** @public
103
96
  * @return {string}
104
97
  */
105
-
106
98
  ColumnFitterPlugin.prototype.getName = function () {
107
- return "ColumnFitterPlugin"; // Read Only
99
+ return "ColumnFitterPlugin"; // Read Only
108
100
  };
101
+
109
102
  /**
110
103
  * @override
111
104
  * @return {boolean}
112
105
  */
113
-
114
-
115
106
  ColumnFitterPlugin.prototype.hasMultiTableSupport = function () {
116
- return true;
107
+ return true;
117
108
  };
109
+
118
110
  /** @public
119
111
  * @param {Object} host core grid object
120
112
  * @param {Object=} options
121
113
  */
122
-
123
-
124
114
  ColumnFitterPlugin.prototype.initialize = function (host, options) {
125
- if (this._hosts.indexOf(host) >= 0) {
126
- return;
127
- } // In case of multi-grid, grace period will be used multiple times because extension is a single instance.
128
-
129
-
130
- this._synchronousRendering = true;
131
-
132
- this._hosts.push(host);
133
-
134
- if (options) {
135
- var pluginOptions = options["columnFitting"] || {}; // Avoid using properties from the main object
136
-
137
- pluginOptions.columns = options["columns"]; // Retrieved property defined in the column
138
-
139
- this.config(pluginOptions);
140
- }
141
-
142
- if (this._autoAdjust) {
143
- host.listen("postSectionDataBinding", this._onPostSectionDataBinding);
144
- }
145
-
146
- host.listen("columnAdded", this._onColumnAdded); // In case of lazy loading
147
-
148
- this._onPostSectionDataBinding();
115
+ if (this._hosts.indexOf(host) >= 0) { return; }
116
+
117
+ // In case of multi-grid, grace period will be used multiple times because extension is a single instance.
118
+ this._synchronousRendering = true;
119
+ this._hosts.push(host);
120
+
121
+ if (options) {
122
+ let pluginOptions = options["columnFitting"] || {}; // Avoid using properties from the main object
123
+ pluginOptions.columns = options["columns"]; // Retrieved property defined in the column
124
+ this.config(pluginOptions);
125
+ }
126
+ if (this._autoAdjust) {
127
+ host.listen("postSectionDataBinding", this._onPostSectionDataBinding);
128
+ }
129
+ host.listen("columnAdded", this._onColumnAdded);
130
+ // In case of lazy loading
131
+ this._onPostSectionDataBinding();
149
132
  };
150
133
  /** @public
151
134
  * @param {Object} host core grid object
152
135
  */
153
-
154
-
155
136
  ColumnFitterPlugin.prototype.unload = function (host) {
156
- var at = this._hosts.indexOf(host);
137
+ let at = this._hosts.indexOf(host);
138
+ if (at < 0) { return; }
139
+ this._hosts.splice(at, 1);
157
140
 
158
- if (at < 0) {
159
- return;
160
- }
141
+ host.unlisten("postSectionDataBinding", this._onPostSectionDataBinding);
142
+ host.unlisten("columnAdded", this._onColumnAdded);
161
143
 
162
- this._hosts.splice(at, 1);
144
+ if (!this._hosts.length) {
145
+ if (this._timerId) {
146
+ clearTimeout(this._timerId);
147
+ this._timerId = 0;
148
+ }
149
+ }
150
+ };
163
151
 
164
- host.unlisten("postSectionDataBinding", this._onPostSectionDataBinding);
165
- host.unlisten("columnAdded", this._onColumnAdded);
166
152
 
167
- if (!this._hosts.length) {
168
- if (this._timerId) {
169
- clearTimeout(this._timerId);
170
- this._timerId = 0;
171
- }
172
- }
173
- };
174
153
  /** @public
175
154
  * @param {ColumnFitterPlugin~Options=} options
176
155
  */
177
-
178
-
179
156
  ColumnFitterPlugin.prototype.config = function (options) {
180
- if (!options) {
181
- return;
182
- }
183
-
184
- var columns = options["columns"];
185
-
186
- if (columns) {
187
- var column,
188
- len = columns.length;
189
-
190
- for (var c = 0; c < len; ++c) {
191
- column = columns[c];
192
-
193
- this._retrieveBooleanColumnOption(column, "noFitting", c);
194
-
195
- this._retrieveBooleanColumnOption(column, "contentFitting", c);
196
-
197
- this._retrieveColumnOption(column, "width", c);
198
-
199
- this._retrieveColumnOption(column, "scalable", c);
200
-
201
- this._retrieveColumnOption(column, "minWidth", c); // NOTE: minWidth is also used in core grid. This will make minWidth option redundant.
202
-
203
-
204
- this._retrieveColumnOption(column, "maxWidth", c);
205
- }
206
- }
207
-
208
- this._proportion = ColumnFitterPlugin._readBoolean(options, "proportion", this._proportion);
209
- this._constraint = ColumnFitterPlugin._readBoolean(options, "constraint", this._constraint);
210
- this._title = ColumnFitterPlugin._readBoolean(options, "title", this._title);
211
- this._shrinkable = ColumnFitterPlugin._readBoolean(options, "shrinkable", this._shrinkable);
212
-
213
- if (this._proportion) {
214
- var host = this._hosts[this._hosts.length - 1];
215
-
216
- if (host) {
217
- host.preserveProportion(true);
218
- }
219
- }
220
-
221
- var val = options["autoAdjust"] || options["autoAdjusting"];
222
-
223
- if (val != null) {
224
- this._autoAdjust = val ? true : false;
225
-
226
- if (typeof val === "number") {
227
- this._interval = val;
228
- }
229
- }
230
-
231
- var paddingSize =
232
- /** @type {number} */
233
- options["paddingSize"];
234
-
235
- if (paddingSize != null) {
236
- this._defaultPadding = false;
237
- this._paddingSize = paddingSize;
238
- }
239
-
240
- if (this._defaultPadding) {
241
- // Title section need extra padding to avoid ellipsis
242
- this._paddingSize = this._title ? 4 : 2;
243
- }
157
+ if (!options) { return; }
158
+
159
+ let columns = options["columns"];
160
+ if (columns) {
161
+ let column, len = columns.length;
162
+ for (let c = 0; c < len; ++c) {
163
+ column = columns[c];
164
+ this._retrieveBooleanColumnOption(column, "noFitting", c);
165
+ this._retrieveBooleanColumnOption(column, "contentFitting", c);
166
+ this._retrieveColumnOption(column, "width", c);
167
+ this._retrieveColumnOption(column, "scalable", c);
168
+ this._retrieveColumnOption(column, "minWidth", c); // NOTE: minWidth is also used in core grid. This will make minWidth option redundant.
169
+ this._retrieveColumnOption(column, "maxWidth", c);
170
+ }
171
+ }
172
+
173
+ this._proportion = ColumnFitterPlugin._readBoolean(options, "proportion", this._proportion);
174
+ this._constraint = ColumnFitterPlugin._readBoolean(options, "constraint", this._constraint);
175
+ this._title = ColumnFitterPlugin._readBoolean(options, "title", this._title);
176
+ this._shrinkable = ColumnFitterPlugin._readBoolean(options, "shrinkable", this._shrinkable);
177
+
178
+ if (this._proportion) {
179
+ let host = this._hosts[this._hosts.length - 1];
180
+ if (host) {
181
+ host.preserveProportion(true);
182
+ }
183
+ }
184
+
185
+ let val = options["autoAdjust"] || options["autoAdjusting"];
186
+ if (val != null) {
187
+ this._autoAdjust = val ? true : false;
188
+ if (typeof val === "number") {
189
+ this._interval = val;
190
+ }
191
+ }
192
+
193
+ let paddingSize = /** @type {number} */(options["paddingSize"]);
194
+ if (paddingSize != null) {
195
+ this._defaultPadding = false;
196
+ this._paddingSize = paddingSize;
197
+ }
198
+ if (this._defaultPadding) {
199
+ // Title section need extra padding to avoid ellipsis
200
+ this._paddingSize = (this._title) ? 4 : 2;
201
+ }
244
202
  };
203
+
245
204
  /** @public
246
205
  * @param {Object=} gridOptions
247
206
  * @return {!Object}
248
207
  */
249
-
250
-
251
208
  ColumnFitterPlugin.prototype.getConfigObject = function (gridOptions) {
252
- var obj = gridOptions || {};
253
- var columns = obj.columns;
254
-
255
- if (!columns) {
256
- columns = obj.columns = [];
257
- }
209
+ let obj = gridOptions || {};
258
210
 
259
- var len = this.getColumnCount();
211
+ let columns = obj.columns;
212
+ if (!columns) {
213
+ columns = obj.columns = [];
214
+ }
260
215
 
261
- for (var i = 0; i < len; ++i) {
262
- var column = columns[i];
216
+ let len = this.getColumnCount();
217
+ for (let i = 0; i < len; ++i) {
218
+ let column = columns[i];
219
+ if (!column) {
220
+ column = columns[i] = {};
221
+ }
263
222
 
264
- if (!column) {
265
- column = columns[i] = {};
266
- }
223
+ let colOptions = this._getColumnOption(i, "noFitting");
224
+ if (colOptions) {
225
+ column.noFitting = true;
226
+ }
227
+ }
267
228
 
268
- var colOptions = this._getColumnOption(i, "noFitting");
229
+ let extOptions = obj.columnFitting;
230
+ if (!extOptions) {
231
+ extOptions = obj.columnFitting = {};
232
+ }
269
233
 
270
- if (colOptions) {
271
- column.noFitting = true;
272
- }
273
- }
234
+ if (this._proportion) {
235
+ extOptions.proportion = true;
236
+ }
274
237
 
275
- var extOptions = obj.columnFitting;
238
+ if (this._constraint) {
239
+ extOptions.constraint = true;
240
+ }
276
241
 
277
- if (!extOptions) {
278
- extOptions = obj.columnFitting = {};
279
- }
242
+ if (this._title) {
243
+ extOptions.title = true;
244
+ }
280
245
 
281
- if (this._proportion) {
282
- extOptions.proportion = true;
283
- }
246
+ if (this._shrinkable) {
247
+ extOptions.shrinkable = true;
248
+ }
284
249
 
285
- if (this._constraint) {
286
- extOptions.constraint = true;
287
- }
250
+ if (this._autoAdjust) {
251
+ extOptions.autoAdjust = true;
252
+ }
288
253
 
289
- if (this._title) {
290
- extOptions.title = true;
291
- }
254
+ if (!this._defaultPadding) {
255
+ extOptions.paddingSize = this._paddingSize;
256
+ }
292
257
 
293
- if (this._shrinkable) {
294
- extOptions.shrinkable = true;
295
- }
296
-
297
- if (this._autoAdjust) {
298
- extOptions.autoAdjust = true;
299
- }
300
-
301
- if (!this._defaultPadding) {
302
- extOptions.paddingSize = this._paddingSize;
303
- }
304
-
305
- return obj;
258
+ return obj;
306
259
  };
260
+
307
261
  /** Function for ColumnMenuExtension to collect config of column menu
308
262
  * @public
309
263
  * @param {number} colIndex Column index
310
264
  * @param {Object} config Column Menu configuration
311
265
  * @return {!Object}
312
266
  */
313
-
314
-
315
267
  ColumnFitterPlugin.prototype.getColumnMenu = function (colIndex, config) {
316
- if (!config) {
317
- config = {};
318
- }
319
-
320
- var menus = config.menus;
321
-
322
- if (!menus) {
323
- menus = config.menus = [];
324
- }
325
-
326
- var menu = menus[0];
327
-
328
- if (!menu) {
329
- menu = menus[0] = {
330
- menuItems: []
331
- };
332
- } // Menu items for this extension
333
-
334
-
335
- var group = "USED_ONCE";
336
- var extMenuItems = [{
337
- indexScore: 2,
338
- label: "Autosize This Column",
339
- group: group,
340
- value: {
341
- colIndex: colIndex
342
- },
343
- click: this._onItemResizeThisColumnClicked
344
- }, {
345
- indexScore: 1,
346
- label: "Autosize All Columns",
347
- group: group,
348
- click: this._onItemResizeAllColumnClicked
349
- }]; // Push menu items to config
350
-
351
- Array.prototype.push.apply(menu.menuItems, extMenuItems);
352
- return config;
268
+ if (!config) {
269
+ config = {};
270
+ }
271
+
272
+ let menus = config.menus;
273
+ if (!menus) {
274
+ menus = config.menus = [];
275
+ }
276
+
277
+ let menu = menus[0];
278
+ if (!menu) {
279
+ menu = menus[0] = {
280
+ menuItems: []
281
+ };
282
+ }
283
+
284
+ // Menu items for this extension
285
+ let group = "USED_ONCE";
286
+ let extMenuItems = [{
287
+ indexScore: 2,
288
+ label: "Autosize This Column",
289
+ group: group,
290
+ value: { colIndex: colIndex },
291
+ click: this._onItemResizeThisColumnClicked
292
+ }, {
293
+ indexScore: 1,
294
+ label: "Autosize All Columns",
295
+ group: group,
296
+ click: this._onItemResizeAllColumnClicked
297
+ }];
298
+
299
+ // Push menu items to config
300
+ Array.prototype.push.apply(menu.menuItems, extMenuItems);
301
+
302
+ return config;
353
303
  };
304
+
354
305
  /** @private
355
306
  * @param {Object} e
356
307
  */
357
-
358
-
359
308
  ColumnFitterPlugin.prototype._onItemResizeThisColumnClicked = function (e) {
360
- this.adjustColumnWidth(e.currentTarget.value.colIndex);
361
-
362
- this._hideColumnMenu();
309
+ this.adjustColumnWidth(e.currentTarget.value.colIndex);
310
+ this._hideColumnMenu();
363
311
  };
312
+
364
313
  /** @private
365
314
  * @param {Object} e
366
315
  */
367
-
368
-
369
316
  ColumnFitterPlugin.prototype._onItemResizeAllColumnClicked = function (e) {
370
- this.adjustAllColumns();
371
-
372
- this._hideColumnMenu();
317
+ this.adjustAllColumns();
318
+ this._hideColumnMenu();
373
319
  };
320
+
374
321
  /** @private
375
322
  */
376
-
377
-
378
323
  ColumnFitterPlugin.prototype._hideColumnMenu = function () {
379
- var host = this._hosts[0];
380
- var columnMenuExt = host.getPlugin('ColumnMenuPlugin');
381
- columnMenuExt.hide();
324
+ let host = this._hosts[0];
325
+ let columnMenuExt = host.getPlugin('ColumnMenuPlugin');
326
+ columnMenuExt.hide();
382
327
  };
328
+
383
329
  /** @private
384
330
  * @param {Object} column
385
331
  * @param {string} propName
386
332
  * @param {number} colIndex
387
333
  */
388
-
389
-
390
334
  ColumnFitterPlugin.prototype._retrieveBooleanColumnOption = function (column, propName, colIndex) {
391
- if (column) {
392
- var bool = ColumnFitterPlugin._readBoolean(column, propName, false);
393
-
394
- this._newColumnData(colIndex)[propName] = bool;
395
- }
335
+ if (column) {
336
+ let bool = ColumnFitterPlugin._readBoolean(column, propName, false);
337
+ this._newColumnData(colIndex)[propName] = bool;
338
+ }
396
339
  };
397
340
  /** @private
398
341
  * @param {Object} column
399
342
  * @param {string} propName
400
343
  * @param {number} colIndex
401
344
  */
402
-
403
-
404
345
  ColumnFitterPlugin.prototype._retrieveColumnOption = function (column, propName, colIndex) {
405
- if (column) {
406
- var val = column[propName];
407
-
408
- if (val != null) {
409
- this._newColumnData(colIndex)[propName] = val;
410
- }
411
- }
346
+ if (column) {
347
+ let val = column[propName];
348
+ if (val != null) {
349
+ this._newColumnData(colIndex)[propName] = val;
350
+ }
351
+ }
412
352
  };
413
353
  /** Guarantee boolean value
414
354
  * @private
@@ -418,26 +358,21 @@ ColumnFitterPlugin.prototype._retrieveColumnOption = function (column, propName,
418
358
  * @param {boolean} defaultVal
419
359
  * @return {boolean}
420
360
  */
421
-
422
-
423
361
  ColumnFitterPlugin._readBoolean = function (obj, propName, defaultVal) {
424
- var val = obj[propName];
425
-
426
- if (val != null) {
427
- return val ? true : false;
428
- } else {
429
- return defaultVal;
430
- }
362
+ let val = obj[propName];
363
+ if (val != null) {
364
+ return val ? true : false;
365
+ } else {
366
+ return defaultVal;
367
+ }
431
368
  };
432
369
  /** Force update and calculation on a single column. It is not recommended to be used multiple time successively
433
370
  * @public
434
371
  * @param {Array.<number>=} colIndex Column indices
435
372
  * @return {boolean} True if there is any change, otherwise false
436
373
  */
437
-
438
-
439
374
  ColumnFitterPlugin.prototype.adjustColumnWidth = function (colIndex) {
440
- return this.adjustColumns([colIndex]);
375
+ return this.adjustColumns([colIndex]);
441
376
  };
442
377
  /** Force update and calculation on specific columns
443
378
  * @public
@@ -445,146 +380,114 @@ ColumnFitterPlugin.prototype.adjustColumnWidth = function (colIndex) {
445
380
  * @param {boolean=} force=true Force adjust the columns regardless of noFitting flag
446
381
  * @return {boolean} True if there is any change, otherwise false
447
382
  */
448
-
449
-
450
383
  ColumnFitterPlugin.prototype.adjustColumns = function (colIndices, force) {
451
- if (force == null) {
452
- force = true;
453
- }
454
-
455
- var candidates = this._collectCandidates(colIndices, force);
456
-
457
- var len = candidates.length;
458
-
459
- if (!len) {
460
- return false; // No valid column to be processed
461
- }
462
-
463
- var i, cd;
464
-
465
- for (i = 0; i < len; ++i) {
466
- cd = candidates[i];
467
-
468
- if (cd.text) {
469
- cd.elem.appendChild(this._getDummyCell(cd.index, cd.text)); // TODO: Handle case where the column is hidden or virtualized.
470
- }
471
- }
472
-
473
- var host = this._hosts[0];
474
- var widths = new Array(host.getColumnCount());
475
-
476
- for (i = 0; i < len; ++i) {
477
- cd = candidates[i];
478
-
479
- var width = this._calculateCellWidth(cd.index, host, cd.width); // WARNING: Only the first host is used
480
-
481
-
482
- var prevW = cd.elem._caclWidth || 0;
483
-
484
- if (width > prevW) {
485
- // Exclude zero width
486
- widths[cd.index] = width;
487
-
488
- if (this._autoAdjust && !this._shrinkable) {
489
- cd.elem._caclWidth = width;
490
- }
491
- }
492
- } // Remove all dummy cells
493
-
494
-
495
- for (i = 0; i < len; ++i) {
496
- var dummy = this._dummyCells[candidates[i].index];
497
-
498
- if (dummy && dummy.parentNode) {
499
- dummy.parentNode.removeChild(dummy);
500
- dummy.textContent = ""; // Reduce cache memory
501
- }
502
- }
503
-
504
- var dirty = 0;
505
- var hostCount = this._hosts.length;
506
-
507
- if (this._constraint) {
508
- for (i = 0; i < hostCount; ++i) {
509
- host = this._hosts[i];
510
- dirty |= host.setMinimumColumnWidths(widths);
511
- }
512
- } else {
513
- for (i = 0; i < hostCount; ++i) {
514
- host = this._hosts[i];
515
-
516
- if (host.isProportionPreserved()) {
517
- // Get proportion mode from grid
518
- var columnScalability = [];
519
-
520
- for (var columnIndex = 0; columnIndex < len; columnIndex++) {
521
- columnScalability.push(host.getColumnScalability(columnIndex));
522
- }
523
-
524
- dirty |= host.setColumnWidths(widths, columnScalability);
525
- } else {
526
- dirty |= host.setColumnWidths(widths);
527
- }
528
- }
529
- }
530
-
531
- this._synchronousRendering = false; // Next time will render asynchronously
532
-
533
- return !!dirty;
384
+ if (force == null) {
385
+ force = true;
386
+ }
387
+ let candidates = this._collectCandidates(colIndices, force);
388
+ let len = candidates.length;
389
+ if (!len) {
390
+ return false; // No valid column to be processed
391
+ }
392
+
393
+ let i, cd;
394
+ for (i = 0; i < len; ++i) {
395
+ cd = candidates[i];
396
+ if (cd.text) {
397
+ cd.elem.appendChild(this._getDummyCell(cd.index, cd.text)); // TODO: Handle case where the column is hidden or virtualized.
398
+ }
399
+ }
400
+
401
+ let host = this._hosts[0];
402
+ let widths = new Array(host.getColumnCount());
403
+ for (i = 0; i < len; ++i) {
404
+ cd = candidates[i];
405
+ let width = this._calculateCellWidth(cd.index, host, cd.width);// WARNING: Only the first host is used
406
+ let prevW = cd.elem._caclWidth || 0;
407
+ if (width > prevW) { // Exclude zero width
408
+ widths[cd.index] = width;
409
+ if (this._autoAdjust && !this._shrinkable) {
410
+ cd.elem._caclWidth = width;
411
+ }
412
+ }
413
+ }
414
+
415
+ // Remove all dummy cells
416
+ for (i = 0; i < len; ++i) {
417
+ let dummy = this._dummyCells[candidates[i].index];
418
+ if (dummy && dummy.parentNode) {
419
+ dummy.parentNode.removeChild(dummy);
420
+ dummy.textContent = ""; // Reduce cache memory
421
+ }
422
+ }
423
+
424
+ let dirty = 0;
425
+ let hostCount = this._hosts.length;
426
+ if (this._constraint) {
427
+ for (i = 0; i < hostCount; ++i) {
428
+ host = this._hosts[i];
429
+ dirty |= host.setMinimumColumnWidths(widths);
430
+ }
431
+ } else {
432
+ for (i = 0; i < hostCount; ++i) {
433
+ host = this._hosts[i];
434
+ if(host.isProportionPreserved()) { // Get proportion mode from grid
435
+ let columnScalability = [];
436
+ for (let columnIndex = 0; columnIndex < len; columnIndex++) {
437
+ columnScalability.push(host.getColumnScalability(columnIndex));
438
+ }
439
+ dirty |= host.setColumnWidths(widths, columnScalability);
440
+ } else {
441
+ dirty |= host.setColumnWidths(widths);
442
+ }
443
+ }
444
+ }
445
+
446
+ this._synchronousRendering = false; // Next time will render asynchronously
447
+
448
+ return !!dirty;
534
449
  };
535
450
  /** Force update and calculation on all columns
536
451
  * @public
537
452
  * @return {boolean} True if there is any change, otherwise false
538
453
  */
539
-
540
-
541
454
  ColumnFitterPlugin.prototype.adjustAllColumns = function () {
542
- return this.adjustColumns();
455
+ return this.adjustColumns();
543
456
  };
457
+
544
458
  /** @public
545
459
  * @param {number} colIndex
546
460
  * @return {number}
547
461
  */
548
-
549
-
550
462
  ColumnFitterPlugin.prototype.calculateColumnWidth = function (colIndex) {
551
- var host = this._hosts[0];
552
- var section = host ? host.getSection("content") : null;
553
-
554
- if (!section) {
555
- return NaN;
556
- }
557
-
558
- var colObj = section.getColumn(colIndex);
559
-
560
- if (!colObj) {
561
- return NaN; // The given column does not exist
562
- }
563
-
564
- var noFitting = this._getColumnOption(colIndex, "noFitting");
565
-
566
- if (noFitting) {
567
- return NaN;
568
- }
569
-
570
- var width, dummyCell;
571
-
572
- var contentFitting = this._getColumnOption(colIndex, "contentFitting");
573
-
574
- if (contentFitting) {
575
- width = this._getColumnFitContentWidth(colIndex);
576
- width = this._calculateCellWidth(colIndex, host, width);
577
- } else {
578
- var text = this._getColumnFitContentText(colIndex);
579
-
580
- dummyCell = this._getDummyCell(colIndex, text);
581
- var columnElem = colObj.getElement();
582
- columnElem.appendChild(dummyCell);
583
- width = this._calculateCellWidth(colIndex, host);
584
- columnElem.removeChild(dummyCell);
585
- }
586
-
587
- return width;
463
+ let host = this._hosts[0];
464
+ let section = host ? host.getSection("content") : null;
465
+ if (!section) {
466
+ return NaN;
467
+ }
468
+ let colObj = section.getColumn(colIndex);
469
+ if (!colObj) {
470
+ return NaN; // The given column does not exist
471
+ }
472
+ let noFitting = this._getColumnOption(colIndex, "noFitting");
473
+ if (noFitting) {
474
+ return NaN;
475
+ }
476
+
477
+ let width, dummyCell;
478
+ let contentFitting = this._getColumnOption(colIndex, "contentFitting");
479
+ if (contentFitting) {
480
+ width = this._getColumnFitContentWidth(colIndex);
481
+ width = this._calculateCellWidth(colIndex, host, width);
482
+ } else {
483
+ let text = this._getColumnFitContentText(colIndex);
484
+ dummyCell = this._getDummyCell(colIndex, text);
485
+ let columnElem = colObj.getElement();
486
+ columnElem.appendChild(dummyCell);
487
+ width = this._calculateCellWidth(colIndex, host);
488
+ columnElem.removeChild(dummyCell);
489
+ }
490
+ return width;
588
491
  };
589
492
  /** This is for backward compatability with old ColumnWidthAdjustingPlugin. The method is an alias of {@link ColumnFitterPlugin#calculateColumnWidth}
590
493
  * @public
@@ -592,109 +495,81 @@ ColumnFitterPlugin.prototype.calculateColumnWidth = function (colIndex) {
592
495
  * @param {number} colIndex
593
496
  * @return {number}
594
497
  */
595
-
596
-
597
498
  ColumnFitterPlugin.prototype.getAdjustedColumnWidth = ColumnFitterPlugin.prototype.calculateColumnWidth;
499
+
598
500
  /** Set all column widths to percentage width
599
501
  * @public
600
502
  */
601
-
602
503
  ColumnFitterPlugin.prototype.resetAllColumns = function () {
603
- var hosts = this._hosts;
604
- var colCount = this.getColumnCount();
605
- var host, width, proportion;
606
-
607
- for (var i = 0; i < hosts.length; i++) {
608
- host = hosts[i];
609
-
610
- for (var c = 0; c < colCount; c++) {
611
- width = this._getColumnOption(c, "width");
612
- proportion = this._getColumnOption(c, "scalable");
613
-
614
- if (width != null) {
615
- host.setColumnWidth(c, width, false);
616
- } else {
617
- host.setColumnWidth(c, 100, proportion !== false);
618
- }
619
- }
620
- }
504
+ let hosts = this._hosts;
505
+ let colCount = this.getColumnCount();
506
+ let host, width, proportion;
507
+ for (let i = 0; i < hosts.length; i++ ) {
508
+ host = hosts[i];
509
+ for (let c = 0; c < colCount; c++) {
510
+ width = this._getColumnOption(c, "width");
511
+ proportion = this._getColumnOption(c, "scalable");
512
+ if (width != null) {
513
+ host.setColumnWidth(c, width, false);
514
+ } else {
515
+ host.setColumnWidth(c, 100, proportion !== false);
516
+ }
517
+ }
518
+ }
621
519
  };
622
- /** @private */
623
520
 
624
521
 
522
+ /** @private */
625
523
  ColumnFitterPlugin.prototype._onPostSectionDataBinding = function () {
626
- if (!this._autoAdjust) {
627
- return;
628
- }
629
-
630
- if (this._synchronousRendering) {
631
- this.adjustColumns(null, false);
632
- return;
633
- }
634
-
635
- if (!this._timerId) {
636
- this._timerId = setTimeout(this._onTimeout, this._interval);
637
- }
524
+ if (!this._autoAdjust) { return; }
525
+ if (this._synchronousRendering) {
526
+ this.adjustColumns(null, false);
527
+ return;
528
+ }
529
+ if (!this._timerId) {
530
+ this._timerId = setTimeout(this._onTimeout, this._interval);
531
+ }
638
532
  };
639
533
  /** @private
640
534
  * @param {Object} e
641
535
  */
642
-
643
-
644
536
  ColumnFitterPlugin.prototype._onColumnAdded = function (e) {
645
- var context = e.context;
646
- var colIndex = e.colIndex;
647
-
648
- this._retrieveBooleanColumnOption(context, "noFitting", colIndex);
649
-
650
- this._retrieveBooleanColumnOption(context, "contentFitting", colIndex);
651
-
652
- this._retrieveColumnOption(context, "width", colIndex);
653
-
654
- this._retrieveColumnOption(context, "scalable", colIndex);
655
-
656
- this._retrieveColumnOption(context, "minWidth", colIndex); // NOTE: minWidth is also used in core grid. This will make minWidth option redundant.
657
-
658
-
659
- this._retrieveColumnOption(context, "maxWidth", colIndex);
660
-
661
- this._synchronousRendering = true;
537
+ let context = e.context;
538
+ let colIndex = e.colIndex;
539
+ this._retrieveBooleanColumnOption(context, "noFitting", colIndex);
540
+ this._retrieveBooleanColumnOption(context, "contentFitting", colIndex);
541
+ this._retrieveColumnOption(context, "width", colIndex);
542
+ this._retrieveColumnOption(context, "scalable", colIndex);
543
+ this._retrieveColumnOption(context, "minWidth", colIndex); // NOTE: minWidth is also used in core grid. This will make minWidth option redundant.
544
+ this._retrieveColumnOption(context, "maxWidth", colIndex);
545
+ this._synchronousRendering = true;
662
546
  };
663
547
  /** @private */
664
-
665
-
666
548
  ColumnFitterPlugin.prototype._onTimeout = function () {
667
- this._timerId = 0;
668
- this.adjustColumns(null, false);
549
+ this._timerId = 0;
550
+ this.adjustColumns(null, false);
669
551
  };
552
+
670
553
  /** @private
671
554
  * @param {Array.<number>=} colIndices Column indices
672
555
  * @param {boolean} force
673
556
  * @return {!Array.<Object>}
674
557
  */
675
-
676
-
677
558
  ColumnFitterPlugin.prototype._collectCandidates = function (colIndices, force) {
678
- var host = this._hosts[0];
679
- var section = host ? host.getSection("content") : null;
680
-
681
- if (!section) {
682
- return [];
683
- }
684
-
685
- var candidate;
686
- var candidates = [];
687
- var len = colIndices ? colIndices.length : host.getColumnCount();
688
-
689
- for (var i = 0; i < len; ++i) {
690
- candidate = this._collectCandidate(section, colIndices ? colIndices[i] : i, force);
691
-
692
- if (candidate) {
693
- candidates.push(candidate);
694
- }
695
- }
696
-
697
- return candidates;
559
+ let host = this._hosts[0];
560
+ let section = host ? host.getSection("content") : null;
561
+ if (!section) { return []; }
562
+
563
+ let candidate;
564
+ let candidates = [];
565
+ let len = colIndices ? colIndices.length : host.getColumnCount();
566
+ for (let i = 0; i < len; ++i) {
567
+ candidate = this._collectCandidate(section, colIndices ? colIndices[i] : i, force);
568
+ if (candidate) {
569
+ candidates.push(candidate);
570
+ }
571
+ }
572
+ return candidates;
698
573
  };
699
574
  /** @private
700
575
  * @param {Object} section ILayoutGrid
@@ -702,301 +577,241 @@ ColumnFitterPlugin.prototype._collectCandidates = function (colIndices, force) {
702
577
  * @param {boolean} force
703
578
  * @return {Object}
704
579
  */
705
-
706
-
707
580
  ColumnFitterPlugin.prototype._collectCandidate = function (section, colIndex, force) {
708
- var colObj = section.getColumn(colIndex);
709
-
710
- if (colObj) {
711
- var obj = {
712
- index: colIndex,
713
- elem: colObj.getElement()
714
- };
715
- var noFitting = force ? false : this._getColumnOption(colIndex, "noFitting");
716
-
717
- var contentFitting = this._getColumnOption(colIndex, "contentFitting");
718
-
719
- if (!noFitting) {
720
- if (contentFitting) {
721
- var width = this._getColumnFitContentWidth(colIndex);
722
-
723
- if (width > 0) {
724
- obj.width = width;
725
- }
726
- } else {
727
- var text = this._getColumnFitContentText(colIndex);
728
-
729
- if (text) {
730
- obj.text = text;
731
- }
732
- }
733
- }
734
-
735
- return obj;
736
- }
737
-
738
- return null;
581
+ let colObj = section.getColumn(colIndex);
582
+ if (colObj) {
583
+ let obj = {
584
+ index: colIndex,
585
+ elem: colObj.getElement()
586
+ };
587
+ let noFitting = force ? false : this._getColumnOption(colIndex, "noFitting");
588
+ let contentFitting = this._getColumnOption(colIndex, "contentFitting");
589
+ if (!noFitting) {
590
+ if (contentFitting) {
591
+ let width = this._getColumnFitContentWidth(colIndex);
592
+ if (width > 0) {
593
+ obj.width = width;
594
+ }
595
+ } else {
596
+ let text = this._getColumnFitContentText(colIndex);
597
+ if (text) {
598
+ obj.text = text;
599
+ }
600
+ }
601
+ }
602
+ return obj;
603
+ }
604
+ return null;
739
605
  };
740
606
  /** @private
741
607
  * @description Calculate width of cell's custom rendered content
742
608
  * @param {number} colIndex
743
609
  * @return {number}
744
610
  */
745
-
746
-
747
611
  ColumnFitterPlugin.prototype._getColumnFitContentWidth = function (colIndex) {
748
- var w, contentWidth;
749
- var width = 0;
750
-
751
- var cellPadding = this._getCellPadding(colIndex);
752
-
753
- for (var i = this._hosts.length; --i >= 0;) {
754
- var host = this._hosts[i];
755
- var sections = host.getAllSections("content");
756
- var sectionCount = sections.length;
757
-
758
- for (var s = 0; s < sectionCount; s++) {
759
- var section = sections[s];
760
- var fi = section.getFirstIndexInView();
761
- var li = section.getLastIndexInView() + 1;
762
-
763
- for (var r = fi; r < li; r++) {
764
- var cell = section.getCell(colIndex, r, false);
765
-
766
- if (!cell) {
767
- continue;
768
- }
769
-
770
- var cellElem = cell.getElement();
771
-
772
- if (cellElem.classList.contains("tr-stretched")) {
773
- continue;
774
- }
775
-
776
- var content = cell.getContent();
777
-
778
- if (content && cellElem && cell.isVisible()) {
779
- w = contentWidth = content.offsetWidth;
780
- var children = content.children;
781
-
782
- var isWidth100Pct = ColumnFitterPlugin._almost100Pct(contentWidth + cellPadding, cellElem.offsetWidth);
783
-
784
- var hasChild = children.length > 0;
785
-
786
- if (isWidth100Pct && hasChild) {
787
- // Content width is 100% of cell.
788
- w = ColumnFitterPlugin._sumChildrenWidth(children); // Use children to calculate width
789
- }
790
-
791
- if (w > width) {
792
- width = w;
793
- }
794
- }
795
- }
796
- }
797
- }
798
-
799
- if (!width) {
800
- // If there is no with, clear cell padding cache.
801
- this._cellPaddings[colIndex] = 0;
802
- return 0;
803
- }
804
-
805
- return width + cellPadding;
612
+ let w, contentWidth;
613
+ let width = 0;
614
+ let cellPadding = this._getCellPadding(colIndex);
615
+ for (let i = this._hosts.length; --i >= 0;) {
616
+ let host = this._hosts[i];
617
+ let sections = host.getAllSections("content");
618
+ let sectionCount = sections.length;
619
+ for (let s = 0; s < sectionCount; s++) {
620
+ let section = sections[s];
621
+ let fi = section.getFirstIndexInView();
622
+ let li = section.getLastIndexInView() + 1;
623
+ for (let r = fi; r < li; r++) {
624
+ let cell = section.getCell(colIndex, r, false);
625
+ if (!cell) {
626
+ continue;
627
+ }
628
+ let cellElem = cell.getElement();
629
+ if (cellElem.classList.contains("tr-stretched")) {
630
+ continue;
631
+ }
632
+ let content = cell.getContent();
633
+
634
+ if (content && cellElem && cell.isVisible()) {
635
+ w = contentWidth = content.offsetWidth;
636
+ let children = content.children;
637
+
638
+ let isWidth100Pct = ColumnFitterPlugin._almost100Pct(contentWidth + cellPadding, cellElem.offsetWidth);
639
+ let hasChild = children.length > 0;
640
+
641
+ if (isWidth100Pct && hasChild) { // Content width is 100% of cell.
642
+ w = ColumnFitterPlugin._sumChildrenWidth(children); // Use children to calculate width
643
+ }
644
+ if (w > width) {
645
+ width = w;
646
+ }
647
+ }
648
+ }
649
+ }
650
+ }
651
+ if (!width) {
652
+ // If there is no with, clear cell padding cache.
653
+ this._cellPaddings[colIndex] = 0;
654
+ return 0;
655
+ }
656
+ return width + cellPadding;
806
657
  };
807
658
  /** @private
808
659
  * @param {number} colIndex
809
660
  * @return {string}
810
661
  */
811
-
812
-
813
662
  ColumnFitterPlugin.prototype._getColumnFitContentText = function (colIndex) {
814
- var maxLen = NaN;
815
- var filteringChars = 3; // TODO: Change this default value
816
-
817
- var texts = [];
818
-
819
- for (var i = this._hosts.length; --i >= 0;) {
820
- var host = this._hosts[i];
821
- var sections = host.getAllSections("content"); // TODO: Get data from the datasource
822
-
823
- if (this._title) {
824
- sections = host.getAllSections("title").concat(sections);
825
- }
826
-
827
- var sectionCount = sections.length;
828
-
829
- for (var s = 0; s < sectionCount; s++) {
830
- var section = sections[s];
831
- var fi = section.getFirstIndexInView();
832
- var li = section.getLastIndexInView() + 1;
833
-
834
- for (var r = fi; r < li; r++) {
835
- var cell = section.getCell(colIndex, r, false); // Ignore cell span
836
-
837
- if (!cell) {
838
- continue;
839
- }
840
-
841
- var text = cell.getTextContent(); // Content can only be string
842
-
843
- if (text && cell.getElement() && cell.isVisible()) {
844
- // Due to timer nature of the algorithm
845
- var textLen = text.length;
846
-
847
- if (textLen <= maxLen) {
848
- if (textLen >= maxLen - filteringChars) {
849
- texts.push(text);
850
- }
851
- } else {
852
- maxLen = textLen;
853
- texts.push(text);
854
- }
855
- }
856
- }
857
- }
858
- }
859
-
860
- return texts.length ? texts.join("\n") : "";
663
+ let maxLen = NaN;
664
+ let filteringChars = 3; // TODO: Change this default value
665
+ let texts = [];
666
+ for (let i = this._hosts.length; --i >= 0;) {
667
+ let host = this._hosts[i];
668
+ let sections = host.getAllSections("content"); // TODO: Get data from the datasource
669
+ if (this._title) {
670
+ sections = host.getAllSections("title").concat(sections);
671
+ }
672
+ let sectionCount = sections.length;
673
+ for (let s = 0; s < sectionCount; s++) {
674
+ let section = sections[s];
675
+ let fi = section.getFirstIndexInView();
676
+ let li = section.getLastIndexInView() + 1;
677
+ for (let r = fi; r < li; r++) {
678
+ let cell = section.getCell(colIndex, r, false); // Ignore cell span
679
+ if (!cell) {
680
+ continue;
681
+ }
682
+
683
+ let text = cell.getTextContent(); // Content can only be string
684
+ if (text && cell.getElement() && cell.isVisible()) { // Due to timer nature of the algorithm
685
+ let textLen = text.length;
686
+ if (textLen <= maxLen) {
687
+ if (textLen >= maxLen - filteringChars) {
688
+ texts.push(text);
689
+ }
690
+ } else {
691
+ maxLen = textLen;
692
+ texts.push(text);
693
+ }
694
+ }
695
+ }
696
+ }
697
+ }
698
+ return texts.length ? texts.join("\n") : "";
861
699
  };
862
700
  /** @private
863
701
  * @param {number} colIndex
864
702
  * @param {string=} text
865
703
  * @return {Element}
866
704
  */
867
-
868
-
869
705
  ColumnFitterPlugin.prototype._getDummyCell = function (colIndex, text) {
870
- var dummyCell = this._dummyCells[colIndex];
871
-
872
- if (!dummyCell) {
873
- dummyCell = this._dummyCells[colIndex] = ColumnFitterPlugin._createDummyCell();
874
- }
875
-
876
- if (text) {
877
- // TODO: Check if we can find a better way to improve innerText
878
- dummyCell.innerText = text; // innerText will populate <br> tag from the newline character '\n'
879
- }
880
-
881
- return dummyCell;
706
+ let dummyCell = this._dummyCells[colIndex];
707
+ if (!dummyCell) {
708
+ dummyCell = this._dummyCells[colIndex] = ColumnFitterPlugin._createDummyCell();
709
+ }
710
+ if (text) {
711
+ // TODO: Check if we can find a better way to improve innerText
712
+ dummyCell.innerText = text; // innerText will populate <br> tag from the newline character '\n'
713
+ }
714
+ return dummyCell;
882
715
  };
716
+
883
717
  /** @private
884
718
  * @param {number} colIndex
885
719
  * @return {number}
886
720
  */
887
-
888
-
889
721
  ColumnFitterPlugin.prototype._getCellPadding = function (colIndex) {
890
- var cellPadding = this._cellPaddings[colIndex];
891
-
892
- if (cellPadding > 0) {
893
- return cellPadding;
894
- }
722
+ let cellPadding = this._cellPaddings[colIndex];
895
723
 
896
- var host = this._hosts[0];
897
- var section = host ? host.getSection("content") : null;
898
- var colObj = section.getColumn(colIndex);
724
+ if (cellPadding > 0) {
725
+ return cellPadding;
726
+ }
899
727
 
900
- if (!colObj) {
901
- cellPadding = this._cellPaddings[colIndex] = NaN;
902
- return cellPadding;
903
- }
728
+ let host = this._hosts[0];
729
+ let section = host ? host.getSection("content") : null;
730
+ let colObj = section.getColumn(colIndex);
731
+ if (!colObj) {
732
+ cellPadding = this._cellPaddings[colIndex] = NaN;
733
+ return cellPadding;
734
+ }
904
735
 
905
- var columnElem = colObj.getElement();
906
-
907
- var dummyCell = ColumnFitterPlugin._createDummyCell();
908
-
909
- columnElem.appendChild(dummyCell);
910
- var width = this._cellPaddings[colIndex] = dummyCell.offsetWidth;
911
- columnElem.removeChild(dummyCell);
912
- return width;
736
+ let columnElem = colObj.getElement();
737
+ let dummyCell = ColumnFitterPlugin._createDummyCell();
738
+ columnElem.appendChild(dummyCell);
739
+ let width = this._cellPaddings[colIndex] = dummyCell.offsetWidth;
740
+ columnElem.removeChild(dummyCell);
741
+ return width;
913
742
  };
743
+
914
744
  /** @private
915
745
  * @param {number} colIndex
916
746
  * @param {Object} grid core grid object
917
747
  * @param {number=} opt_width Optional initial width
918
748
  * @return {number}
919
749
  */
920
-
921
-
922
750
  ColumnFitterPlugin.prototype._calculateCellWidth = function (colIndex, grid, opt_width) {
923
- var minWidth = NaN;
924
- var maxWidth = NaN;
925
- var colDef = grid.getColumnData(colIndex);
926
-
927
- if (colDef) {
928
- minWidth = colDef["minWidth"] || NaN;
929
- maxWidth = colDef["maxWidth"] || NaN;
930
- }
931
-
932
- var width;
933
-
934
- if (opt_width) {
935
- width = opt_width;
936
- } else {
937
- var dummyCell = this._dummyCells[colIndex];
938
-
939
- if (dummyCell) {
940
- // NOTE: If font isn't cached, comparison is being done against Arial instead of Proxima Nova, thus yielding wrong offsetwidth
941
- width = dummyCell.offsetWidth; // TODO: Handle case where the column is hidden or virtualized
942
- }
943
- }
944
-
945
- if (width) {
946
- width += this._paddingSize;
947
-
948
- if (width > maxWidth) {
949
- width = maxWidth;
950
- }
951
-
952
- if (width < minWidth) {
953
- width = minWidth;
954
- }
955
- }
956
-
957
- return width;
751
+ let minWidth = NaN;
752
+ let maxWidth = NaN;
753
+ let colDef = grid.getColumnData(colIndex);
754
+ if (colDef) {
755
+ minWidth = colDef["minWidth"] || NaN;
756
+ maxWidth = colDef["maxWidth"] || NaN;
757
+ }
758
+
759
+ let width;
760
+ if (opt_width) {
761
+ width = opt_width;
762
+ } else {
763
+ let dummyCell = this._dummyCells[colIndex];
764
+ if (dummyCell) {
765
+ // NOTE: If font isn't cached, comparison is being done against Arial instead of Proxima Nova, thus yielding wrong offsetwidth
766
+ width = dummyCell.offsetWidth; // TODO: Handle case where the column is hidden or virtualized
767
+ }
768
+ }
769
+ if (width) {
770
+ width += this._paddingSize;
771
+ if (width > maxWidth) {
772
+ width = maxWidth;
773
+ }
774
+ if (width < minWidth) {
775
+ width = minWidth;
776
+ }
777
+ }
778
+ return width;
958
779
  };
780
+
959
781
  /** @private
960
782
  * @param {NodeList} childNodes
961
783
  * @return {number}
962
784
  */
963
-
964
-
965
785
  ColumnFitterPlugin._sumChildrenWidth = function (childNodes) {
966
- var len = childNodes.length;
967
-
968
- if (len > 0) {
969
- var last = childNodes[len - 1];
970
- var first = childNodes[0];
971
- return last.offsetWidth + last.offsetLeft - first.offsetLeft;
972
- }
973
-
974
- return 0;
786
+ let len = childNodes.length;
787
+ if (len > 0) {
788
+ let last = childNodes[len - 1];
789
+ let first = childNodes[0];
790
+ return last.offsetWidth + last.offsetLeft - first.offsetLeft;
791
+ }
792
+ return 0;
975
793
  };
794
+
976
795
  /** @private
977
796
  * @return {Element}
978
797
  */
979
-
980
-
981
798
  ColumnFitterPlugin._createDummyCell = function () {
982
- var dummyCell = document.createElement("div");
983
- dummyCell.className = "cell";
984
- dummyCell.style.whiteSpace = "nowrap"; // Inline style will override everything
985
-
986
- dummyCell.style.width = "auto";
987
- dummyCell.style.display = "table";
988
- return dummyCell;
799
+ let dummyCell = document.createElement("div");
800
+ dummyCell.className = "cell";
801
+ dummyCell.style.whiteSpace = "nowrap"; // Inline style will override everything
802
+ dummyCell.style.width = "auto";
803
+ dummyCell.style.display = "table";
804
+ return dummyCell;
989
805
  };
990
806
  /** @private
991
807
  * @param {number} val1
992
808
  * @param {number} val2
993
809
  * @return {boolean}
994
810
  */
995
-
996
-
997
811
  ColumnFitterPlugin._almost100Pct = function (val1, val2) {
998
- return (val1 > val2 ? val2 / val1 : val1 / val2) >= 0.97;
812
+ return (val1 > val2 ? val2 / val1 : val1 / val2) >= 0.97;
999
813
  };
1000
814
 
815
+
1001
816
  export default ColumnFitterPlugin;
1002
- export { ColumnFitterPlugin, ColumnFitterPlugin as ColumnFitter, ColumnFitterPlugin as ColumnFitterExtension };
817
+ export { ColumnFitterPlugin, ColumnFitterPlugin as ColumnFitter, ColumnFitterPlugin as ColumnFitterExtension };