canvas-datagrid 0.3.14 → 0.3.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,30 @@ All notable changes to this project will be documented in this file.
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
+ ## 0.3.18 - 2021-11-18
11
+
12
+ No changes; had to bump version number because race condition caused 0.3.16 to be published instead of 0.3.17.
13
+
14
+ ## 0.3.17 - 2021-11-18
15
+
16
+ ### Fixed
17
+
18
+ - Do not render row gaps when sorting (ndrsn, #391)
19
+
20
+ ## 0.3.16 - 2021-11-18
21
+
22
+ ### Fixed
23
+
24
+ - Fix string sort when value is null/undefined (faimaklg, #388)
25
+
26
+ ## 0.3.15 - 2021-11-18
27
+
28
+ ### Fixed
29
+
30
+ - Fix highlighting incorrect column after repositioning column (xianzhi3, #399)
31
+ - Reverse sort order icon (faimaklg, #387)
32
+ - Fix link in tutorials (slominskir, #386)
33
+
10
34
  ## 0.3.14 - 2021-10-20
11
35
 
12
36
  ### Added
@@ -1892,15 +1892,15 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
1892
1892
  y = y + mt;
1893
1893
 
1894
1894
  if (self.orderDirection === 'asc') {
1895
- self.ctx.moveTo(x, y);
1896
- self.ctx.lineTo(x + aw, y);
1897
- self.ctx.lineTo(x + aw * 0.5, y + ah);
1898
- self.ctx.moveTo(x, y);
1899
- } else {
1900
1895
  self.ctx.lineTo(x, y + ah);
1901
1896
  self.ctx.lineTo(x + aw, y + ah);
1902
1897
  self.ctx.lineTo(x + aw * 0.5, y);
1903
1898
  self.ctx.lineTo(x, y + ah);
1899
+ } else {
1900
+ self.ctx.moveTo(x, y);
1901
+ self.ctx.lineTo(x + aw, y);
1902
+ self.ctx.lineTo(x + aw * 0.5, y + ah);
1903
+ self.ctx.moveTo(x, y);
1904
1904
  }
1905
1905
 
1906
1906
  self.ctx.stroke();
@@ -2796,9 +2796,13 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
2796
2796
 
2797
2797
  self.ctx.restore(); // Gaps may occur in row numbers between consecutively rendered rows
2798
2798
  // when we are filtering. We draw attention to this by drawing a thick
2799
- // border overlapping the two consecutive row headers.
2799
+ // border overlapping the two consecutive row headers. If sorting, visible
2800
+ // row numbers stay the same (i.e. they don't correspond to the underlying
2801
+ // data's row number), so we do not show row gaps in that case.
2802
+
2803
+ var isSorting = self.orderings.columns && self.orderings.columns.length > 0;
2800
2804
 
2801
- if (isRowHeader && self.attributes.showRowNumbers && self.attributes.showRowNumberGaps) {
2805
+ if (isRowHeader && self.attributes.showRowNumbers && self.attributes.showRowNumberGaps && isSorting === false) {
2802
2806
  var previousRowNumber = self.getBoundRowIndexFromViewRowIndex(rowOrderIndex - 1);
2803
2807
  var hasRowGap = previousRowNumber !== undefined && cell.boundRowIndex > 0 && cell.boundRowIndex - previousRowNumber > 1;
2804
2808
 
@@ -4365,6 +4369,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
4365
4369
  self.stopDragReorder = function (e) {
4366
4370
  var oIndex,
4367
4371
  tIndex,
4372
+ odata,
4368
4373
  cr = {
4369
4374
  'row-reorder': self.orders.rows,
4370
4375
  'column-reorder': self.orders.columns
@@ -4385,13 +4390,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
4385
4390
  self.ignoreNextClick = true;
4386
4391
  oIndex = cr[self.dragMode].indexOf(self.reorderObject[i]);
4387
4392
  tIndex = cr[self.dragMode].indexOf(self.reorderTarget[i]);
4388
- cr[self.dragMode].splice(oIndex, 1);
4389
- cr[self.dragMode].splice(tIndex, 0, self.reorderObject[i]);
4390
4393
 
4391
4394
  if (self.dragMode === 'column-reorder') {
4395
+ cr[self.dragMode].splice(oIndex, 1);
4396
+ cr[self.dragMode].splice(tIndex, 0, self.reorderObject[i]);
4392
4397
  self.orders.columns = cr[self.dragMode];
4393
4398
  } else {
4394
- self.orders.rows = cr[self.dragMode];
4399
+ // self.orders.rows = cr[self.dragMode];
4400
+ odata = self.viewData[oIndex];
4401
+ self.viewData[oIndex] = self.viewData[tIndex];
4402
+ self.viewData[tIndex] = odata;
4395
4403
  }
4396
4404
 
4397
4405
  self.resize();
@@ -4617,6 +4625,12 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
4617
4625
 
4618
4626
  if (['row-reorder', 'column-reorder'].indexOf(self.dragMode) !== -1) {
4619
4627
  self.draggingItem = self.dragStartObject;
4628
+
4629
+ if (self.dragMode === 'column-reorder' && self.attributes.columnHeaderClickBehavior === 'select') {
4630
+ self.selectColumn(self.currentCell.header.index, ctrl, e.shiftKey);
4631
+ self.draw();
4632
+ }
4633
+
4620
4634
  document.body.addEventListener('mousemove', self.dragReorder, false);
4621
4635
  document.body.addEventListener('mouseup', self.stopDragReorder, false);
4622
4636
  return;
@@ -4625,9 +4639,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
4625
4639
 
4626
4640
  self.mouseup = function (e) {
4627
4641
  clearTimeout(self.scrollTimer);
4642
+ var ctrl = e.ctrlKey || e.metaKey;
4628
4643
  self.cellBoundaryCrossed = true;
4629
4644
  self.rowBoundaryCrossed = true;
4630
4645
  self.columnBoundaryCrossed = true;
4646
+
4647
+ if (self.draggingItem) {
4648
+ self.selectColumn(self.currentCell.header.index, ctrl, e.shiftKey);
4649
+ self.draw();
4650
+ }
4651
+
4631
4652
  self.selecting = undefined;
4632
4653
  self.draggingItem = undefined;
4633
4654
  self.dragStartObject = undefined;
@@ -8717,27 +8738,22 @@ __webpack_require__.r(__webpack_exports__);
8717
8738
  self.sorters.string = function (columnName, direction) {
8718
8739
  var asc = direction === 'asc';
8719
8740
  return function (a, b) {
8720
- if (a[columnName] === undefined || a[columnName] === null) {
8721
- return 1;
8722
- }
8723
-
8724
- if (b[columnName] === undefined || b[columnName] === null) {
8725
- return 0;
8726
- }
8741
+ var aValue = a[columnName] || '';
8742
+ var bValue = b[columnName] || '';
8727
8743
 
8728
8744
  if (asc) {
8729
- if (!a[columnName].localeCompare) {
8745
+ if (!aValue.localeCompare) {
8730
8746
  return 1;
8731
8747
  }
8732
8748
 
8733
- return a[columnName].localeCompare(b[columnName]);
8749
+ return aValue.localeCompare(bValue);
8734
8750
  }
8735
8751
 
8736
- if (!b[columnName].localeCompare) {
8752
+ if (!bValue.localeCompare) {
8737
8753
  return 1;
8738
8754
  }
8739
8755
 
8740
- return b[columnName].localeCompare(a[columnName]);
8756
+ return bValue.localeCompare(aValue);
8741
8757
  };
8742
8758
  };
8743
8759