wunderbaum 0.5.4 → 0.6.0

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/src/wunderbaum.ts CHANGED
@@ -538,7 +538,7 @@ export class Wunderbaum {
538
538
  } else if ((<Event>el).target) {
539
539
  el = (<Event>el).target as Element;
540
540
  }
541
- util.assert(el instanceof Element);
541
+ util.assert(el instanceof Element, `Invalid el type: ${el}`);
542
542
  if (!(<HTMLElement>el).matches(".wunderbaum")) {
543
543
  el = (<HTMLElement>el).closest(".wunderbaum")!;
544
544
  }
@@ -843,7 +843,7 @@ export class Wunderbaum {
843
843
  node = nodeOrOpts;
844
844
  } else {
845
845
  node = this.getActiveNode()!;
846
- util.assert(options === undefined);
846
+ util.assert(options === undefined, `Unexpected options: ${options}`);
847
847
  options = nodeOrOpts;
848
848
  }
849
849
  // clipboard = options.clipboard;
@@ -1066,7 +1066,10 @@ export class Wunderbaum {
1066
1066
  try {
1067
1067
  this.enableUpdate(false);
1068
1068
  const res = func();
1069
- util.assert(!(res instanceof Promise));
1069
+ util.assert(
1070
+ !(res instanceof Promise),
1071
+ `Promise return not allowed: ${res}`
1072
+ );
1070
1073
  return res;
1071
1074
  } finally {
1072
1075
  this.enableUpdate(true);
@@ -1547,7 +1550,7 @@ export class Wunderbaum {
1547
1550
  options = nodeOrOpts;
1548
1551
  node = options.node;
1549
1552
  }
1550
- util.assert(node && node._rowIdx != null);
1553
+ util.assert(node && node._rowIdx != null, `Invalid node: ${node}`);
1551
1554
 
1552
1555
  const scrollParent = this.element;
1553
1556
  const headerHeight = this.headerElement.clientHeight; // May be 0
@@ -1623,8 +1626,11 @@ export class Wunderbaum {
1623
1626
  * Available in cell-nav mode only.
1624
1627
  */
1625
1628
  setColumn(colIdx: number) {
1626
- util.assert(this.isCellNav());
1627
- util.assert(0 <= colIdx && colIdx < this.columns.length);
1629
+ util.assert(this.isCellNav(), "Exected cellNav mode");
1630
+ util.assert(
1631
+ 0 <= colIdx && colIdx < this.columns.length,
1632
+ `Invalid colIdx: ${colIdx}`
1633
+ );
1628
1634
  this.activeColIdx = colIdx;
1629
1635
 
1630
1636
  // Update `wb-active` class for all headers
@@ -1776,11 +1782,11 @@ export class Wunderbaum {
1776
1782
  return this.columns && this.columns.length > 1;
1777
1783
  }
1778
1784
 
1779
- /** Return true if cell-navigation mode is acive. */
1785
+ /** Return true if cell-navigation mode is active. */
1780
1786
  isCellNav(): boolean {
1781
1787
  return !!this._cellNavMode;
1782
1788
  }
1783
- /** Return true if row-navigation mode is acive. */
1789
+ /** Return true if row-navigation mode is active. */
1784
1790
  isRowNav(): boolean {
1785
1791
  return !this._cellNavMode;
1786
1792
  }
@@ -1840,7 +1846,7 @@ export class Wunderbaum {
1840
1846
 
1841
1847
  /** Add or redefine node type definitions. */
1842
1848
  setTypes(types: any, replace = true) {
1843
- util.assert(util.isPlainObject(types));
1849
+ util.assert(util.isPlainObject(types), `Expected plain objext: ${types}`);
1844
1850
  if (replace) {
1845
1851
  this.types = types;
1846
1852
  } else {
@@ -1890,7 +1896,8 @@ export class Wunderbaum {
1890
1896
  const defaultMinWidth = 4;
1891
1897
  const vpWidth = this.element.clientWidth;
1892
1898
  // Shorten last column width to avoid h-scrollbar
1893
- const FIX_ADJUST_LAST_COL = 0; // 2;
1899
+ // (otherwise resizbing the demo would display a void scrollbar?)
1900
+ const FIX_ADJUST_LAST_COL = 1;
1894
1901
  const columns = this.columns;
1895
1902
  const col0 = columns[0];
1896
1903
 
@@ -1991,7 +1998,7 @@ export class Wunderbaum {
1991
1998
  * @internal
1992
1999
  */
1993
2000
  protected _renderHeaderMarkup() {
1994
- util.assert(this.headerElement);
2001
+ util.assert(this.headerElement, "Expected a headerElement");
1995
2002
  const wantHeader = this.hasHeader();
1996
2003
  util.setElemDisplay(this.headerElement, wantHeader);
1997
2004
  if (!wantHeader) {
@@ -1999,7 +2006,7 @@ export class Wunderbaum {
1999
2006
  }
2000
2007
  const colCount = this.columns.length;
2001
2008
  const headerRow = this.headerElement.querySelector(".wb-row")!;
2002
- util.assert(headerRow);
2009
+ util.assert(headerRow, "Expected a row in header element");
2003
2010
  headerRow.innerHTML = "<span class='wb-col'></span>".repeat(colCount);
2004
2011
 
2005
2012
  for (let i = 0; i < colCount; i++) {