@websy/websy-designs 1.3.11 → 1.4.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.
@@ -2617,7 +2617,9 @@ var WebsyIcons = {
2617
2617
  'Pin': "\n <svg xmlns=\"http://www.w3.org/2000/svg\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 500 500\" style=\"enable-background:new 0 0 500 500;\" xml:space=\"preserve\">\n\t<g>\n\t\t<path d=\"M368,312.1H132l-0.6-9.4c-0.1-2.4-0.2-4.8-0.2-7.1c0-40.3,20.7-78.1,54.4-99.9V73.2h-9c-13,0-23.6-10.6-23.6-23.6\n\t\t\tS163.5,26,176.6,26h146.9c13,0,23.6,10.6,23.6,23.6s-10.6,23.6-23.6,23.6h-9v122.5c33.7,21.8,54.4,59.5,54.4,99.9\n\t\t\tc0,2.3-0.1,4.7-0.2,7.1L368,312.1z M151.2,292.1h197.5c-1.2-33.8-19.9-65.1-49.4-82.1l-5-2.9V53.2h29c2,0,3.6-1.6,3.6-3.6\n\t\t\tc0-2-1.6-3.6-3.6-3.6H176.6c-2,0-3.6,1.6-3.6,3.6c0,2,1.6,3.6,3.6,3.6h29v153.9l-5,2.9C171.1,227,152.4,258.3,151.2,292.1z\"/>\n\t</g>\n\t<path d=\"M260.9,403.8V299.9h-21.8v108.8h0c0.1,36.1,4.9,65.3,10.9,65.3c6,0,10.9-29.7,10.9-66.4\n\t\tC260.9,406.4,260.9,405.1,260.9,403.8z\"/>\n</svg>\n\n ",
2618
2618
  'WindowPopout': "\n <svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 500 500\" style=\"enable-background:new 0 0 500 500;\" xml:space=\"preserve\">\n<style type=\"text/css\">\n\t.st0{fill:none;stroke:#000000;stroke-width:20;stroke-miterlimit:10;}\n</style>\n<path class=\"st0\" d=\"M420.1,359.6h-285c-24.7,0-45-20.2-45-45V124.9c0-24.7,20.2-45,45-45h285c24.7,0,45,20.2,45,45v189.7\n\tC465.1,339.3,444.9,359.6,420.1,359.6z\"/>\n<path class=\"st0\" d=\"M407.3,389.8c-6.3,17.3-22.9,29.7-42.3,29.7H80c-24.7,0-45-20.2-45-45V184.9c0-18.2,10.9-33.9,26.5-41\"/>\n</svg>\n\n ",
2619
2619
  'Plus': "\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 500 500\">\n<path d=\"M254.7,486h-10.3c-5.5,0-10-4.5-10-10V26c0-5.5,4.5-10,10-10h10.3c5.5,0,10,4.5,10,10v450C264.6,481.5,260.2,486,254.7,486z\"/>\n<path d=\"M15,255.1v-10.3c0-5.5,4.5-10,10-10h450c5.5,0,10,4.5,10,10v10.3c0,5.5-4.5,10-10,10H25C19.5,265.1,15,260.7,15,255.1z\"/>\n</svg>\n\n ",
2620
- 'Minus': "\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 500 500\">\n<path d=\"M15,255.1v-10.3c0-5.5,4.5-10,10-10h450c5.5,0,10,4.5,10,10v10.3c0,5.5-4.5,10-10,10H25C19.5,265.1,15,260.7,15,255.1z\"/>\n</svg>\n "
2620
+ 'Minus': "\n <svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\" viewBox=\"0 0 500 500\">\n<path d=\"M15,255.1v-10.3c0-5.5,4.5-10,10-10h450c5.5,0,10,4.5,10,10v10.3c0,5.5-4.5,10-10,10H25C19.5,265.1,15,260.7,15,255.1z\"/>\n</svg>\n ",
2621
+ 'PlusFilled': "\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 500 500\" style=\"enable-background:new 0 0 500 500;\" xml:space=\"preserve\">\n<style type=\"text/css\">\n\t.st0{fill:#FFFFFF;}\n</style>\n<circle cx=\"249.6\" cy=\"251\" r=\"235\"/>\n<path class=\"st0\" d=\"M422.3,234.8H264.7V78.7c0-4.2-4.5-7.7-10-7.7h-10.3c-5.5,0-10,3.4-10,7.7v156.1H77.7c-4.2,0-7.7,4.5-7.7,10\n\tv10.3c0,5.6,3.4,10,7.7,10h156.7v158.2c0,4.2,4.5,7.7,10,7.7h10.3c5.5,0,9.9-3.4,10-7.7V265.1h157.6c4.2,0,7.7-4.5,7.7-10v-10.3\n\tC430,239.3,426.6,234.8,422.3,234.8z\"/>\n</svg>\n\n ",
2622
+ 'MinusFilled': "\n <?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg version=\"1.1\" id=\"Layer_1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" x=\"0px\" y=\"0px\"\n\t viewBox=\"0 0 500 500\" style=\"enable-background:new 0 0 500 500;\" xml:space=\"preserve\">\n<style type=\"text/css\">\n\t.st0{fill:#FFFFFF;}\n</style>\n<circle cx=\"250.1\" cy=\"255.4\" r=\"235\"/>\n<path class=\"st0\" d=\"M70,255.1v-10.3c0-5.5,3.4-10,7.7-10h344.7c4.2,0,7.7,4.5,7.7,10v10.3c0,5.5-3.4,10-7.7,10H77.7\n\tC73.4,265.1,70,260.7,70,255.1z\"/>\n</svg>\n\n "
2621
2623
  };
