melondtable 1.19.0 → 1.21.2

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.
@@ -298,13 +298,6 @@ var DataTable = (function (Sortable) {
298
298
 
299
299
  var _root = root;
300
300
 
301
- var _root$1 = /*#__PURE__*/Object.freeze({
302
- default: _root,
303
- __moduleExports: _root
304
- });
305
-
306
- var root$1 = ( _root$1 && _root ) || _root$1;
307
-
308
301
  /**
309
302
  * Gets the timestamp of the number of milliseconds that have elapsed since
310
303
  * the Unix epoch (1 January 1970 00:00:00 UTC).
@@ -322,13 +315,13 @@ var DataTable = (function (Sortable) {
322
315
  * // => Logs the number of milliseconds it took for the deferred invocation.
323
316
  */
324
317
  var now = function() {
325
- return root$1.Date.now();
318
+ return _root.Date.now();
326
319
  };
327
320
 
328
321
  var now_1 = now;
329
322
 
330
323
  /** Built-in value references. */
331
- var Symbol = root$1.Symbol;
324
+ var Symbol = _root.Symbol;
332
325
 
333
326
  var _Symbol = Symbol;
334
327
 
@@ -376,11 +369,6 @@ var DataTable = (function (Sortable) {
376
369
 
377
370
  var _getRawTag = getRawTag;
378
371
 
379
- var _getRawTag$1 = /*#__PURE__*/Object.freeze({
380
- default: _getRawTag,
381
- __moduleExports: _getRawTag
382
- });
383
-
384
372
  /** Used for built-in method references. */
385
373
  var objectProto$1 = Object.prototype;
386
374
 
@@ -404,8 +392,6 @@ var DataTable = (function (Sortable) {
404
392
 
405
393
  var _objectToString = objectToString;
406
394
 
407
- var getRawTag$1 = ( _getRawTag$1 && _getRawTag ) || _getRawTag$1;
408
-
409
395
  /** `Object#toString` result references. */
410
396
  var nullTag = '[object Null]',
411
397
  undefinedTag = '[object Undefined]';
@@ -425,7 +411,7 @@ var DataTable = (function (Sortable) {
425
411
  return value === undefined ? undefinedTag : nullTag;
426
412
  }
427
413
  return (symToStringTag$1 && symToStringTag$1 in Object(value))
428
- ? getRawTag$1(value)
414
+ ? _getRawTag(value)
429
415
  : _objectToString(value);
430
416
  }
431
417
 
@@ -488,13 +474,6 @@ var DataTable = (function (Sortable) {
488
474
 
489
475
  var isSymbol_1 = isSymbol;
490
476
 
491
- var isSymbol$1 = /*#__PURE__*/Object.freeze({
492
- default: isSymbol_1,
493
- __moduleExports: isSymbol_1
494
- });
495
-
496
- var isSymbol$2 = ( isSymbol$1 && isSymbol_1 ) || isSymbol$1;
497
-
498
477
  /** Used as references for various `Number` constants. */
499
478
  var NAN = 0 / 0;
500
479
 
@@ -540,7 +519,7 @@ var DataTable = (function (Sortable) {
540
519
  if (typeof value == 'number') {
541
520
  return value;
542
521
  }
543
- if (isSymbol$2(value)) {
522
+ if (isSymbol_1(value)) {
544
523
  return NAN;
545
524
  }
546
525
  if (isObject_1(value)) {
@@ -849,13 +828,20 @@ var DataTable = (function (Sortable) {
849
828
  var isFunction_1 = isFunction;
850
829
 
851
830
  /** Used to detect overreaching core-js shims. */
852
- var coreJsData = root$1['__core-js_shared__'];
831
+ var coreJsData = _root['__core-js_shared__'];
853
832
 
854
833
  var _coreJsData = coreJsData;
855
834
 
835
+ var _coreJsData$1 = /*#__PURE__*/Object.freeze({
836
+ default: _coreJsData,
837
+ __moduleExports: _coreJsData
838
+ });
839
+
840
+ var coreJsData$1 = ( _coreJsData$1 && _coreJsData ) || _coreJsData$1;
841
+
856
842
  /** Used to detect methods masquerading as native. */
857
843
  var maskSrcKey = (function() {
858
- var uid = /[^.]+$/.exec(_coreJsData && _coreJsData.keys && _coreJsData.keys.IE_PROTO || '');
844
+ var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || '');
859
845
  return uid ? ('Symbol(src)_1.' + uid) : '';
860
846
  }());
861
847
 
@@ -942,11 +928,6 @@ var DataTable = (function (Sortable) {
942
928
 
943
929
  var _baseIsNative = baseIsNative;
944
930
 
945
- var _baseIsNative$1 = /*#__PURE__*/Object.freeze({
946
- default: _baseIsNative,
947
- __moduleExports: _baseIsNative
948
- });
949
-
950
931
  /**
951
932
  * Gets the value at `key` of `object`.
952
933
  *
@@ -961,8 +942,6 @@ var DataTable = (function (Sortable) {
961
942
 
962
943
  var _getValue = getValue;
963
944
 
964
- var baseIsNative$1 = ( _baseIsNative$1 && _baseIsNative ) || _baseIsNative$1;
965
-
966
945
  /**
967
946
  * Gets the native function at `key` of `object`.
968
947
  *
@@ -973,7 +952,7 @@ var DataTable = (function (Sortable) {
973
952
  */
974
953
  function getNative(object, key) {
975
954
  var value = _getValue(object, key);
976
- return baseIsNative$1(value) ? value : undefined;
955
+ return _baseIsNative(value) ? value : undefined;
977
956
  }
978
957
 
979
958
  var _getNative = getNative;
@@ -1129,6 +1108,11 @@ var DataTable = (function (Sortable) {
1129
1108
 
1130
1109
  var _listCacheClear = listCacheClear;
1131
1110
 
1111
+ var _listCacheClear$1 = /*#__PURE__*/Object.freeze({
1112
+ default: _listCacheClear,
1113
+ __moduleExports: _listCacheClear
1114
+ });
1115
+
1132
1116
  /**
1133
1117
  * Performs a
1134
1118
  * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
@@ -1187,6 +1171,13 @@ var DataTable = (function (Sortable) {
1187
1171
 
1188
1172
  var _assocIndexOf = assocIndexOf;
1189
1173
 
1174
+ var _assocIndexOf$1 = /*#__PURE__*/Object.freeze({
1175
+ default: _assocIndexOf,
1176
+ __moduleExports: _assocIndexOf
1177
+ });
1178
+
1179
+ var assocIndexOf$1 = ( _assocIndexOf$1 && _assocIndexOf ) || _assocIndexOf$1;
1180
+
1190
1181
  /** Used for built-in method references. */
1191
1182
  var arrayProto = Array.prototype;
1192
1183
 
@@ -1204,7 +1195,7 @@ var DataTable = (function (Sortable) {
1204
1195
  */
1205
1196
  function listCacheDelete(key) {
1206
1197
  var data = this.__data__,
1207
- index = _assocIndexOf(data, key);
1198
+ index = assocIndexOf$1(data, key);
1208
1199
 
1209
1200
  if (index < 0) {
1210
1201
  return false;
@@ -1232,7 +1223,7 @@ var DataTable = (function (Sortable) {
1232
1223
  */
1233
1224
  function listCacheGet(key) {
1234
1225
  var data = this.__data__,
1235
- index = _assocIndexOf(data, key);
1226
+ index = assocIndexOf$1(data, key);
1236
1227
 
1237
1228
  return index < 0 ? undefined : data[index][1];
1238
1229
  }
@@ -1249,7 +1240,7 @@ var DataTable = (function (Sortable) {
1249
1240
  * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1250
1241
  */
1251
1242
  function listCacheHas(key) {
1252
- return _assocIndexOf(this.__data__, key) > -1;
1243
+ return assocIndexOf$1(this.__data__, key) > -1;
1253
1244
  }
1254
1245
 
1255
1246
  var _listCacheHas = listCacheHas;
@@ -1266,7 +1257,7 @@ var DataTable = (function (Sortable) {
1266
1257
  */
1267
1258
  function listCacheSet(key, value) {
1268
1259
  var data = this.__data__,
1269
- index = _assocIndexOf(data, key);
1260
+ index = assocIndexOf$1(data, key);
1270
1261
 
1271
1262
  if (index < 0) {
1272
1263
  ++this.size;
@@ -1279,6 +1270,8 @@ var DataTable = (function (Sortable) {
1279
1270
 
1280
1271
  var _listCacheSet = listCacheSet;
1281
1272
 
1273
+ var listCacheClear$1 = ( _listCacheClear$1 && _listCacheClear ) || _listCacheClear$1;
1274
+
1282
1275
  /**
1283
1276
  * Creates an list cache object.
1284
1277
  *
@@ -1298,7 +1291,7 @@ var DataTable = (function (Sortable) {
1298
1291
  }
1299
1292
 
1300
1293
  // Add methods to `ListCache`.
1301
- ListCache.prototype.clear = _listCacheClear;
1294
+ ListCache.prototype.clear = listCacheClear$1;
1302
1295
  ListCache.prototype['delete'] = _listCacheDelete;
1303
1296
  ListCache.prototype.get = _listCacheGet;
1304
1297
  ListCache.prototype.has = _listCacheHas;
@@ -1306,17 +1299,17 @@ var DataTable = (function (Sortable) {
1306
1299
 
1307
1300
  var _ListCache = ListCache;
1308
1301
 
1302
+ var _ListCache$1 = /*#__PURE__*/Object.freeze({
1303
+ default: _ListCache,
1304
+ __moduleExports: _ListCache
1305
+ });
1306
+
1309
1307
  /* Built-in method references that are verified to be native. */
1310
- var Map = _getNative(root$1, 'Map');
1308
+ var Map = _getNative(_root, 'Map');
1311
1309
 
1312
1310
  var _Map = Map;
1313
1311
 
1314
- var _Map$1 = /*#__PURE__*/Object.freeze({
1315
- default: _Map,
1316
- __moduleExports: _Map
1317
- });
1318
-
1319
- var Map$1 = ( _Map$1 && _Map ) || _Map$1;
1312
+ var ListCache$1 = ( _ListCache$1 && _ListCache ) || _ListCache$1;
1320
1313
 
1321
1314
  /**
1322
1315
  * Removes all key-value entries from the map.
@@ -1329,7 +1322,7 @@ var DataTable = (function (Sortable) {
1329
1322
  this.size = 0;
1330
1323
  this.__data__ = {
1331
1324
  'hash': new _Hash,
1332
- 'map': new (Map$1 || _ListCache),
1325
+ 'map': new (_Map || ListCache$1),
1333
1326
  'string': new _Hash
1334
1327
  };
1335
1328
  }
@@ -1352,6 +1345,13 @@ var DataTable = (function (Sortable) {
1352
1345
 
1353
1346
  var _isKeyable = isKeyable;
1354
1347
 
1348
+ var _isKeyable$1 = /*#__PURE__*/Object.freeze({
1349
+ default: _isKeyable,
1350
+ __moduleExports: _isKeyable
1351
+ });
1352
+
1353
+ var isKeyable$1 = ( _isKeyable$1 && _isKeyable ) || _isKeyable$1;
1354
+
1355
1355
  /**
1356
1356
  * Gets the data for `map`.
1357
1357
  *
@@ -1362,7 +1362,7 @@ var DataTable = (function (Sortable) {
1362
1362
  */
1363
1363
  function getMapData(map, key) {
1364
1364
  var data = map.__data__;
1365
- return _isKeyable(key)
1365
+ return isKeyable$1(key)
1366
1366
  ? data[typeof key == 'string' ? 'string' : 'hash']
1367
1367
  : data.map;
1368
1368
  }
@@ -1484,6 +1484,11 @@ var DataTable = (function (Sortable) {
1484
1484
 
1485
1485
  var _setCacheAdd = setCacheAdd;
1486
1486
 
1487
+ var _setCacheAdd$1 = /*#__PURE__*/Object.freeze({
1488
+ default: _setCacheAdd,
1489
+ __moduleExports: _setCacheAdd
1490
+ });
1491
+
1487
1492
  /**
1488
1493
  * Checks if `value` is in the array cache.
1489
1494
  *
@@ -1499,6 +1504,8 @@ var DataTable = (function (Sortable) {
1499
1504
 
1500
1505
  var _setCacheHas = setCacheHas;
1501
1506
 
1507
+ var setCacheAdd$1 = ( _setCacheAdd$1 && _setCacheAdd ) || _setCacheAdd$1;
1508
+
1502
1509
  /**
1503
1510
  *
1504
1511
  * Creates an array cache object to store unique values.
@@ -1518,7 +1525,7 @@ var DataTable = (function (Sortable) {
1518
1525
  }
1519
1526
 
1520
1527
  // Add methods to `SetCache`.
1521
- SetCache.prototype.add = SetCache.prototype.push = _setCacheAdd;
1528
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd$1;
1522
1529
  SetCache.prototype.has = _setCacheHas;
1523
1530
 
1524
1531
  var _SetCache = SetCache;
@@ -1585,13 +1592,6 @@ var DataTable = (function (Sortable) {
1585
1592
 
1586
1593
  var _strictIndexOf = strictIndexOf;
1587
1594
 
1588
- var _strictIndexOf$1 = /*#__PURE__*/Object.freeze({
1589
- default: _strictIndexOf,
1590
- __moduleExports: _strictIndexOf
1591
- });
1592
-
1593
- var strictIndexOf$1 = ( _strictIndexOf$1 && _strictIndexOf ) || _strictIndexOf$1;
1594
-
1595
1595
  /**
1596
1596
  * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
1597
1597
  *
@@ -1603,7 +1603,7 @@ var DataTable = (function (Sortable) {
1603
1603
  */
1604
1604
  function baseIndexOf(array, value, fromIndex) {
1605
1605
  return value === value
1606
- ? strictIndexOf$1(array, value, fromIndex)
1606
+ ? _strictIndexOf(array, value, fromIndex)
1607
1607
  : _baseFindIndex(array, _baseIsNaN, fromIndex);
1608
1608
  }
1609
1609
 
@@ -1663,7 +1663,7 @@ var DataTable = (function (Sortable) {
1663
1663
  var _cacheHas = cacheHas;
1664
1664
 
1665
1665
  /* Built-in method references that are verified to be native. */
1666
- var Set$1 = _getNative(root$1, 'Set');
1666
+ var Set$1 = _getNative(_root, 'Set');
1667
1667
 
1668
1668
  var _Set = Set$1;
1669
1669
 
@@ -1786,13 +1786,6 @@ var DataTable = (function (Sortable) {
1786
1786
 
1787
1787
  var _baseUniq = baseUniq;
1788
1788
 
1789
- var _baseUniq$1 = /*#__PURE__*/Object.freeze({
1790
- default: _baseUniq,
1791
- __moduleExports: _baseUniq
1792
- });
1793
-
1794
- var baseUniq$1 = ( _baseUniq$1 && _baseUniq ) || _baseUniq$1;
1795
-
1796
1789
  /**
1797
1790
  * Creates a duplicate-free version of an array, using
1798
1791
  * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
@@ -1812,7 +1805,7 @@ var DataTable = (function (Sortable) {
1812
1805
  * // => [2, 1]
1813
1806
  */
1814
1807
  function uniq(array) {
1815
- return (array && array.length) ? baseUniq$1(array) : [];
1808
+ return (array && array.length) ? _baseUniq(array) : [];
1816
1809
  }
1817
1810
 
1818
1811
  var uniq_1 = uniq;
@@ -2033,6 +2026,7 @@ var DataTable = (function (Sortable) {
2033
2026
  sortable: false,
2034
2027
  focusable: false,
2035
2028
  dropdown: false,
2029
+ sticky: true,
2036
2030
  width: 32
2037
2031
  };
2038
2032
  this.columns.push(cell);
@@ -2041,16 +2035,14 @@ var DataTable = (function (Sortable) {
2041
2035
  if (this.options.serialNoColumn && !this.hasColumnById('_rowIndex')) {
2042
2036
  let cell = {
2043
2037
  id: '_rowIndex',
2044
- content: '',
2038
+ content: this.options.serialNoColumnLabel || '',
2045
2039
  align: 'center',
2046
2040
  editable: false,
2047
- resizable: false,
2041
+ resizable: true,
2048
2042
  focusable: false,
2049
- dropdown: false
2043
+ dropdown: false,
2044
+ sticky: true
2050
2045
  };
2051
- if (this.options.data.length > 1000) {
2052
- cell.resizable = true;
2053
- }
2054
2046
  this.columns.push(cell);
2055
2047
  }
2056
2048
  }
@@ -2255,14 +2247,18 @@ var DataTable = (function (Sortable) {
2255
2247
  }
2256
2248
  }
2257
2249
 
2250
+ const sortValue = cell => {
2251
+ const hook = cell.column && cell.column.sortValue;
2252
+ const value = hook ? hook(cell) : cell.content;
2253
+ return value == null ? '' : value;
2254
+ };
2255
+
2258
2256
  this.rowViewOrder.sort((a, b) => {
2259
2257
  const aIndex = a;
2260
2258
  const bIndex = b;
2261
2259
 
2262
- let aContent = this.getCell(colIndex, a).content;
2263
- let bContent = this.getCell(colIndex, b).content;
2264
- aContent = aContent == null ? '' : aContent;
2265
- bContent = bContent == null ? '' : bContent;
2260
+ const aContent = sortValue(this.getCell(colIndex, a));
2261
+ const bContent = sortValue(this.getCell(colIndex, b));
2266
2262
 
2267
2263
  if (sortOrder === 'none') {
2268
2264
  return aIndex - bIndex;
@@ -2634,6 +2630,7 @@ var DataTable = (function (Sortable) {
2634
2630
  this.bindKeyboardSelection();
2635
2631
  this.bindCopyCellContents();
2636
2632
  this.bindMouseEvents();
2633
+ this.bindWheelEvents();
2637
2634
  this.bindTreeEvents();
2638
2635
  }
2639
2636
 
@@ -2682,6 +2679,7 @@ var DataTable = (function (Sortable) {
2682
2679
  }
2683
2680
 
2684
2681
  this.focusCell($cell);
2682
+ sessionStorage.setItem('dt-last-nav-method', 'key');
2685
2683
  return true;
2686
2684
  };
2687
2685
 
@@ -2790,6 +2788,12 @@ var DataTable = (function (Sortable) {
2790
2788
  $.on(this.bodyScrollable, 'mousemove', '.dt-cell', throttle$1(selectArea, 50));
2791
2789
  }
2792
2790
 
2791
+ bindWheelEvents() {
2792
+ $.on(this.bodyScrollable, 'wheel', (e) => {
2793
+ sessionStorage.setItem('dt-last-nav-method', 'scroll');
2794
+ });
2795
+ }
2796
+
2793
2797
  bindTreeEvents() {
2794
2798
  $.on(this.bodyScrollable, 'click', '.dt-tree-node__toggle', (e, $toggle) => {
2795
2799
  const $cell = $.closest('.dt-cell', $toggle);
@@ -2914,11 +2918,13 @@ var DataTable = (function (Sortable) {
2914
2918
  // this function is called after hyperlist renders the rows after scroll,
2915
2919
  // focusCell calls clearSelection which resets the area selection
2916
2920
  // so a flag to skip it
2917
- // we also skip DOM focus and scroll to cell
2918
- // because it fights with the user scroll
2921
+ // we skip scroll to cell
2922
+ // and also skip DOM focus (if user is scrolling) because it fights with the user scroll
2923
+ const skipDOMFocus = sessionStorage.getItem('dt-last-nav-method') !== 'key';
2924
+
2919
2925
  this.focusCell($cell, {
2926
+ skipDOMFocus,
2920
2927
  skipClearSelection: 1,
2921
- skipDOMFocus: 1,
2922
2928
  skipScrollToCell: 1
2923
2929
  });
2924
2930
  }
@@ -3315,6 +3321,7 @@ var DataTable = (function (Sortable) {
3315
3321
  }
3316
3322
 
3317
3323
  this.focusCell($cell);
3324
+ sessionStorage.setItem('dt-last-nav-method', 'key');
3318
3325
  return true;
3319
3326
  }
3320
3327
 
@@ -3413,8 +3420,15 @@ var DataTable = (function (Sortable) {
3413
3420
  });
3414
3421
 
3415
3422
  const row = this.datamanager.getRow(rowIndex);
3423
+ const column = cell.column || this.datamanager.getColumn(colIndex) || {};
3416
3424
 
3417
3425
  const isBodyCell = !(isHeader || isFilter || isTotalRow);
3426
+ const isSticky = Boolean(column.sticky);
3427
+ const stickyColumns = this.datamanager.getColumns().filter(col => col.sticky);
3428
+ const lastStickyColumn = stickyColumns[stickyColumns.length - 1];
3429
+ const isLastStickyColumn = isSticky &&
3430
+ lastStickyColumn &&
3431
+ lastStickyColumn.colIndex === colIndex;
3418
3432
 
3419
3433
  const className = [
3420
3434
  'dt-cell',
@@ -3424,7 +3438,10 @@ var DataTable = (function (Sortable) {
3424
3438
  isHeader ? 'dt-cell--header' : '',
3425
3439
  isHeader ? `dt-cell--header-${colIndex}` : '',
3426
3440
  isFilter ? 'dt-cell--filter' : '',
3427
- isBodyCell && (row && row.meta.isTreeNodeClose) ? 'dt-cell--tree-close' : ''
3441
+ isBodyCell && (row && row.meta.isTreeNodeClose) ? 'dt-cell--tree-close' : '',
3442
+ isSticky ? 'dt-cell--sticky' : '',
3443
+ isSticky && !isBodyCell ? 'dt-cell--sticky-top' : '',
3444
+ isLastStickyColumn ? 'dt-cell--sticky-last' : ''
3428
3445
  ].join(' ');
3429
3446
 
3430
3447
  return `
@@ -3622,7 +3639,7 @@ var DataTable = (function (Sortable) {
3622
3639
  });
3623
3640
 
3624
3641
  $.on(this.$dropdownList, 'click', '.dt-dropdown__list-item', (e, $item) => {
3625
- if (!this._dropdownActiveColIndex) return;
3642
+ if (this._dropdownActiveColIndex == null) return;
3626
3643
  const dropdownItems = this.options.headerDropdown;
3627
3644
  const { index } = $.data($item);
3628
3645
  const colIndex = this._dropdownActiveColIndex;
@@ -3637,6 +3654,11 @@ var DataTable = (function (Sortable) {
3637
3654
  _this.hideDropdown();
3638
3655
  }
3639
3656
 
3657
+ this.stickDropdownIndex = this.options.headerDropdown
3658
+ .findIndex(item => item.stickyAction === 'stick');
3659
+ this.unstickDropdownIndex = this.options.headerDropdown
3660
+ .findIndex(item => item.stickyAction === 'unstick');
3661
+
3640
3662
  this.hideDropdown();
3641
3663
  }
3642
3664
 
@@ -3653,6 +3675,7 @@ var DataTable = (function (Sortable) {
3653
3675
  const $cell = $.closest('.dt-cell', e.target);
3654
3676
  const { colIndex } = $.data($cell);
3655
3677
  this._dropdownActiveColIndex = colIndex;
3678
+ this.updateStickyDropdownItems(this.getColumn(colIndex));
3656
3679
  }
3657
3680
 
3658
3681
  hideDropdown() {
@@ -3688,12 +3711,6 @@ var DataTable = (function (Sortable) {
3688
3711
  document.body.classList.remove('dt-resize');
3689
3712
  if (!$resizingCell) return;
3690
3713
  isDragging = false;
3691
-
3692
- const {
3693
- colIndex
3694
- } = $.data($resizingCell);
3695
- this.setColumnWidth(colIndex);
3696
- this.style.setBodyStyle();
3697
3714
  $resizingCell = null;
3698
3715
  };
3699
3716
  $.on(document.body, 'mouseup', onMouseup);
@@ -3721,6 +3738,9 @@ var DataTable = (function (Sortable) {
3721
3738
  width: finalWidth
3722
3739
  });
3723
3740
  this.setColumnHeaderWidth(colIndex);
3741
+ this.setColumnWidth(colIndex);
3742
+ this.style.refreshStickyColumns();
3743
+ this.style.setBodyStyle();
3724
3744
  };
3725
3745
  $.on(document.body, 'mousemove', onMouseMove);
3726
3746
  this.instance.on('onDestroy', () => {
@@ -3757,6 +3777,7 @@ var DataTable = (function (Sortable) {
3757
3777
  this.datamanager.updateColumn(colIndex, { width });
3758
3778
  this.setColumnHeaderWidth(colIndex);
3759
3779
  this.setColumnWidth(colIndex);
3780
+ this.style.refreshStickyColumns();
3760
3781
  });
3761
3782
  }
3762
3783
 
@@ -3833,6 +3854,20 @@ var DataTable = (function (Sortable) {
3833
3854
  });
3834
3855
  }
3835
3856
 
3857
+ setColumnSticky(colIndex, sticky) {
3858
+ const column = this.getColumn(colIndex);
3859
+ if (!column || column.sticky === sticky) {
3860
+ return;
3861
+ }
3862
+
3863
+ this.instance.freeze();
3864
+ this.datamanager.updateColumn(colIndex, { sticky });
3865
+
3866
+ this.refreshHeader();
3867
+ this.rowmanager.refreshRows()
3868
+ .then(() => this.instance.unfreeze());
3869
+ }
3870
+
3836
3871
  switchColumn(oldIndex, newIndex) {
3837
3872
  this.instance.freeze();
3838
3873
  this.datamanager.switchColumn(oldIndex, newIndex)
@@ -4022,6 +4057,23 @@ var DataTable = (function (Sortable) {
4022
4057
  toggleDropdownItem(index) {
4023
4058
  $('.dt-dropdown__list', this.instance.dropdownContainer).children[index].classList.toggle('dt-hidden');
4024
4059
  }
4060
+
4061
+ updateStickyDropdownItems(column) {
4062
+ if (!column) return;
4063
+ if (this.stickDropdownIndex === -1 || this.unstickDropdownIndex === -1) return;
4064
+
4065
+ const stickItem = this.$dropdownList.children[this.stickDropdownIndex];
4066
+ const unstickItem = this.$dropdownList.children[this.unstickDropdownIndex];
4067
+ if (!(stickItem && unstickItem)) return;
4068
+
4069
+ if (column.sticky) {
4070
+ stickItem.classList.add('dt-hidden');
4071
+ unstickItem.classList.remove('dt-hidden');
4072
+ } else {
4073
+ stickItem.classList.remove('dt-hidden');
4074
+ unstickItem.classList.add('dt-hidden');
4075
+ }
4076
+ }
4025
4077
  }
4026
4078
 
4027
4079
  class RowManager {
@@ -4889,12 +4941,26 @@ var DataTable = (function (Sortable) {
4889
4941
  }
4890
4942
 
4891
4943
  render() {
4892
- const rows = this.datamanager.getRowsForView();
4944
+ const rows = this.getRowsToRender();
4893
4945
  this.renderRows(rows);
4894
4946
  // setDimensions requires atleast 1 row to exist in dom
4895
4947
  this.instance.setDimensions();
4896
4948
  }
4897
4949
 
4950
+ // Keep the current tree expand/collapse state on a full re-render
4951
+ getRowsToRender() {
4952
+ const rows = this.datamanager.getRowsForView();
4953
+ let closedIndent = null;
4954
+ return rows.filter(row => {
4955
+ const { indent, isTreeNodeClose } = row.meta;
4956
+ if (closedIndent !== null && indent > closedIndent) {
4957
+ return false;
4958
+ }
4959
+ closedIndent = isTreeNodeClose ? indent : null;
4960
+ return true;
4961
+ });
4962
+ }
4963
+
4898
4964
  renderFooter() {
4899
4965
  if (!this.options.showTotalRow) return;
4900
4966
 
@@ -5024,6 +5090,7 @@ var DataTable = (function (Sortable) {
5024
5090
 
5025
5091
  bindScrollHeader() {
5026
5092
  this._settingHeaderPosition = false;
5093
+ this.updateStickyTopPositions(0);
5027
5094
 
5028
5095
  $.on(this.bodyScrollable, 'scroll', (e) => {
5029
5096
  if (this._settingHeaderPosition) return;
@@ -5031,7 +5098,8 @@ var DataTable = (function (Sortable) {
5031
5098
  this._settingHeaderPosition = true;
5032
5099
 
5033
5100
  requestAnimationFrame(() => {
5034
- const left = -e.target.scrollLeft;
5101
+ const scrollLeft = e.target.scrollLeft;
5102
+ const left = -scrollLeft;
5035
5103
 
5036
5104
  $.style(this.header, {
5037
5105
  transform: `translateX(${left}px)`
@@ -5039,6 +5107,7 @@ var DataTable = (function (Sortable) {
5039
5107
  $.style(this.footer, {
5040
5108
  transform: `translateX(${left}px)`
5041
5109
  });
5110
+ this.updateStickyTopPositions(scrollLeft);
5042
5111
  this._settingHeaderPosition = false;
5043
5112
  if (this.instance.noData) {
5044
5113
  $.style($('.no-data-message'), {
@@ -5136,6 +5205,7 @@ var DataTable = (function (Sortable) {
5136
5205
  this.setupColumnWidth();
5137
5206
  this.distributeRemainingWidth();
5138
5207
  this.setColumnStyle();
5208
+ this.refreshStickyColumns();
5139
5209
  this.setBodyStyle();
5140
5210
  }
5141
5211
 
@@ -5293,6 +5363,12 @@ var DataTable = (function (Sortable) {
5293
5363
  this.columnmanager.setColumnHeaderWidth(column.colIndex);
5294
5364
  this.columnmanager.setColumnWidth(column.colIndex);
5295
5365
  });
5366
+ this.refreshStickyColumns();
5367
+ }
5368
+
5369
+ refreshStickyColumns() {
5370
+ this.setStickyColumnStyle();
5371
+ this.updateStickyTopPositions(this.bodyScrollable.scrollLeft || 0);
5296
5372
  }
5297
5373
 
5298
5374
  setBodyStyle() {
@@ -5354,6 +5430,59 @@ var DataTable = (function (Sortable) {
5354
5430
  return $(`.dt-cell--col-${colIndex}`, this.header);
5355
5431
  }
5356
5432
 
5433
+ setStickyColumnStyle() {
5434
+ if (!this.datamanager || !this.datamanager.getColumns) return;
5435
+
5436
+ const columns = this.datamanager.getColumns();
5437
+ if (!columns.some(column => column.sticky) && !(this._stickySelectors || []).length) return;
5438
+
5439
+ const stickySelectors = [];
5440
+ let stickyOffset = 0;
5441
+ let normalOffset = 0;
5442
+
5443
+ columns.forEach((column) => {
5444
+ const $headerCell = this.getColumnHeaderElement(column.colIndex);
5445
+ const renderedWidth = $headerCell ? $headerCell.offsetWidth : column.width;
5446
+
5447
+ if (column.sticky) {
5448
+ const selector = `.dt-cell--col-${column.colIndex}.dt-cell--sticky`;
5449
+ const style = {
5450
+ left: `${stickyOffset}px`
5451
+ };
5452
+
5453
+ column.stickyLeft = stickyOffset;
5454
+ column.stickyScrollTrigger = normalOffset - stickyOffset;
5455
+ column.renderedWidth = renderedWidth;
5456
+ this.setStyle(selector, style);
5457
+ stickySelectors.push(selector);
5458
+ stickyOffset += renderedWidth;
5459
+ }
5460
+ normalOffset += renderedWidth;
5461
+ });
5462
+
5463
+ const staleSelectors = (this._stickySelectors || [])
5464
+ .filter(selector => !stickySelectors.includes(selector));
5465
+
5466
+ staleSelectors.forEach(selector => this.removeStyle(selector));
5467
+ this._stickySelectors = stickySelectors;
5468
+ }
5469
+
5470
+ updateStickyTopPositions(scrollLeft) {
5471
+ if (!this.datamanager || !this.datamanager.getColumns) return;
5472
+
5473
+ const stickyColumns = this.datamanager.getColumns().filter(column => column.sticky);
5474
+
5475
+ stickyColumns.forEach((column) => {
5476
+ const trigger = Math.max(0, column.stickyScrollTrigger || 0);
5477
+ const compensation = Math.max(0, scrollLeft - trigger);
5478
+ const cells = $.each(`.dt-cell--col-${column.colIndex}.dt-cell--sticky-top`, this.wrapper) || [];
5479
+
5480
+ $.style(cells, {
5481
+ transform: compensation ? `translateX(${compensation}px)` : ''
5482
+ });
5483
+ });
5484
+ }
5485
+
5357
5486
  getRowIndexColumnWidth() {
5358
5487
  const rowCount = this.datamanager.getRowCount();
5359
5488
  const padding = 22;
@@ -5417,7 +5546,11 @@ var DataTable = (function (Sortable) {
5417
5546
  }
5418
5547
  }
5419
5548
 
5549
+ var Freeze = "Freeze";
5550
+ var Unfreeze = "Unfreeze";
5420
5551
  var en = {
5552
+ Freeze: Freeze,
5553
+ Unfreeze: Unfreeze,
5421
5554
  "Sort Ascending": "Sort Ascending",
5422
5555
  "Sort Descending": "Sort Descending",
5423
5556
  "Reset sorting": "Reset sorting",
@@ -5427,7 +5560,11 @@ var DataTable = (function (Sortable) {
5427
5560
  "{count} rows selected": {"1":"{count} row selected","default":"{count} rows selected"}
5428
5561
  };
5429
5562
 
5563
+ var Freeze$1 = "Bevriezen";
5564
+ var Unfreeze$1 = "Ontdooien";
5430
5565
  var de = {
5566
+ Freeze: Freeze$1,
5567
+ Unfreeze: Unfreeze$1,
5431
5568
  "Sort Ascending": "Aufsteigend sortieren",
5432
5569
  "Sort Descending": "Absteigend sortieren",
5433
5570
  "Reset sorting": "Sortierung zurücksetzen",
@@ -5437,7 +5574,11 @@ var DataTable = (function (Sortable) {
5437
5574
  "{count} rows selected": {"1":"{count} Zeile ausgewählt","default":"{count} Zeilen ausgewählt"}
5438
5575
  };
5439
5576
 
5577
+ var Freeze$2 = "Geler";
5578
+ var Unfreeze$2 = "Dégeler";
5440
5579
  var fr = {
5580
+ Freeze: Freeze$2,
5581
+ Unfreeze: Unfreeze$2,
5441
5582
  "Sort Ascending": "Trier par ordre croissant",
5442
5583
  "Sort Descending": "Trier par ordre décroissant",
5443
5584
  "Reset sorting": "Réinitialiser le tri",
@@ -5447,7 +5588,11 @@ var DataTable = (function (Sortable) {
5447
5588
  "{count} rows selected": {"1":"{count} ligne sélectionnée","default":"{count} lignes sélectionnées"}
5448
5589
  };
5449
5590
 
5591
+ var Freeze$3 = "Congelare";
5592
+ var Unfreeze$3 = "Dégeler";
5450
5593
  var it = {
5594
+ Freeze: Freeze$3,
5595
+ Unfreeze: Unfreeze$3,
5451
5596
  "Sort Ascending": "Ordinamento ascendente",
5452
5597
  "Sort Descending": "Ordinamento decrescente",
5453
5598
  "Reset sorting": "Azzeramento ordinamento",
@@ -5729,6 +5874,22 @@ var DataTable = (function (Sortable) {
5729
5874
  action: function (column) {
5730
5875
  this.removeColumn(column.colIndex);
5731
5876
  }
5877
+ },
5878
+ {
5879
+ label: instance.translate('Freeze'),
5880
+ stickyAction: 'stick',
5881
+ display: 'hidden',
5882
+ action: function (column) {
5883
+ this.setColumnSticky(column.colIndex, true);
5884
+ }
5885
+ },
5886
+ {
5887
+ label: instance.translate('Unfreeze'),
5888
+ stickyAction: 'unstick',
5889
+ display: 'hidden',
5890
+ action: function (column) {
5891
+ this.setColumnSticky(column.colIndex, false);
5892
+ }
5732
5893
  }
5733
5894
  ],
5734
5895
  events: {
@@ -5753,6 +5914,7 @@ var DataTable = (function (Sortable) {
5753
5914
  freezeMessage: '',
5754
5915
  getEditor: null,
5755
5916
  serialNoColumn: true,
5917
+ serialNoColumnLabel: '',
5756
5918
  checkboxColumn: false,
5757
5919
  clusterize: true,
5758
5920
  logs: false,
@@ -5984,6 +6146,10 @@ var DataTable = (function (Sortable) {
5984
6146
  this.columnmanager.removeColumn(colIndex);
5985
6147
  }
5986
6148
 
6149
+ setColumnSticky(colIndex, sticky) {
6150
+ this.columnmanager.setColumnSticky(colIndex, sticky);
6151
+ }
6152
+
5987
6153
  scrollToLastColumn() {
5988
6154
  this.datatableWrapper.scrollLeft = 9999;
5989
6155
  }
@@ -6063,7 +6229,7 @@ var DataTable = (function (Sortable) {
6063
6229
  var jsdelivr = "dist/melondtable.min.js";
6064
6230
  var scripts = {"start":"yarn run dev","build":"rollup -c && NODE_ENV=production rollup -c","dev":"rollup -c -w","cy:server":"http-server -p 8989","cy:open":"cypress open","cy:run":"cypress run","test":"start-server-and-test cy:server http://localhost:8989 cy:run","test-local":"start-server-and-test cy:server http://localhost:8989 cy:open","travis-deploy-once":"travis-deploy-once","semantic-release":"semantic-release","lint":"eslint src","lint-and-build":"yarn lint && yarn build","commit":"npx git-cz"};
6065
6231
  var files = ["dist","src"];
6066
- var devDependencies = {"autoprefixer":"^9.0.0","chai":"3.5.0","cypress":"^9.2.0","cz-conventional-changelog":"^2.1.0","deepmerge":"^2.0.1","eslint":"^5.0.1","eslint-config-airbnb":"^16.1.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.11.0","http-server":"^0.11.1","mocha":"3.3.0","postcss-custom-properties":"^7.0.0","postcss-nested":"^3.0.0","rollup":"^0.59.4","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-eslint":"^4.0.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify-es":"^0.0.1","semantic-release":"^17.1.1","start-server-and-test":"^1.4.1","travis-deploy-once":"^5.0.1"};
6232
+ var devDependencies = {"autoprefixer":"^9.0.0","chai":"3.5.0","cypress":"^9.2.0","cz-conventional-changelog":"^2.1.0","deepmerge":"^2.0.1","eslint":"^5.0.1","eslint-config-airbnb":"^16.1.0","eslint-config-airbnb-base":"^12.1.0","eslint-plugin-import":"^2.11.0","http-server":"^0.11.1","mocha":"3.3.0","postcss-custom-properties":"^7.0.0","postcss-nested":"^3.0.0","rollup":"^0.59.4","rollup-plugin-commonjs":"^8.3.0","rollup-plugin-eslint":"^4.0.0","rollup-plugin-json":"^2.3.0","rollup-plugin-node-resolve":"^3.0.3","rollup-plugin-postcss":"^1.2.8","rollup-plugin-uglify-es":"^0.0.1","semantic-release":"^25.0.3","start-server-and-test":"^1.4.1","travis-deploy-once":"^5.0.1"};
6067
6233
  var repository = {"type":"git","url":"https://github.com/amonak/melondtable.git"};
6068
6234
  var keywords = ["datatable","data","grid","table"];
6069
6235
  var author = "Alphamonak Solutions";