melondtable 1.19.0 → 1.20.7

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.
@@ -290,21 +290,21 @@ var DataTable = (function (Sortable) {
290
290
 
291
291
  var _freeGlobal = freeGlobal;
292
292
 
293
+ var _freeGlobal$1 = /*#__PURE__*/Object.freeze({
294
+ default: _freeGlobal,
295
+ __moduleExports: _freeGlobal
296
+ });
297
+
298
+ var freeGlobal$1 = ( _freeGlobal$1 && _freeGlobal ) || _freeGlobal$1;
299
+
293
300
  /** Detect free variable `self`. */
294
301
  var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
295
302
 
296
303
  /** Used as a reference to the global object. */
297
- var root = _freeGlobal || freeSelf || Function('return this')();
304
+ var root = freeGlobal$1 || freeSelf || Function('return this')();
298
305
 
299
306
  var _root = root;
300
307
 
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
308
  /**
309
309
  * Gets the timestamp of the number of milliseconds that have elapsed since
310
310
  * the Unix epoch (1 January 1970 00:00:00 UTC).
@@ -322,13 +322,13 @@ var DataTable = (function (Sortable) {
322
322
  * // => Logs the number of milliseconds it took for the deferred invocation.
323
323
  */
324
324
  var now = function() {
325
- return root$1.Date.now();
325
+ return _root.Date.now();
326
326
  };
327
327
 
328
328
  var now_1 = now;
329
329
 
330
330
  /** Built-in value references. */
331
- var Symbol = root$1.Symbol;
331
+ var Symbol = _root.Symbol;
332
332
 
333
333
  var _Symbol = Symbol;
334
334
 
@@ -461,6 +461,13 @@ var DataTable = (function (Sortable) {
461
461
 
462
462
  var isObjectLike_1 = isObjectLike;
463
463
 
464
+ var isObjectLike$1 = /*#__PURE__*/Object.freeze({
465
+ default: isObjectLike_1,
466
+ __moduleExports: isObjectLike_1
467
+ });
468
+
469
+ var isObjectLike$2 = ( isObjectLike$1 && isObjectLike_1 ) || isObjectLike$1;
470
+
464
471
  /** `Object#toString` result references. */
465
472
  var symbolTag = '[object Symbol]';
466
473
 
@@ -483,18 +490,11 @@ var DataTable = (function (Sortable) {
483
490
  */
484
491
  function isSymbol(value) {
485
492
  return typeof value == 'symbol' ||
486
- (isObjectLike_1(value) && _baseGetTag(value) == symbolTag);
493
+ (isObjectLike$2(value) && _baseGetTag(value) == symbolTag);
487
494
  }
488
495
 
489
496
  var isSymbol_1 = isSymbol;
490
497
 
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
498
  /** Used as references for various `Number` constants. */
499
499
  var NAN = 0 / 0;
500
500
 
@@ -540,7 +540,7 @@ var DataTable = (function (Sortable) {
540
540
  if (typeof value == 'number') {
541
541
  return value;
542
542
  }
543
- if (isSymbol$2(value)) {
543
+ if (isSymbol_1(value)) {
544
544
  return NAN;
545
545
  }
546
546
  if (isObject_1(value)) {
@@ -848,8 +848,13 @@ var DataTable = (function (Sortable) {
848
848
 
849
849
  var isFunction_1 = isFunction;
850
850
 
851
+ var isFunction$1 = /*#__PURE__*/Object.freeze({
852
+ default: isFunction_1,
853
+ __moduleExports: isFunction_1
854
+ });
855
+
851
856
  /** Used to detect overreaching core-js shims. */
852
- var coreJsData = root$1['__core-js_shared__'];
857
+ var coreJsData = _root['__core-js_shared__'];
853
858
 
854
859
  var _coreJsData = coreJsData;
855
860
 
@@ -899,6 +904,8 @@ var DataTable = (function (Sortable) {
899
904
 
900
905
  var _toSource = toSource;
901
906
 
907
+ var isFunction$2 = ( isFunction$1 && isFunction_1 ) || isFunction$1;
908
+
902
909
  /**
903
910
  * Used to match `RegExp`
904
911
  * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
@@ -936,17 +943,12 @@ var DataTable = (function (Sortable) {
936
943
  if (!isObject_1(value) || _isMasked(value)) {
937
944
  return false;
938
945
  }
939
- var pattern = isFunction_1(value) ? reIsNative : reIsHostCtor;
946
+ var pattern = isFunction$2(value) ? reIsNative : reIsHostCtor;
940
947
  return pattern.test(_toSource(value));
941
948
  }
942
949
 
943
950
  var _baseIsNative = baseIsNative;
944
951
 
945
- var _baseIsNative$1 = /*#__PURE__*/Object.freeze({
946
- default: _baseIsNative,
947
- __moduleExports: _baseIsNative
948
- });
949
-
950
952
  /**
951
953
  * Gets the value at `key` of `object`.
952
954
  *
@@ -961,8 +963,6 @@ var DataTable = (function (Sortable) {
961
963
 
962
964
  var _getValue = getValue;
963
965
 
964
- var baseIsNative$1 = ( _baseIsNative$1 && _baseIsNative ) || _baseIsNative$1;
965
-
966
966
  /**
967
967
  * Gets the native function at `key` of `object`.
968
968
  *
@@ -973,7 +973,7 @@ var DataTable = (function (Sortable) {
973
973
  */
974
974
  function getNative(object, key) {
975
975
  var value = _getValue(object, key);
976
- return baseIsNative$1(value) ? value : undefined;
976
+ return _baseIsNative(value) ? value : undefined;
977
977
  }
978
978
 
979
979
  var _getNative = getNative;
@@ -1066,6 +1066,11 @@ var DataTable = (function (Sortable) {
1066
1066
 
1067
1067
  var _hashHas = hashHas;
1068
1068
 
1069
+ var _hashHas$1 = /*#__PURE__*/Object.freeze({
1070
+ default: _hashHas,
1071
+ __moduleExports: _hashHas
1072
+ });
1073
+
1069
1074
  /** Used to stand-in for `undefined` hash values. */
1070
1075
  var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1071
1076
 
@@ -1088,6 +1093,8 @@ var DataTable = (function (Sortable) {
1088
1093
 
1089
1094
  var _hashSet = hashSet;
1090
1095
 
1096
+ var hashHas$1 = ( _hashHas$1 && _hashHas ) || _hashHas$1;
1097
+
1091
1098
  /**
1092
1099
  * Creates a hash object.
1093
1100
  *
@@ -1110,7 +1117,7 @@ var DataTable = (function (Sortable) {
1110
1117
  Hash.prototype.clear = _hashClear;
1111
1118
  Hash.prototype['delete'] = _hashDelete;
1112
1119
  Hash.prototype.get = _hashGet;
1113
- Hash.prototype.has = _hashHas;
1120
+ Hash.prototype.has = hashHas$1;
1114
1121
  Hash.prototype.set = _hashSet;
1115
1122
 
1116
1123
  var _Hash = Hash;
@@ -1167,6 +1174,13 @@ var DataTable = (function (Sortable) {
1167
1174
 
1168
1175
  var eq_1 = eq;
1169
1176
 
1177
+ var eq$1 = /*#__PURE__*/Object.freeze({
1178
+ default: eq_1,
1179
+ __moduleExports: eq_1
1180
+ });
1181
+
1182
+ var eq$2 = ( eq$1 && eq_1 ) || eq$1;
1183
+
1170
1184
  /**
1171
1185
  * Gets the index at which the `key` is found in `array` of key-value pairs.
1172
1186
  *
@@ -1178,7 +1192,7 @@ var DataTable = (function (Sortable) {
1178
1192
  function assocIndexOf(array, key) {
1179
1193
  var length = array.length;
1180
1194
  while (length--) {
1181
- if (eq_1(array[length][0], key)) {
1195
+ if (eq$2(array[length][0], key)) {
1182
1196
  return length;
1183
1197
  }
1184
1198
  }
@@ -1187,6 +1201,13 @@ var DataTable = (function (Sortable) {
1187
1201
 
1188
1202
  var _assocIndexOf = assocIndexOf;
1189
1203
 
1204
+ var _assocIndexOf$1 = /*#__PURE__*/Object.freeze({
1205
+ default: _assocIndexOf,
1206
+ __moduleExports: _assocIndexOf
1207
+ });
1208
+
1209
+ var assocIndexOf$1 = ( _assocIndexOf$1 && _assocIndexOf ) || _assocIndexOf$1;
1210
+
1190
1211
  /** Used for built-in method references. */
1191
1212
  var arrayProto = Array.prototype;
1192
1213
 
@@ -1204,7 +1225,7 @@ var DataTable = (function (Sortable) {
1204
1225
  */
1205
1226
  function listCacheDelete(key) {
1206
1227
  var data = this.__data__,
1207
- index = _assocIndexOf(data, key);
1228
+ index = assocIndexOf$1(data, key);
1208
1229
 
1209
1230
  if (index < 0) {
1210
1231
  return false;
@@ -1232,7 +1253,7 @@ var DataTable = (function (Sortable) {
1232
1253
  */
1233
1254
  function listCacheGet(key) {
1234
1255
  var data = this.__data__,
1235
- index = _assocIndexOf(data, key);
1256
+ index = assocIndexOf$1(data, key);
1236
1257
 
1237
1258
  return index < 0 ? undefined : data[index][1];
1238
1259
  }
@@ -1249,7 +1270,7 @@ var DataTable = (function (Sortable) {
1249
1270
  * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1250
1271
  */
1251
1272
  function listCacheHas(key) {
1252
- return _assocIndexOf(this.__data__, key) > -1;
1273
+ return assocIndexOf$1(this.__data__, key) > -1;
1253
1274
  }
1254
1275
 
1255
1276
  var _listCacheHas = listCacheHas;
@@ -1266,7 +1287,7 @@ var DataTable = (function (Sortable) {
1266
1287
  */
1267
1288
  function listCacheSet(key, value) {
1268
1289
  var data = this.__data__,
1269
- index = _assocIndexOf(data, key);
1290
+ index = assocIndexOf$1(data, key);
1270
1291
 
1271
1292
  if (index < 0) {
1272
1293
  ++this.size;
@@ -1307,17 +1328,10 @@ var DataTable = (function (Sortable) {
1307
1328
  var _ListCache = ListCache;
1308
1329
 
1309
1330
  /* Built-in method references that are verified to be native. */
1310
- var Map = _getNative(root$1, 'Map');
1331
+ var Map = _getNative(_root, 'Map');
1311
1332
 
1312
1333
  var _Map = Map;
1313
1334
 
1314
- var _Map$1 = /*#__PURE__*/Object.freeze({
1315
- default: _Map,
1316
- __moduleExports: _Map
1317
- });
1318
-
1319
- var Map$1 = ( _Map$1 && _Map ) || _Map$1;
1320
-
1321
1335
  /**
1322
1336
  * Removes all key-value entries from the map.
1323
1337
  *
@@ -1329,13 +1343,18 @@ var DataTable = (function (Sortable) {
1329
1343
  this.size = 0;
1330
1344
  this.__data__ = {
1331
1345
  'hash': new _Hash,
1332
- 'map': new (Map$1 || _ListCache),
1346
+ 'map': new (_Map || _ListCache),
1333
1347
  'string': new _Hash
1334
1348
  };
1335
1349
  }
1336
1350
 
1337
1351
  var _mapCacheClear = mapCacheClear;
1338
1352
 
1353
+ var _mapCacheClear$1 = /*#__PURE__*/Object.freeze({
1354
+ default: _mapCacheClear,
1355
+ __moduleExports: _mapCacheClear
1356
+ });
1357
+
1339
1358
  /**
1340
1359
  * Checks if `value` is suitable for use as unique object key.
1341
1360
  *
@@ -1352,6 +1371,13 @@ var DataTable = (function (Sortable) {
1352
1371
 
1353
1372
  var _isKeyable = isKeyable;
1354
1373
 
1374
+ var _isKeyable$1 = /*#__PURE__*/Object.freeze({
1375
+ default: _isKeyable,
1376
+ __moduleExports: _isKeyable
1377
+ });
1378
+
1379
+ var isKeyable$1 = ( _isKeyable$1 && _isKeyable ) || _isKeyable$1;
1380
+
1355
1381
  /**
1356
1382
  * Gets the data for `map`.
1357
1383
  *
@@ -1362,13 +1388,20 @@ var DataTable = (function (Sortable) {
1362
1388
  */
1363
1389
  function getMapData(map, key) {
1364
1390
  var data = map.__data__;
1365
- return _isKeyable(key)
1391
+ return isKeyable$1(key)
1366
1392
  ? data[typeof key == 'string' ? 'string' : 'hash']
1367
1393
  : data.map;
1368
1394
  }
1369
1395
 
1370
1396
  var _getMapData = getMapData;
1371
1397
 
1398
+ var _getMapData$1 = /*#__PURE__*/Object.freeze({
1399
+ default: _getMapData,
1400
+ __moduleExports: _getMapData
1401
+ });
1402
+
1403
+ var getMapData$1 = ( _getMapData$1 && _getMapData ) || _getMapData$1;
1404
+
1372
1405
  /**
1373
1406
  * Removes `key` and its value from the map.
1374
1407
  *
@@ -1379,7 +1412,7 @@ var DataTable = (function (Sortable) {
1379
1412
  * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1380
1413
  */
1381
1414
  function mapCacheDelete(key) {
1382
- var result = _getMapData(this, key)['delete'](key);
1415
+ var result = getMapData$1(this, key)['delete'](key);
1383
1416
  this.size -= result ? 1 : 0;
1384
1417
  return result;
1385
1418
  }
@@ -1396,7 +1429,7 @@ var DataTable = (function (Sortable) {
1396
1429
  * @returns {*} Returns the entry value.
1397
1430
  */
1398
1431
  function mapCacheGet(key) {
1399
- return _getMapData(this, key).get(key);
1432
+ return getMapData$1(this, key).get(key);
1400
1433
  }
1401
1434
 
1402
1435
  var _mapCacheGet = mapCacheGet;
@@ -1411,7 +1444,7 @@ var DataTable = (function (Sortable) {
1411
1444
  * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1412
1445
  */
1413
1446
  function mapCacheHas(key) {
1414
- return _getMapData(this, key).has(key);
1447
+ return getMapData$1(this, key).has(key);
1415
1448
  }
1416
1449
 
1417
1450
  var _mapCacheHas = mapCacheHas;
@@ -1427,7 +1460,7 @@ var DataTable = (function (Sortable) {
1427
1460
  * @returns {Object} Returns the map cache instance.
1428
1461
  */
1429
1462
  function mapCacheSet(key, value) {
1430
- var data = _getMapData(this, key),
1463
+ var data = getMapData$1(this, key),
1431
1464
  size = data.size;
1432
1465
 
1433
1466
  data.set(key, value);
@@ -1437,6 +1470,8 @@ var DataTable = (function (Sortable) {
1437
1470
 
1438
1471
  var _mapCacheSet = mapCacheSet;
1439
1472
 
1473
+ var mapCacheClear$1 = ( _mapCacheClear$1 && _mapCacheClear ) || _mapCacheClear$1;
1474
+
1440
1475
  /**
1441
1476
  * Creates a map cache object to store key-value pairs.
1442
1477
  *
@@ -1456,7 +1491,7 @@ var DataTable = (function (Sortable) {
1456
1491
  }
1457
1492
 
1458
1493
  // Add methods to `MapCache`.
1459
- MapCache.prototype.clear = _mapCacheClear;
1494
+ MapCache.prototype.clear = mapCacheClear$1;
1460
1495
  MapCache.prototype['delete'] = _mapCacheDelete;
1461
1496
  MapCache.prototype.get = _mapCacheGet;
1462
1497
  MapCache.prototype.has = _mapCacheHas;
@@ -1585,13 +1620,6 @@ var DataTable = (function (Sortable) {
1585
1620
 
1586
1621
  var _strictIndexOf = strictIndexOf;
1587
1622
 
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
1623
  /**
1596
1624
  * The base implementation of `_.indexOf` without `fromIndex` bounds checks.
1597
1625
  *
@@ -1603,12 +1631,19 @@ var DataTable = (function (Sortable) {
1603
1631
  */
1604
1632
  function baseIndexOf(array, value, fromIndex) {
1605
1633
  return value === value
1606
- ? strictIndexOf$1(array, value, fromIndex)
1634
+ ? _strictIndexOf(array, value, fromIndex)
1607
1635
  : _baseFindIndex(array, _baseIsNaN, fromIndex);
1608
1636
  }
1609
1637
 
1610
1638
  var _baseIndexOf = baseIndexOf;
1611
1639
 
1640
+ var _baseIndexOf$1 = /*#__PURE__*/Object.freeze({
1641
+ default: _baseIndexOf,
1642
+ __moduleExports: _baseIndexOf
1643
+ });
1644
+
1645
+ var baseIndexOf$1 = ( _baseIndexOf$1 && _baseIndexOf ) || _baseIndexOf$1;
1646
+
1612
1647
  /**
1613
1648
  * A specialized version of `_.includes` for arrays without support for
1614
1649
  * specifying an index to search from.
@@ -1620,11 +1655,16 @@ var DataTable = (function (Sortable) {
1620
1655
  */
1621
1656
  function arrayIncludes(array, value) {
1622
1657
  var length = array == null ? 0 : array.length;
1623
- return !!length && _baseIndexOf(array, value, 0) > -1;
1658
+ return !!length && baseIndexOf$1(array, value, 0) > -1;
1624
1659
  }
1625
1660
 
1626
1661
  var _arrayIncludes = arrayIncludes;
1627
1662
 
1663
+ var _arrayIncludes$1 = /*#__PURE__*/Object.freeze({
1664
+ default: _arrayIncludes,
1665
+ __moduleExports: _arrayIncludes
1666
+ });
1667
+
1628
1668
  /**
1629
1669
  * This function is like `arrayIncludes` except that it accepts a comparator.
1630
1670
  *
@@ -1663,7 +1703,7 @@ var DataTable = (function (Sortable) {
1663
1703
  var _cacheHas = cacheHas;
1664
1704
 
1665
1705
  /* Built-in method references that are verified to be native. */
1666
- var Set$1 = _getNative(root$1, 'Set');
1706
+ var Set$1 = _getNative(_root, 'Set');
1667
1707
 
1668
1708
  var _Set = Set$1;
1669
1709
 
@@ -1720,6 +1760,8 @@ var DataTable = (function (Sortable) {
1720
1760
 
1721
1761
  var _createSet = createSet;
1722
1762
 
1763
+ var arrayIncludes$1 = ( _arrayIncludes$1 && _arrayIncludes ) || _arrayIncludes$1;
1764
+
1723
1765
  /** Used as the size to enable large array optimizations. */
1724
1766
  var LARGE_ARRAY_SIZE = 200;
1725
1767
 
@@ -1734,7 +1776,7 @@ var DataTable = (function (Sortable) {
1734
1776
  */
1735
1777
  function baseUniq(array, iteratee, comparator) {
1736
1778
  var index = -1,
1737
- includes = _arrayIncludes,
1779
+ includes = arrayIncludes$1,
1738
1780
  length = array.length,
1739
1781
  isCommon = true,
1740
1782
  result = [],
@@ -2033,6 +2075,7 @@ var DataTable = (function (Sortable) {
2033
2075
  sortable: false,
2034
2076
  focusable: false,
2035
2077
  dropdown: false,
2078
+ sticky: true,
2036
2079
  width: 32
2037
2080
  };
2038
2081
  this.columns.push(cell);
@@ -2041,16 +2084,14 @@ var DataTable = (function (Sortable) {
2041
2084
  if (this.options.serialNoColumn && !this.hasColumnById('_rowIndex')) {
2042
2085
  let cell = {
2043
2086
  id: '_rowIndex',
2044
- content: '',
2087
+ content: this.options.serialNoColumnLabel || '',
2045
2088
  align: 'center',
2046
2089
  editable: false,
2047
- resizable: false,
2090
+ resizable: true,
2048
2091
  focusable: false,
2049
- dropdown: false
2092
+ dropdown: false,
2093
+ sticky: true
2050
2094
  };
2051
- if (this.options.data.length > 1000) {
2052
- cell.resizable = true;
2053
- }
2054
2095
  this.columns.push(cell);
2055
2096
  }
2056
2097
  }
@@ -2634,6 +2675,7 @@ var DataTable = (function (Sortable) {
2634
2675
  this.bindKeyboardSelection();
2635
2676
  this.bindCopyCellContents();
2636
2677
  this.bindMouseEvents();
2678
+ this.bindWheelEvents();
2637
2679
  this.bindTreeEvents();
2638
2680
  }
2639
2681
 
@@ -2682,6 +2724,7 @@ var DataTable = (function (Sortable) {
2682
2724
  }
2683
2725
 
2684
2726
  this.focusCell($cell);
2727
+ sessionStorage.setItem('dt-last-nav-method', 'key');
2685
2728
  return true;
2686
2729
  };
2687
2730
 
@@ -2790,6 +2833,12 @@ var DataTable = (function (Sortable) {
2790
2833
  $.on(this.bodyScrollable, 'mousemove', '.dt-cell', throttle$1(selectArea, 50));
2791
2834
  }
2792
2835
 
2836
+ bindWheelEvents() {
2837
+ $.on(this.bodyScrollable, 'wheel', (e) => {
2838
+ sessionStorage.setItem('dt-last-nav-method', 'scroll');
2839
+ });
2840
+ }
2841
+
2793
2842
  bindTreeEvents() {
2794
2843
  $.on(this.bodyScrollable, 'click', '.dt-tree-node__toggle', (e, $toggle) => {
2795
2844
  const $cell = $.closest('.dt-cell', $toggle);
@@ -2914,11 +2963,13 @@ var DataTable = (function (Sortable) {
2914
2963
  // this function is called after hyperlist renders the rows after scroll,
2915
2964
  // focusCell calls clearSelection which resets the area selection
2916
2965
  // so a flag to skip it
2917
- // we also skip DOM focus and scroll to cell
2918
- // because it fights with the user scroll
2966
+ // we skip scroll to cell
2967
+ // and also skip DOM focus (if user is scrolling) because it fights with the user scroll
2968
+ const skipDOMFocus = sessionStorage.getItem('dt-last-nav-method') !== 'key';
2969
+
2919
2970
  this.focusCell($cell, {
2971
+ skipDOMFocus,
2920
2972
  skipClearSelection: 1,
2921
- skipDOMFocus: 1,
2922
2973
  skipScrollToCell: 1
2923
2974
  });
2924
2975
  }
@@ -3315,6 +3366,7 @@ var DataTable = (function (Sortable) {
3315
3366
  }
3316
3367
 
3317
3368
  this.focusCell($cell);
3369
+ sessionStorage.setItem('dt-last-nav-method', 'key');
3318
3370
  return true;
3319
3371
  }
3320
3372
 
@@ -3413,8 +3465,15 @@ var DataTable = (function (Sortable) {
3413
3465
  });
3414
3466
 
3415
3467
  const row = this.datamanager.getRow(rowIndex);
3468
+ const column = cell.column || this.datamanager.getColumn(colIndex) || {};
3416
3469
 
3417
3470
  const isBodyCell = !(isHeader || isFilter || isTotalRow);
3471
+ const isSticky = Boolean(column.sticky);
3472
+ const stickyColumns = this.datamanager.getColumns().filter(col => col.sticky);
3473
+ const lastStickyColumn = stickyColumns[stickyColumns.length - 1];
3474
+ const isLastStickyColumn = isSticky &&
3475
+ lastStickyColumn &&
3476
+ lastStickyColumn.colIndex === colIndex;
3418
3477
 
3419
3478
  const className = [
3420
3479
  'dt-cell',
@@ -3424,7 +3483,10 @@ var DataTable = (function (Sortable) {
3424
3483
  isHeader ? 'dt-cell--header' : '',
3425
3484
  isHeader ? `dt-cell--header-${colIndex}` : '',
3426
3485
  isFilter ? 'dt-cell--filter' : '',
3427
- isBodyCell && (row && row.meta.isTreeNodeClose) ? 'dt-cell--tree-close' : ''
3486
+ isBodyCell && (row && row.meta.isTreeNodeClose) ? 'dt-cell--tree-close' : '',
3487
+ isSticky ? 'dt-cell--sticky' : '',
3488
+ isSticky && !isBodyCell ? 'dt-cell--sticky-top' : '',
3489
+ isLastStickyColumn ? 'dt-cell--sticky-last' : ''
3428
3490
  ].join(' ');
3429
3491
 
3430
3492
  return `
@@ -3622,7 +3684,7 @@ var DataTable = (function (Sortable) {
3622
3684
  });
3623
3685
 
3624
3686
  $.on(this.$dropdownList, 'click', '.dt-dropdown__list-item', (e, $item) => {
3625
- if (!this._dropdownActiveColIndex) return;
3687
+ if (this._dropdownActiveColIndex == null) return;
3626
3688
  const dropdownItems = this.options.headerDropdown;
3627
3689
  const { index } = $.data($item);
3628
3690
  const colIndex = this._dropdownActiveColIndex;
@@ -3637,6 +3699,11 @@ var DataTable = (function (Sortable) {
3637
3699
  _this.hideDropdown();
3638
3700
  }
3639
3701
 
3702
+ this.stickDropdownIndex = this.options.headerDropdown
3703
+ .findIndex(item => item.stickyAction === 'stick');
3704
+ this.unstickDropdownIndex = this.options.headerDropdown
3705
+ .findIndex(item => item.stickyAction === 'unstick');
3706
+
3640
3707
  this.hideDropdown();
3641
3708
  }
3642
3709
 
@@ -3653,6 +3720,7 @@ var DataTable = (function (Sortable) {
3653
3720
  const $cell = $.closest('.dt-cell', e.target);
3654
3721
  const { colIndex } = $.data($cell);
3655
3722
  this._dropdownActiveColIndex = colIndex;
3723
+ this.updateStickyDropdownItems(this.getColumn(colIndex));
3656
3724
  }
3657
3725
 
3658
3726
  hideDropdown() {
@@ -3833,6 +3901,20 @@ var DataTable = (function (Sortable) {
3833
3901
  });
3834
3902
  }
3835
3903
 
3904
+ setColumnSticky(colIndex, sticky) {
3905
+ const column = this.getColumn(colIndex);
3906
+ if (!column || column.sticky === sticky) {
3907
+ return;
3908
+ }
3909
+
3910
+ this.instance.freeze();
3911
+ this.datamanager.updateColumn(colIndex, { sticky });
3912
+
3913
+ this.refreshHeader();
3914
+ this.rowmanager.refreshRows()
3915
+ .then(() => this.instance.unfreeze());
3916
+ }
3917
+
3836
3918
  switchColumn(oldIndex, newIndex) {
3837
3919
  this.instance.freeze();
3838
3920
  this.datamanager.switchColumn(oldIndex, newIndex)
@@ -4022,6 +4104,23 @@ var DataTable = (function (Sortable) {
4022
4104
  toggleDropdownItem(index) {
4023
4105
  $('.dt-dropdown__list', this.instance.dropdownContainer).children[index].classList.toggle('dt-hidden');
4024
4106
  }
4107
+
4108
+ updateStickyDropdownItems(column) {
4109
+ if (!column) return;
4110
+ if (this.stickDropdownIndex === -1 || this.unstickDropdownIndex === -1) return;
4111
+
4112
+ const stickItem = this.$dropdownList.children[this.stickDropdownIndex];
4113
+ const unstickItem = this.$dropdownList.children[this.unstickDropdownIndex];
4114
+ if (!(stickItem && unstickItem)) return;
4115
+
4116
+ if (column.sticky) {
4117
+ stickItem.classList.add('dt-hidden');
4118
+ unstickItem.classList.remove('dt-hidden');
4119
+ } else {
4120
+ stickItem.classList.remove('dt-hidden');
4121
+ unstickItem.classList.add('dt-hidden');
4122
+ }
4123
+ }
4025
4124
  }
4026
4125
 
4027
4126
  class RowManager {
@@ -4889,12 +4988,26 @@ var DataTable = (function (Sortable) {
4889
4988
  }
4890
4989
 
4891
4990
  render() {
4892
- const rows = this.datamanager.getRowsForView();
4991
+ const rows = this.getRowsToRender();
4893
4992
  this.renderRows(rows);
4894
4993
  // setDimensions requires atleast 1 row to exist in dom
4895
4994
  this.instance.setDimensions();
4896
4995
  }
4897
4996
 
4997
+ // Keep the current tree expand/collapse state on a full re-render
4998
+ getRowsToRender() {
4999
+ const rows = this.datamanager.getRowsForView();
5000
+ let closedIndent = null;
5001
+ return rows.filter(row => {
5002
+ const { indent, isTreeNodeClose } = row.meta;
5003
+ if (closedIndent !== null && indent > closedIndent) {
5004
+ return false;
5005
+ }
5006
+ closedIndent = isTreeNodeClose ? indent : null;
5007
+ return true;
5008
+ });
5009
+ }
5010
+
4898
5011
  renderFooter() {
4899
5012
  if (!this.options.showTotalRow) return;
4900
5013
 
@@ -5024,6 +5137,7 @@ var DataTable = (function (Sortable) {
5024
5137
 
5025
5138
  bindScrollHeader() {
5026
5139
  this._settingHeaderPosition = false;
5140
+ this.updateStickyTopPositions(0);
5027
5141
 
5028
5142
  $.on(this.bodyScrollable, 'scroll', (e) => {
5029
5143
  if (this._settingHeaderPosition) return;
@@ -5031,7 +5145,8 @@ var DataTable = (function (Sortable) {
5031
5145
  this._settingHeaderPosition = true;
5032
5146
 
5033
5147
  requestAnimationFrame(() => {
5034
- const left = -e.target.scrollLeft;
5148
+ const scrollLeft = e.target.scrollLeft;
5149
+ const left = -scrollLeft;
5035
5150
 
5036
5151
  $.style(this.header, {
5037
5152
  transform: `translateX(${left}px)`
@@ -5039,6 +5154,7 @@ var DataTable = (function (Sortable) {
5039
5154
  $.style(this.footer, {
5040
5155
  transform: `translateX(${left}px)`
5041
5156
  });
5157
+ this.updateStickyTopPositions(scrollLeft);
5042
5158
  this._settingHeaderPosition = false;
5043
5159
  if (this.instance.noData) {
5044
5160
  $.style($('.no-data-message'), {
@@ -5136,6 +5252,8 @@ var DataTable = (function (Sortable) {
5136
5252
  this.setupColumnWidth();
5137
5253
  this.distributeRemainingWidth();
5138
5254
  this.setColumnStyle();
5255
+ this.setStickyColumnStyle();
5256
+ this.updateStickyTopPositions(this.bodyScrollable.scrollLeft || 0);
5139
5257
  this.setBodyStyle();
5140
5258
  }
5141
5259
 
@@ -5293,6 +5411,8 @@ var DataTable = (function (Sortable) {
5293
5411
  this.columnmanager.setColumnHeaderWidth(column.colIndex);
5294
5412
  this.columnmanager.setColumnWidth(column.colIndex);
5295
5413
  });
5414
+ this.setStickyColumnStyle();
5415
+ this.updateStickyTopPositions(this.bodyScrollable.scrollLeft || 0);
5296
5416
  }
5297
5417
 
5298
5418
  setBodyStyle() {
@@ -5354,6 +5474,56 @@ var DataTable = (function (Sortable) {
5354
5474
  return $(`.dt-cell--col-${colIndex}`, this.header);
5355
5475
  }
5356
5476
 
5477
+ setStickyColumnStyle() {
5478
+ if (!this.datamanager || !this.datamanager.getColumns) return;
5479
+
5480
+ const stickySelectors = [];
5481
+ let stickyOffset = 0;
5482
+ let normalOffset = 0;
5483
+
5484
+ this.datamanager.getColumns().forEach((column) => {
5485
+ const $headerCell = this.getColumnHeaderElement(column.colIndex);
5486
+ const renderedWidth = $headerCell ? $headerCell.offsetWidth : column.width;
5487
+
5488
+ if (column.sticky) {
5489
+ const selector = `.dt-cell--col-${column.colIndex}.dt-cell--sticky`;
5490
+ const style = {
5491
+ left: `${stickyOffset}px`
5492
+ };
5493
+
5494
+ column.stickyLeft = stickyOffset;
5495
+ column.stickyScrollTrigger = normalOffset - stickyOffset;
5496
+ column.renderedWidth = renderedWidth;
5497
+ this.setStyle(selector, style);
5498
+ stickySelectors.push(selector);
5499
+ stickyOffset += renderedWidth;
5500
+ }
5501
+ normalOffset += renderedWidth;
5502
+ });
5503
+
5504
+ const staleSelectors = (this._stickySelectors || [])
5505
+ .filter(selector => !stickySelectors.includes(selector));
5506
+
5507
+ staleSelectors.forEach(selector => this.removeStyle(selector));
5508
+ this._stickySelectors = stickySelectors;
5509
+ }
5510
+
5511
+ updateStickyTopPositions(scrollLeft) {
5512
+ if (!this.datamanager || !this.datamanager.getColumns) return;
5513
+
5514
+ const stickyColumns = this.datamanager.getColumns().filter(column => column.sticky);
5515
+
5516
+ stickyColumns.forEach((column) => {
5517
+ const trigger = Math.max(0, column.stickyScrollTrigger || 0);
5518
+ const compensation = Math.max(0, scrollLeft - trigger);
5519
+ const cells = $.each(`.dt-cell--col-${column.colIndex}.dt-cell--sticky-top`, this.wrapper) || [];
5520
+
5521
+ $.style(cells, {
5522
+ transform: compensation ? `translateX(${compensation}px)` : ''
5523
+ });
5524
+ });
5525
+ }
5526
+
5357
5527
  getRowIndexColumnWidth() {
5358
5528
  const rowCount = this.datamanager.getRowCount();
5359
5529
  const padding = 22;
@@ -5417,7 +5587,11 @@ var DataTable = (function (Sortable) {
5417
5587
  }
5418
5588
  }
5419
5589
 
5590
+ var Freeze = "Freeze";
5591
+ var Unfreeze = "Unfreeze";
5420
5592
  var en = {
5593
+ Freeze: Freeze,
5594
+ Unfreeze: Unfreeze,
5421
5595
  "Sort Ascending": "Sort Ascending",
5422
5596
  "Sort Descending": "Sort Descending",
5423
5597
  "Reset sorting": "Reset sorting",
@@ -5427,7 +5601,11 @@ var DataTable = (function (Sortable) {
5427
5601
  "{count} rows selected": {"1":"{count} row selected","default":"{count} rows selected"}
5428
5602
  };
5429
5603
 
5604
+ var Freeze$1 = "Bevriezen";
5605
+ var Unfreeze$1 = "Ontdooien";
5430
5606
  var de = {
5607
+ Freeze: Freeze$1,
5608
+ Unfreeze: Unfreeze$1,
5431
5609
  "Sort Ascending": "Aufsteigend sortieren",
5432
5610
  "Sort Descending": "Absteigend sortieren",
5433
5611
  "Reset sorting": "Sortierung zurücksetzen",
@@ -5437,7 +5615,11 @@ var DataTable = (function (Sortable) {
5437
5615
  "{count} rows selected": {"1":"{count} Zeile ausgewählt","default":"{count} Zeilen ausgewählt"}
5438
5616
  };
5439
5617
 
5618
+ var Freeze$2 = "Geler";
5619
+ var Unfreeze$2 = "Dégeler";
5440
5620
  var fr = {
5621
+ Freeze: Freeze$2,
5622
+ Unfreeze: Unfreeze$2,
5441
5623
  "Sort Ascending": "Trier par ordre croissant",
5442
5624
  "Sort Descending": "Trier par ordre décroissant",
5443
5625
  "Reset sorting": "Réinitialiser le tri",
@@ -5447,7 +5629,11 @@ var DataTable = (function (Sortable) {
5447
5629
  "{count} rows selected": {"1":"{count} ligne sélectionnée","default":"{count} lignes sélectionnées"}
5448
5630
  };
5449
5631
 
5632
+ var Freeze$3 = "Congelare";
5633
+ var Unfreeze$3 = "Dégeler";
5450
5634
  var it = {
5635
+ Freeze: Freeze$3,
5636
+ Unfreeze: Unfreeze$3,
5451
5637
  "Sort Ascending": "Ordinamento ascendente",
5452
5638
  "Sort Descending": "Ordinamento decrescente",
5453
5639
  "Reset sorting": "Azzeramento ordinamento",
@@ -5729,6 +5915,22 @@ var DataTable = (function (Sortable) {
5729
5915
  action: function (column) {
5730
5916
  this.removeColumn(column.colIndex);
5731
5917
  }
5918
+ },
5919
+ {
5920
+ label: instance.translate('Freeze'),
5921
+ stickyAction: 'stick',
5922
+ display: 'hidden',
5923
+ action: function (column) {
5924
+ this.setColumnSticky(column.colIndex, true);
5925
+ }
5926
+ },
5927
+ {
5928
+ label: instance.translate('Unfreeze'),
5929
+ stickyAction: 'unstick',
5930
+ display: 'hidden',
5931
+ action: function (column) {
5932
+ this.setColumnSticky(column.colIndex, false);
5933
+ }
5732
5934
  }
5733
5935
  ],
5734
5936
  events: {
@@ -5753,6 +5955,7 @@ var DataTable = (function (Sortable) {
5753
5955
  freezeMessage: '',
5754
5956
  getEditor: null,
5755
5957
  serialNoColumn: true,
5958
+ serialNoColumnLabel: '',
5756
5959
  checkboxColumn: false,
5757
5960
  clusterize: true,
5758
5961
  logs: false,
@@ -5984,6 +6187,10 @@ var DataTable = (function (Sortable) {
5984
6187
  this.columnmanager.removeColumn(colIndex);
5985
6188
  }
5986
6189
 
6190
+ setColumnSticky(colIndex, sticky) {
6191
+ this.columnmanager.setColumnSticky(colIndex, sticky);
6192
+ }
6193
+
5987
6194
  scrollToLastColumn() {
5988
6195
  this.datatableWrapper.scrollLeft = 9999;
5989
6196
  }
@@ -6063,7 +6270,7 @@ var DataTable = (function (Sortable) {
6063
6270
  var jsdelivr = "dist/melondtable.min.js";
6064
6271
  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
6272
  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"};
6273
+ 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
6274
  var repository = {"type":"git","url":"https://github.com/amonak/melondtable.git"};
6068
6275
  var keywords = ["datatable","data","grid","table"];
6069
6276
  var author = "Alphamonak Solutions";