2622
2624
 
2623
2625
  var WebsyLoadingDialog = /*#__PURE__*/function () {
@@ -4221,7 +4223,10 @@ var WebsyRouter = /*#__PURE__*/function () {
4221
4223
 
4222
4224
  for (var i = 0; i < parts.length; i++) {
4223
4225
  var bits = parts[i].split('=');
4224
- output.items[bits[0]] = bits[1];
4226
+
4227
+ if (bits[0] && bits[0] !== '' && bits[1] && bits[1] !== '') {
4228
+ output.items[bits[0]] = bits[1];
4229
+ }
4225
4230
  }
4226
4231
 
4227
4232
  this.currentParams = output;
@@ -4344,17 +4349,32 @@ var WebsyRouter = /*#__PURE__*/function () {
4344
4349
  }, {
4345
4350
  key: "hideView",
4346
4351
  value: function hideView(view, group) {
4352
+ if (view === '/' || view === '') {
4353
+ view = this.options.defaultView;
4354
+ }
4355
+
4347
4356
  this.hideChildren(view, group);
4348
4357
 
4349
- if (this.previousView !== this.currentView) {
4358
+ if (this.previousView !== this.currentView || group !== this.options.defaultGroup) {
4350
4359
  this.hideTriggerItems(view, group);
4351
4360
  this.hideViewItems(view, group);
4352
4361
  this.publish('hide', [view]);
4353
- } else if (group !== this.options.defaultGroup) {
4354
- this.hideTriggerItems(view, group);
4355
- this.hideViewItems(view, group);
4356
- this.publish('hide', [view]);
4357
- }
4362
+
4363
+ if (this.options.views && this.options.views[view]) {
4364
+ this.options.views[view].components.forEach(function (c) {
4365
+ if (typeof c.instance !== 'undefined') {
4366
+ if (c.instance.close) {
4367
+ c.instance.close();
4368
+ }
4369
+ }
4370
+ });
4371
+ }
4372
+ } // else if (group !== this.options.defaultGroup) {
4373
+ // this.hideTriggerItems(view, group)
4374
+ // this.hideViewItems(view, group)
4375
+ // this.publish('hide', [view])
4376
+ // }
4377
+
4358
4378
  } // registerElements (root) {
4359
4379
  // if (root.nodeName === '#document') {
4360
4380
  // this.groups = {}
@@ -4763,6 +4783,7 @@ var WebsySearch = /*#__PURE__*/function () {
4763
4783
  // el.addEventListener('click', this.handleClick.bind(this))
4764
4784
  el.addEventListener('click', this.handleClick.bind(this));
4765
4785
  el.addEventListener('keyup', this.handleKeyUp.bind(this));
4786
+ el.addEventListener('keyup', this.handleKeyDown.bind(this));
4766
4787
  el.innerHTML = "\n <div class='websy-search-input-container'>\n ".concat(this.options.searchIcon, "\n <input id='").concat(this.elementId, "_search' class='websy-search-input' placeholder='").concat(this.options.placeholder || 'Search', "'>\n <div class='clear websy-hidden' id='").concat(this.elementId, "_clear'>\n ").concat(this.options.clearIcon, "\n </div>\n </div>\n ");
4767
4788
  } else {
4768
4789
  console.log('No element found with Id', elementId);
@@ -4778,6 +4799,16 @@ var WebsySearch = /*#__PURE__*/function () {
4778
4799
  this.options.onSearch('');
4779
4800
  }
4780
4801
  }
4802
+ }, {
4803
+ key: "handleKeyDown",
4804
+ value: function handleKeyDown(event) {
4805
+ if (event.key === 'Enter') {
4806
+ if (this.options.onSubmit) {
4807
+ this.options.onSubmit(event.target.value);
4808
+ return false;
4809
+ }
4810
+ }
4811
+ }
4781
4812
  }, {
4782
4813
  key: "handleKeyUp",
4783
4814
  value: function handleKeyUp(event) {
@@ -6433,18 +6464,22 @@ var WebsyTable3 = /*#__PURE__*/function () {
6433
6464
  data.forEach(function (row, rowIndex) {
6434
6465
  bodyHtml += "<tr class=\"websy-table-row\">";
6435
6466
  row.forEach(function (cell, cellIndex) {
6436
- if (typeof sizingColumns[cellIndex] === 'undefined') {
6467
+ var sizeIndex = cell.level || cellIndex;
6468
+
6469
+ if (typeof sizingColumns[sizeIndex] === 'undefined') {
6437
6470
  return; // need to revisit this logic
6438
6471
  }
6439
6472
 
6440
- var style = '';
6473
+ var style = "width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important; ");
6474
+ var divStyle = style;
6441
6475
 
6442
6476
  if (cell.style) {
6443
6477
  style += cell.style;
6444
6478
  }
6445
6479
 
6446
6480
  if (useWidths === true) {
6447
- style += "max-width: ".concat(sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth, "px!important;");
6481
+ style += "max-width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important;");
6482
+ divStyle += "max-width: ".concat(sizingColumns[sizeIndex].width || sizingColumns[sizeIndex].actualWidth, "px!important;");
6448
6483
  }
6449
6484
 
6450
6485
  if (cell.backgroundColor) {
@@ -6457,9 +6492,9 @@ var WebsyTable3 = /*#__PURE__*/function () {
6457
6492
 
6458
6493
  if (cell.color) {
6459
6494
  style += "color: ".concat(cell.color, "; ");
6460
- }
6495
+ } // console.log('rowspan', cell.rowspan)
6496
+
6461
6497
 
6462
- console.log('rowspan', cell.rowspan);
6463
6498
  bodyHtml += "<td \n class='websy-table-cell ".concat((cell.classes || []).join(' '), "'\n style='").concat(style, "'\n data-info='").concat(cell.value, "'\n colspan='").concat(cell.colspan || 1, "'\n rowspan='").concat(cell.rowspan || 1, "'\n data-row-index='").concat(rowIndex, "'\n data-col-index='").concat(cellIndex, "'\n "); // if (useWidths === true) {
6464
6499
  // bodyHtml += `
6465
6500
  // style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
@@ -6467,17 +6502,17 @@ var WebsyTable3 = /*#__PURE__*/function () {
6467
6502
  // `
6468
6503
  // }
6469
6504
 
6470
- bodyHtml += "\n >";
6505
+ bodyHtml += "\n ><div style='".concat(divStyle, "'>");
6471
6506
 
6472
6507
  if (cell.expandable === true) {
6473
- bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cellIndex, "'\n class='websy-table-cell-expand'\n >").concat(WebsyDesigns.Icons.Plus, "</i>");
6508
+ bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-expand'\n >").concat(WebsyDesigns.Icons.PlusFilled, "</i>");
6474
6509
  }
6475
6510
 
6476
6511
  if (cell.collapsable === true) {
6477
- bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cellIndex, "'\n class='websy-table-cell-collapse'\n >").concat(WebsyDesigns.Icons.Minus, "</i>");
6512
+ bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-collapse'\n >").concat(WebsyDesigns.Icons.MinusFilled, "</i>");
6478
6513
  }
6479
6514
 
6480
- bodyHtml += "\n ".concat(cell.value, "\n </td>");
6515
+ bodyHtml += "\n ".concat(cell.value, "\n </div></td>");
6481
6516
  });
6482
6517
  bodyHtml += "</tr>";
6483
6518
  }); // bodyHtml += `</div>`
@@ -6509,14 +6544,26 @@ var WebsyTable3 = /*#__PURE__*/function () {
6509
6544
 
6510
6545
  headerHtml += "<tr class=\"websy-table-row websy-table-header-row\">";
6511
6546
  row.forEach(function (col, colIndex) {
6512
- headerHtml += "<td \n class='websy-table-cell' \n style='".concat(col.style, "' \n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n "); // if (useWidths === true && rowIndex === this.options.columns.length - 1) {
6547
+ var style = "width: ".concat(sizingColumns[colIndex].width || sizingColumns[colIndex].actualWidth, "px!important; ");
6548
+ var divStyle = style;
6549
+
6550
+ if (useWidths === true) {
6551
+ style += "max-width: ".concat(sizingColumns[colIndex].width || sizingColumns[colIndex].actualWidth, "px!important;");
6552
+ divStyle += "max-width: ".concat(sizingColumns[colIndex].width || sizingColumns[colIndex].actualWidth, "px!important;");
6553
+ }
6554
+
6555
+ if (col.style) {
6556
+ style += col.style;
6557
+ }
6558
+
6559
+ headerHtml += "<td \n class='websy-table-cell' \n style='".concat(style, "' \n colspan='").concat(col.colspan || 1, "'\n rowspan='").concat(col.rowspan || 1, "'\n "); // if (useWidths === true && rowIndex === this.options.columns.length - 1) {
6513
6560
  // headerHtml += `
6514
6561
  // style='width: ${col.width || col.actualWidth}px'
6515
6562
  // width='${col.width || col.actualWidth}'
6516
6563
  // `
6517
6564
  // }
6518
6565
 
6519
- headerHtml += " \n >\n <div>\n ".concat(col.name, "\n ").concat(col.searchable === true ? _this38.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
6566
+ headerHtml += "><div style='".concat(divStyle, "'>").concat(col.name).concat(col.searchable === true ? _this38.buildSearchIcon(col, colIndex) : '', "</div></td>");
6520
6567
  });
6521
6568
  headerHtml += "</tr>";
6522
6569
  });
@@ -6538,7 +6585,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6538
6585
  }, {
6539
6586
  key: "buildSearchIcon",
6540
6587
  value: function buildSearchIcon(col, index) {
6541
- return "\n <div class=\"websy-table-search-icon\" data-col-id=\"".concat(col.dimId, "\" data-col-index=\"").concat(index, "\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-f</title><path d=\"M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z\" style=\"fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px\"/><line x1=\"338.29\" y1=\"338.29\" x2=\"448\" y2=\"448\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px\"/></svg>\n </div>\n ");
6588
+ return "<div class=\"websy-table-search-icon\" data-col-id=\"".concat(col.dimId, "\" data-col-index=\"").concat(index, "\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-f</title><path d=\"M221.09,64A157.09,157.09,0,1,0,378.18,221.09,157.1,157.1,0,0,0,221.09,64Z\" style=\"fill:none;stroke:#000;stroke-miterlimit:10;stroke-width:32px\"/><line x1=\"338.29\" y1=\"338.29\" x2=\"448\" y2=\"448\" style=\"fill:none;stroke:#000;stroke-linecap:round;stroke-miterlimit:10;stroke-width:32px\"/></svg>\n </div>");
6542
6589
  }
6543
6590
  }, {
6544
6591
  key: "buildTotalHtml",
@@ -6606,6 +6653,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6606
6653
  var rows = Array.from(tableEl.querySelectorAll('.websy-table-row'));
6607
6654
  var totalWidth = 0;
6608
6655
  this.sizes.scrollableWidth = this.sizes.outer.width;
6656
+ var firstNonPinnedColumnWidth = 0;
6609
6657
  rows.forEach(function (row, rowIndex) {
6610
6658
  Array.from(row.children).forEach(function (col, colIndex) {
6611
6659
  var colSize = col.getBoundingClientRect();
@@ -6618,6 +6666,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6618
6666
 
6619
6667
  _this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth = Math.min(Math.max(_this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth, colSize.width), maxWidth);
6620
6668
  _this40.options.columns[_this40.options.columns.length - 1][colIndex].cellHeight = colSize.height;
6669
+
6670
+ if (colIndex >= _this40.pinnedColumns) {
6671
+ firstNonPinnedColumnWidth = _this40.options.columns[_this40.options.columns.length - 1][colIndex].actualWidth;
6672
+ }
6621
6673
  }
6622
6674
  });
6623
6675
  });
@@ -6634,10 +6686,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6634
6686
  }).reduce(function (a, b) {
6635
6687
  return a + (b.width || b.actualWidth);
6636
6688
  }, 0);
6637
- var outerSize = outerEl.getBoundingClientRect();
6689
+ this.sizes.pinnedWidth = this.sizes.totalWidth - this.sizes.totalNonPinnedWidth; // const outerSize = outerEl.getBoundingClientRect()
6638
6690
 
6639
- if (this.sizes.totalWidth < outerSize.width) {
6640
- var equalWidth = (outerSize.width - this.sizes.totalWidth) / this.options.columns[this.options.columns.length - 1].length;
6691
+ if (this.sizes.totalWidth < this.sizes.outer.width) {
6692
+ var equalWidth = (this.sizes.outer.width - this.sizes.totalWidth) / this.options.columns[this.options.columns.length - 1].length;
6641
6693
  this.sizes.totalWidth = 0;
6642
6694
  this.sizes.totalNonPinnedWidth = 0;
6643
6695
  this.options.columns[this.options.columns.length - 1].forEach(function (c, i) {
@@ -6658,6 +6710,21 @@ var WebsyTable3 = /*#__PURE__*/function () {
6658
6710
  } // equalWidth = (outerSize.width - this.sizes.totalWidth) / (this.options.columns[this.options.columns.length - 1].length - (i + 1))
6659
6711
 
6660
6712
  });
6713
+ } // check that we have enough from for all of the pinned columns plus 1 non pinned column
6714
+
6715
+
6716
+ if (this.sizes.pinnedWidth > this.sizes.outer.width - firstNonPinnedColumnWidth) {
6717
+ this.sizes.totalWidth = 0;
6718
+ var diff = this.sizes.pinnedWidth - (this.sizes.outer.width - firstNonPinnedColumnWidth); // let colDiff = diff / this.pinnedColumns
6719
+
6720
+ for (var i = 0; i < this.options.columns[this.options.columns.length - 1].length; i++) {
6721
+ if (i < this.pinnedColumns) {
6722
+ var colDiff = this.options.columns[this.options.columns.length - 1][i].actualWidth / this.sizes.pinnedWidth * diff;
6723
+ this.options.columns[this.options.columns.length - 1][i].actualWidth -= colDiff;
6724
+ }
6725
+
6726
+ this.sizes.totalWidth += this.options.columns[this.options.columns.length - 1][i].width || this.options.columns[this.options.columns.length - 1][i].actualWidth;
6727
+ }
6661
6728
  } // take the height of the last cell as the official height for data cells
6662
6729
  // this.sizes.dataCellHeight = this.options.columns[this.options.columns.length - 1].cellHeight
6663
6730
 
@@ -6689,8 +6756,8 @@ var WebsyTable3 = /*#__PURE__*/function () {
6689
6756
 
6690
6757
  this.options.allColumns = this.options.columns.map(function (c) {
6691
6758
  return c;
6692
- });
6693
- console.log('sizes', this.sizes);
6759
+ }); // console.log('sizes', this.sizes)
6760
+
6694
6761
  return this.sizes;
6695
6762
  }
6696
6763
  }, {
@@ -6729,8 +6796,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6729
6796
  var rowIndex = +event.target.getAttribute('data-row-index');
6730
6797
 
6731
6798
  if (event.target.classList.contains('websy-table-search-icon')) {
6732
- console.log('clicked on search icon');
6733
-
6799
+ // console.log('clicked on search icon')
6734
6800
  if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
6735
6801
  this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex]);
6736
6802
  }
@@ -6759,9 +6825,8 @@ var WebsyTable3 = /*#__PURE__*/function () {
6759
6825
  this.scrollDirection = 'y';
6760
6826
  var scrollHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
6761
6827
  this.handleYStart = scrollHandleEl.offsetTop;
6762
- this.mouseYStart = event.pageY;
6763
- console.log('mouse down', this.handleYStart, this.mouseYStart);
6764
- console.log(scrollHandleEl.offsetTop);
6828
+ this.mouseYStart = event.pageY; // console.log('mouse down', this.handleYStart, this.mouseYStart)
6829
+ // console.log(scrollHandleEl.offsetTop)
6765
6830
  } else if (event.target.classList.contains('websy-scroll-handle-x')) {
6766
6831
  this.scrollDragging = true;
6767
6832
  this.scrollDirection = 'x';
@@ -6800,8 +6865,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6800
6865
  }, {
6801
6866
  key: "handleScrollWheel",
6802
6867
  value: function handleScrollWheel(event) {
6803
- event.preventDefault();
6804
- console.log('scrollwheel', event);
6868
+ event.preventDefault(); // console.log('scrollwheel', event)
6805
6869
 
6806
6870
  if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
6807
6871
  this.scrollX(Math.max(-5, Math.min(5, event.deltaX)));
@@ -6851,9 +6915,9 @@ var WebsyTable3 = /*#__PURE__*/function () {
6851
6915
  if (calcSizes === true) {
6852
6916
  var sample = this.createSample(data);
6853
6917
  this.calculateSizes(sample, data.length, (data[0] || []).length, 0);
6854
- }
6918
+ } // console.log(this.options.columns)
6919
+
6855
6920
 
6856
- console.log(this.options.columns);
6857
6921
  var tableInnerEl = document.getElementById("".concat(this.elementId, "_tableInner"));
6858
6922
 
6859
6923
  if (tableInnerEl) {
@@ -6986,8 +7050,8 @@ var WebsyTable3 = /*#__PURE__*/function () {
6986
7050
  handlePos = scrollHandleEl.offsetLeft + diff;
6987
7051
  }
6988
7052
 
6989
- var scrollableSpace = scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width;
6990
- console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width);
7053
+ var scrollableSpace = scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width; // console.log('dragging x', diff, scrollContainerEl.getBoundingClientRect().width - scrollHandleEl.getBoundingClientRect().width)
7054
+
6991
7055
  scrollHandleEl.style.left = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
6992
7056
 
6993
7057
  if (this.options.onScroll) {
@@ -6997,8 +7061,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6997
7061
  this.endCol = 0;
6998
7062
 
6999
7063
  for (var i = this.pinnedColumns; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
7000
- cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth;
7001
- console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth);
7064
+ cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth; // console.log('actualLeft', actualLeft, this.sizes.totalWidth, cumulativeWidth, cumulativeWidth + this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth)
7002
7065
 
7003
7066
  if (actualLeft < cumulativeWidth) {
7004
7067
  this.startCol = i;
@@ -7020,12 +7083,12 @@ var WebsyTable3 = /*#__PURE__*/function () {
7020
7083
  this.endCol += 1;
7021
7084
  }
7022
7085
 
7023
- if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.totalWidth) {
7086
+ if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.scrollableWidth && actualLeft > 0) {
7024
7087
  this.startCol += 1;
7025
7088
  }
7026
7089
 
7027
7090
  this.endCol = Math.max(this.startCol, this.endCol);
7028
- this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
7091
+ this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns);
7029
7092
  }
7030
7093
  }
7031
7094
  }, {
@@ -7056,12 +7119,12 @@ var WebsyTable3 = /*#__PURE__*/function () {
7056
7119
  if (typeof this.handleYStart !== 'undefined' && this.handleYStart !== null) {
7057
7120
  handlePos = this.handleYStart + diff;
7058
7121
  } else {
7059
- console.log('appending not resetting');
7122
+ // console.log('appending not resetting')
7060
7123
  handlePos = scrollHandleEl.offsetTop + diff;
7061
7124
  }
7062
7125
 
7063
- var scrollableSpace = scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height;
7064
- console.log('dragging y', diff, scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height);
7126
+ var scrollableSpace = scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height; // console.log('dragging y', (diff), scrollContainerEl.getBoundingClientRect().height - scrollHandleEl.getBoundingClientRect().height)
7127
+
7065
7128
  scrollHandleEl.style.top = Math.min(scrollableSpace, Math.max(0, handlePos)) + 'px';
7066
7129
 
7067
7130
  if (this.options.onScroll) {
@@ -7072,7 +7135,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
7072
7135
  this.startRow += 1;
7073
7136
  }
7074
7137
 
7075
- this.options.onScroll('y', this.startRow, this.endRow, this.startCol, this.endCol);
7138
+ this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns);
7076
7139
  }
7077
7140
  }
7078
7141
  }, {
@@ -7127,6 +7190,7 @@ var WebsyChart = /*#__PURE__*/function () {
7127
7190
  curveStyle: 'curveLinear',
7128
7191
  lineWidth: 2,
7129
7192
  forceZero: true,
7193
+ grouping: 'grouped',
7130
7194
  fontSize: 14,
7131
7195
  symbolSize: 20,
7132
7196
  showTrackingLine: true,
@@ -7412,9 +7476,18 @@ var WebsyChart = /*#__PURE__*/function () {
7412
7476
  };
7413
7477
 
7414
7478
  if (xPoint > this.plotWidth / 2) {
7415
- posOptions.left = xPoint - this.options.tooltipWidth - 15;
7479
+ posOptions.left = xPoint - this.options.tooltipWidth + this.options.margin.left + this.options.margin.axisLeft + 15;
7480
+
7481
+ if (this.options.data[xData].scale !== 'Time') {
7482
+ // posOptions.left -= (this[xAxis].bandwidth())
7483
+ posOptions.left += 10;
7484
+ }
7416
7485
  } else {
7417
7486
  posOptions.left = xPoint + this.options.margin.left + this.options.margin.axisLeft + 15;
7487
+
7488
+ if (this.options.data[xData].scale !== 'Time') {
7489
+ posOptions.left += this[xAxis].bandwidth() / 2;
7490
+ }
7418
7491
  }
7419
7492
 
7420
7493
  posOptions.top = this.options.margin.top + this.options.margin.axisTop;
@@ -7567,9 +7640,11 @@ var WebsyChart = /*#__PURE__*/function () {
7567
7640
 
7568
7641
  if (this.options.legendPosition === 'top' || this.options.legendPosition === 'bottom') {
7569
7642
  this.legendArea.style('width', '100%');
7643
+ this.legend.options.align = 'center';
7570
7644
  }
7571
7645
 
7572
7646
  if (this.options.legendPosition === 'left' || this.options.legendPosition === 'right') {
7647
+ this.legend.options.align = 'left';
7573
7648
  this.legendArea.style('height', '100%');
7574
7649
  this.legendArea.style('width', this.legend.testWidth(d3.max(legendData.map(function (d) {
7575
7650
  return d.value;
@@ -7608,6 +7683,7 @@ var WebsyChart = /*#__PURE__*/function () {
7608
7683
  this.longestLeft = 0;
7609
7684
  this.longestRight = 0;
7610
7685
  this.longestBottom = 0;
7686
+ var firstBottom = '';
7611
7687
 
7612
7688
  if (this.options.data.bottom && this.options.data.bottom.data && typeof this.options.data.bottom.max === 'undefined') {
7613
7689
  // this.options.data.bottom.max = this.options.data.bottom.data.reduce((a, b) => a.length > b.value.length ? a : b.value, '')
@@ -7621,8 +7697,17 @@ var WebsyChart = /*#__PURE__*/function () {
7621
7697
 
7622
7698
  if (this.options.data.bottom.formatter) {
7623
7699
  this.longestBottom = this.options.data.bottom.formatter(this.options.data.bottom.max).toString();
7700
+ firstBottom = this.longestBottom;
7624
7701
  } else {
7625
- this.longestBottom = '01/01/2000';
7702
+ if (this.options.data.bottom.scale === 'Time') {
7703
+ this.longestBottom = '01/01/2000';
7704
+ firstBottom = '01/01/2000';
7705
+ } else {
7706
+ this.longestBottom = this.options.data.bottom.data.reduce(function (a, b) {
7707
+ return a.length > b.value.length ? a : b.value;
7708
+ }, '');
7709
+ firstBottom = this.options.data.bottom.data[0].value;
7710
+ }
7626
7711
  }
7627
7712
  }
7628
7713
 
@@ -7671,7 +7756,23 @@ var WebsyChart = /*#__PURE__*/function () {
7671
7756
  var longestLeftBounds = WebsyUtils.measureText(this.longestLeft, 0, this.options.data.left && this.options.data.left.fontSize || this.options.fontSize);
7672
7757
  var longestRightBounds = WebsyUtils.measureText(this.longestRight, 0, this.options.data.right && this.options.data.right.fontSize || this.options.fontSize);
7673
7758
  var longestBottomBounds = WebsyUtils.measureText(this.longestBottom, this.options.data.bottom && this.options.data.bottom.rotate || 0, this.options.data.bottom && this.options.data.bottom.fontSize || this.options.fontSize);
7674
- this.options.margin.axisLeft = longestLeftBounds.width;
7759
+ var firstBottomWidth = 0;
7760
+
7761
+ if (this.options.orientation === 'vertical') {
7762
+ firstBottomWidth = WebsyUtils.measureText(firstBottom, this.options.data.bottom && this.options.data.bottom.rotate || 0, this.options.data.bottom && this.options.data.bottom.fontSize || this.options.fontSize).width;
7763
+
7764
+ if (Math.abs(this.options.data.bottom && this.options.data.bottom.rotate || 0) !== 90) {
7765
+ firstBottomWidth = firstBottomWidth / 2;
7766
+ } else if (Math.abs(this.options.data.bottom && this.options.data.bottom.rotate || 0) === 90) {
7767
+ firstBottomWidth = 0;
7768
+ }
7769
+
7770
+ if (this.options.data.bottom.scale !== 'Time') {
7771
+ firstBottom = Math.max(0, firstBottomWidth);
7772
+ }
7773
+ }
7774
+
7775
+ this.options.margin.axisLeft = Math.max(longestLeftBounds.width, firstBottomWidth);
7675
7776
  this.options.margin.axisRight = longestRightBounds.width;
7676
7777
  this.options.margin.axisBottom = longestBottomBounds.height + 10;
7677
7778
  this.options.margin.axisTop = 0; // adjust axis margins based on title options
@@ -7855,7 +7956,7 @@ var WebsyChart = /*#__PURE__*/function () {
7855
7956
 
7856
7957
  if (this.options.data.left.titlePosition === 1) {
7857
7958
  // put the title vertically on the left
7858
- var t = this.leftAxisLabel.append('text').attr('class', 'title').attr('x', 1 - this.plotHeight / 2).attr('y', 5).attr('font-size', this.options.data.left.titleFontSize || 10).attr('fill', this.options.data.left.titleColor || '#888888').attr('text-anchor', 'middle').style('transform', 'rotate(-90deg)').text(this.options.data.left.title || '');
7959
+ var t = this.leftAxisLabel.append('text').attr('class', 'title').attr('x', 1 - this.plotHeight / 2).attr('y', (this.options.data.left.titleFontSize || 10) / 2 + 2).attr('font-size', this.options.data.left.titleFontSize || 10).attr('fill', this.options.data.left.titleColor || '#888888').attr('text-anchor', 'middle').style('transform', 'rotate(-90deg)').text(this.options.data.left.title || '');
7859
7960
 
7860
7961
  if (rightDomain.length > 0) {
7861
7962
  // we have 2 axis so we can treat the title like a legend
@@ -7969,36 +8070,39 @@ var WebsyChart = /*#__PURE__*/function () {
7969
8070
  key: "renderbar",
7970
8071
  value: function renderbar(series, index) {
7971
8072
  /* global series index d3 */
7972
- var xAxis = 'bottomAxis';
7973
- var yAxis = 'leftAxis';
8073
+ var xAxis = 'bottom';
8074
+ var yAxis = 'left';
7974
8075
  var bars = this.barLayer.selectAll(".bar_".concat(series.key)).data(series.data);
7975
8076
  var acummulativeY = new Array(this.options.data.series.length).fill(0);
7976
8077
 
7977
8078
  if (this.options.orientation === 'horizontal') {
7978
- xAxis = 'leftAxis';
7979
- yAxis = 'bottomAxis';
8079
+ xAxis = 'left';
8080
+ yAxis = 'bottom';
7980
8081
  }
7981
8082
 
7982
- var barWidth = this[xAxis].bandwidth();
7983
-
7984
- if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
7985
- barWidth = barWidth / this.options.data.series.length - 4;
7986
- }
8083
+ var barWidth = this["".concat(xAxis, "Axis")].bandwidth();
8084
+ var groupedBarWidth = (barWidth - 10) / this.options.data.series.length; // if (this.options.data.series.length > 1 && this.options.grouping === 'grouped') {
8085
+ // barWidth = barWidth / this.options.data.series.length - 4
8086
+ // }
7987
8087
 
7988
8088
  function getBarHeight(d, i) {
7989
8089
  if (this.options.orientation === 'horizontal') {
7990
8090
  return barWidth;
7991
8091
  } else {
7992
- return this[yAxis](d.y.value);
8092
+ return this["".concat(yAxis, "Axis")](d.y.value);
7993
8093
  }
7994
8094
  }
7995
8095
 
7996
8096
  function getBarWidth(d, i) {
7997
8097
  if (this.options.orientation === 'horizontal') {
7998
- var width = this[yAxis](d.y.value);
8098
+ var width = this["".concat(yAxis, "Axis")](d.y.value);
7999
8099
  acummulativeY[d.y.index] += width;
8000
8100
  return width;
8001
8101
  } else {
8102
+ if (this.options.grouping === 'grouped') {
8103
+ return groupedBarWidth;
8104
+ }
8105
+
8002
8106
  return barWidth;
8003
8107
  }
8004
8108
  }
@@ -8006,15 +8110,19 @@ var WebsyChart = /*#__PURE__*/function () {
8006
8110
  function getBarX(d, i) {
8007
8111
  if (this.options.orientation === 'horizontal') {
8008
8112
  if (this.options.grouping === 'stacked') {
8009
- return this[yAxis](d.y.accumulative);
8113
+ return this["".concat(yAxis, "Axis")](d.y.accumulative);
8010
8114
  } else {
8011
8115
  return 0;
8012
8116
  }
8013
8117
  } else {
8014
- if (this.options.grouping !== 'grouped') {
8015
- return this[xAxis](this.parseX(d.x.value));
8118
+ var adjustment = this.options.data[xAxis].scale === 'Time' ? 0 : this["".concat(xAxis, "Axis")].bandwidth() / 2;
8119
+
8120
+ if (this.options.grouping === 'grouped') {
8121
+ var barAdjustment = groupedBarWidth * index + 5; // + (index > 0 ? 4 : 0)
8122
+
8123
+ return this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + barAdjustment;
8016
8124
  } else {
8017
- return this[xAxis](this.parseX(d.x.value)) + i * barWidth;
8125
+ return this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + i * barWidth + adjustment;
8018
8126
  }
8019
8127
  }
8020
8128
  }
@@ -8022,15 +8130,15 @@ var WebsyChart = /*#__PURE__*/function () {
8022
8130
  function getBarY(d, i) {
8023
8131
  if (this.options.orientation === 'horizontal') {
8024
8132
  if (this.options.grouping !== 'grouped') {
8025
- return this[xAxis](this.parseX(d.x.value));
8133
+ return this["".concat(xAxis, "Axis")](this.parseX(d.x.value));
8026
8134
  } else {
8027
- return this[xAxis](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
8135
+ return this["".concat(xAxis, "Axis")](this.parseX(d.x.value)) + (d.y.index || i) * barWidth;
8028
8136
  }
8029
8137
  } else {
8030
8138
  if (this.options.grouping === 'stacked') {
8031
- return this[yAxis](d.y.accumulative);
8139
+ return this["".concat(yAxis, "Axis")](d.y.accumulative);
8032
8140
  } else {
8033
- return 0;
8141
+ return this.plotHeight - getBarHeight.call(this, d, i);
8034
8142
  }
8035
8143
  }
8036
8144
  }
@@ -8163,18 +8271,19 @@ var WebsyChart = /*#__PURE__*/function () {
8163
8271
  /* global series index d3 */
8164
8272
  var drawLine = function drawLine(xAxis, yAxis, curveStyle) {
8165
8273
  return d3.line().x(function (d) {
8166
- return _this46[xAxis](_this46.parseX(d.x.value));
8274
+ var adjustment = _this46.options.data[xAxis].scale === 'Time' ? 0 : _this46["".concat(xAxis, "Axis")].bandwidth() / 2;
8275
+ return _this46["".concat(xAxis, "Axis")](_this46.parseX(d.x.value)) + adjustment;
8167
8276
  }).y(function (d) {
8168
- return _this46[yAxis](isNaN(d.y.value) ? 0 : d.y.value);
8277
+ return _this46["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value);
8169
8278
  }).curve(d3[curveStyle || _this46.options.curveStyle]);
8170
8279
  };
8171
8280
 
8172
- var xAxis = 'bottomAxis';
8173
- var yAxis = series.axis === 'secondary' ? 'rightAxis' : 'leftAxis';
8281
+ var xAxis = 'bottom';
8282
+ var yAxis = series.axis === 'secondary' ? 'right' : 'left';
8174
8283
 
8175
8284
  if (this.options.orienation === 'horizontal') {
8176
- xAxis = series.axis === 'secondary' ? 'rightAxis' : 'leftAxis';
8177
- yAxis = 'bottomAxis';
8285
+ xAxis = series.axis === 'secondary' ? 'right' : 'left';
8286
+ yAxis = 'bottom';
8178
8287
  }
8179
8288
 
8180
8289
  var lines = this.lineLayer.selectAll(".line_".concat(series.key)).data([series.data]); // Exit