@websy/websy-designs 1.9.12 → 1.9.14

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.
@@ -1617,7 +1617,20 @@ class WebsyDropdown {
1617
1617
  const maskEl = document.getElementById(`${this.elementId}_mask`)
1618
1618
  const contentEl = document.getElementById(`${this.elementId}_content`)
1619
1619
  const scrollEl = document.getElementById(`${this.elementId}_itemsContainer`)
1620
- const actionEl = document.getElementById(`${this.elementId}_actionContainer`)
1620
+ const actionEl = document.getElementById(`${this.elementId}_actionContainer`)
1621
+ const headerEl = document.getElementById(`${this.elementId}_header`)
1622
+ const headerPos = WebsyUtils.getElementPos(headerEl)
1623
+ const contentPos = WebsyUtils.getElementPos(contentEl)
1624
+ if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1625
+ contentEl.style.right = 'unset'
1626
+ if (headerPos.bottom + contentPos.height > window.innerHeight) {
1627
+ // contentEl.classList.add('on-top')
1628
+ contentEl.style.bottom = 'unset'
1629
+ }
1630
+ else {
1631
+ contentEl.style.top = 'unset'
1632
+ }
1633
+ }
1621
1634
  if (actionEl) {
1622
1635
  actionEl.classList.remove('active')
1623
1636
  }
@@ -1641,7 +1654,7 @@ class WebsyDropdown {
1641
1654
  return
1642
1655
  }
1643
1656
  if (event.target.classList.contains('websy-dropdown-header')) {
1644
- this.open()
1657
+ this.open(event)
1645
1658
  }
1646
1659
  else if (event.target.classList.contains('websy-dropdown-mask')) {
1647
1660
  this.close()
@@ -1756,17 +1769,27 @@ class WebsyDropdown {
1756
1769
  }
1757
1770
  }
1758
1771
  }
1759
- open (options, override = false) {
1772
+ open (event, override = false) {
1760
1773
  const maskEl = document.getElementById(`${this.elementId}_mask`)
1761
1774
  const contentEl = document.getElementById(`${this.elementId}_content`)
1762
- const el = document.getElementById(this.elementId)
1763
- if (el) {
1764
- el.style.zIndex = 999
1765
- }
1775
+ const headerEl = document.getElementById(`${this.elementId}_header`)
1766
1776
  maskEl.classList.add('active')
1767
1777
  contentEl.classList.add('active')
1768
- if (WebsyUtils.getElementPos(contentEl).bottom > window.innerHeight) {
1769
- contentEl.classList.add('on-top')
1778
+ const headerPos = WebsyUtils.getElementPos(headerEl)
1779
+ const contentPos = WebsyUtils.getElementPos(contentEl)
1780
+ if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1781
+ contentEl.style.right = `calc(100vw - ${headerPos.right}px)`
1782
+ if (headerPos.bottom + contentPos.height > window.innerHeight) {
1783
+ // contentEl.classList.add('on-top')
1784
+ contentEl.style.bottom = `calc(100vh - ${headerPos.top}px)`
1785
+ }
1786
+ else {
1787
+ contentEl.style.top = headerPos.bottom + 'px'
1788
+ }
1789
+ }
1790
+ else if (this.options.style === 'plain' && headerPos.width === 0 && headerPos.height === 0) {
1791
+ const targetPos = WebsyUtils.getElementPos(event.target)
1792
+ contentEl.style.right = `calc(100vw - ${targetPos.right}px)`
1770
1793
  }
1771
1794
  if (this.options.disableSearch !== true) {
1772
1795
  const searchEl = document.getElementById(`${this.elementId}_search`)
@@ -5523,7 +5546,9 @@ const WebsyUtils = {
5523
5546
  top: rect.top + scrollTop,
5524
5547
  left: rect.left + scrollLeft,
5525
5548
  bottom: rect.top + scrollTop + el.clientHeight,
5526
- right: rect.left + scrollLeft + el.clientWidth
5549
+ right: rect.left + scrollLeft + el.clientWidth,
5550
+ width: rect.width,
5551
+ height: rect.height
5527
5552
  }
5528
5553
  },
5529
5554
  getLightDark: (backgroundColor, darkColor = '#000000', lightColor = '#ffffff') => {
@@ -6694,7 +6719,8 @@ class WebsyTable3 {
6694
6719
  disableInternalLoader: false,
6695
6720
  disableTouch: false,
6696
6721
  scrollWidth: 10,
6697
- touchScrollWidth: 30
6722
+ touchScrollWidth: 30,
6723
+ autoFitColumns: true
6698
6724
  }
6699
6725
  this.options = Object.assign({}, DEFAULTS, options)
6700
6726
  this.isTouchDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
@@ -6843,7 +6869,7 @@ class WebsyTable3 {
6843
6869
  row.forEach((cell, cellIndex) => {
6844
6870
  let sizeIndex = cell.level || cellIndex
6845
6871
  let colIndex = cell.index || cellIndex
6846
- if (typeof sizingColumns[sizeIndex] === 'undefined' || sizingColumns[sizeIndex].show === false) {
6872
+ if (typeof sizingColumns[sizeIndex] === 'undefined' || this.options.columns[this.options.columns.length - 1][colIndex].show === false) {
6847
6873
  return // need to revisit this logic
6848
6874
  }
6849
6875
  let style = ''
@@ -7072,7 +7098,7 @@ class WebsyTable3 {
7072
7098
  maxWidth = this.options.maxColWidth
7073
7099
  }
7074
7100
  else if (this.options.maxColWidth.indexOf('%') !== -1) {
7075
- maxWidth = this.sizes.outer.width * (+(this.options.maxColWidth.replace('%', '')) / 100)
7101
+ maxWidth = this.sizes.table.width * (+(this.options.maxColWidth.replace('%', '')) / 100)
7076
7102
  }
7077
7103
  else if (this.options.maxColWidth.indexOf('px') !== -1) {
7078
7104
  maxWidth = +this.options.maxColWidth.replace('px', '')
@@ -7085,7 +7111,7 @@ class WebsyTable3 {
7085
7111
  this.sizes.total = footerEl.getBoundingClientRect()
7086
7112
  const rows = Array.from(tableEl.querySelectorAll('.websy-table-row'))
7087
7113
  let totalWidth = 0
7088
- this.sizes.scrollableWidth = this.sizes.outer.width
7114
+ this.sizes.scrollableWidth = this.sizes.table.width
7089
7115
  let firstNonPinnedColumnWidth = 0
7090
7116
  let columnsForSizing = this.options.columns[this.options.columns.length - 1].filter(c => c.show !== false)
7091
7117
  rows.forEach((row, rowIndex) => {
@@ -7094,8 +7120,10 @@ class WebsyTable3 {
7094
7120
  this.sizes.cellHeight = colSize.height
7095
7121
  if (columnsForSizing[colIndex]) {
7096
7122
  if (!columnsForSizing[colIndex].actualWidth) {
7123
+ columnsForSizing[colIndex].potentialWidth = 0
7097
7124
  columnsForSizing[colIndex].actualWidth = 0
7098
7125
  }
7126
+ columnsForSizing[colIndex].potentialWidth = Math.max(columnsForSizing[colIndex].potentialWidth, colSize.width)
7099
7127
  columnsForSizing[colIndex].actualWidth = Math.min(Math.max(columnsForSizing[colIndex].actualWidth, colSize.width), maxWidth)
7100
7128
  // if (columnsForSizing[colIndex].width) {
7101
7129
  // columnsForSizing[colIndex].actualWidth = columnsForSizing[colIndex].width
@@ -7115,19 +7143,53 @@ class WebsyTable3 {
7115
7143
  this.sizes.totalWidth = columnsForSizing.reduce((a, b) => a + (b.width || b.actualWidth), 0)
7116
7144
  this.sizes.totalNonPinnedWidth = columnsForSizing.filter((c, i) => i >= this.pinnedColumns).reduce((a, b) => a + (b.width || b.actualWidth), 0)
7117
7145
  this.sizes.pinnedWidth = this.sizes.totalWidth - this.sizes.totalNonPinnedWidth
7118
- // const outerSize = outerEl.getBoundingClientRect()
7119
- if (this.sizes.totalWidth < this.sizes.outer.width) {
7120
- let equalWidth = (this.sizes.outer.width - this.sizes.totalWidth) / columnsForSizing.length
7146
+ // const outerSize = outerEl.getBoundingClientRect()
7147
+ if (this.sizes.totalWidth < this.sizes.table.width) {
7148
+ let requiredSpace = 0
7149
+ let availableSpace = (this.sizes.table.width - this.sizes.totalWidth)
7150
+ columnsForSizing.forEach(c => {
7151
+ c.shouldGrow = true
7152
+ if (this.options.autoFitColumns === false) {
7153
+ c.shouldGrow = false
7154
+ if (c.potentialWidth > c.actualWidth) {
7155
+ c.shouldGrow = true
7156
+ c.growDiff = c.potentialWidth - c.actualWidth
7157
+ c.growDiffPerc = (c.potentialWidth - c.actualWidth) / availableSpace
7158
+ requiredSpace += c.growDiff
7159
+ }
7160
+ }
7161
+ })
7162
+ let equalWidth = (this.sizes.table.width - this.sizes.totalWidth) / columnsForSizing.filter(c => c.shouldGrow).length
7121
7163
  this.sizes.totalWidth = 0
7122
7164
  this.sizes.totalNonPinnedWidth = 0
7123
7165
  columnsForSizing.forEach((c, i) => {
7124
7166
  // if (!c.width) {
7125
7167
  // if (c.actualWidth < equalWidth) {
7126
7168
  // adjust the width
7127
- if (c.width) {
7128
- c.width += equalWidth
7169
+ if (this.options.autoFitColumns === true) {
7170
+ if (c.width) {
7171
+ c.width += equalWidth
7172
+ }
7173
+ c.actualWidth += equalWidth
7174
+ }
7175
+ else {
7176
+ if (requiredSpace > 0 && requiredSpace <= availableSpace) {
7177
+ if (c.shouldGrow) {
7178
+ if (c.width) {
7179
+ c.width += c.growDiff
7180
+ }
7181
+ c.actualWidth += c.growDiff
7182
+ }
7183
+ }
7184
+ else {
7185
+ if (c.shouldGrow) {
7186
+ if (c.width) {
7187
+ c.width += availableSpace * (c.growDiff / requiredSpace)
7188
+ }
7189
+ c.actualWidth += availableSpace * (c.growDiff / requiredSpace)
7190
+ }
7191
+ }
7129
7192
  }
7130
- c.actualWidth += equalWidth
7131
7193
  // }
7132
7194
  // }
7133
7195
  this.sizes.totalWidth += c.width || c.actualWidth
@@ -7138,9 +7200,9 @@ class WebsyTable3 {
7138
7200
  })
7139
7201
  }
7140
7202
  // check that we have enough from for all of the pinned columns plus 1 non pinned column
7141
- if (this.sizes.pinnedWidth > (this.sizes.outer.width - firstNonPinnedColumnWidth)) {
7203
+ if (this.sizes.pinnedWidth > (this.sizes.table.width - firstNonPinnedColumnWidth)) {
7142
7204
  this.sizes.totalWidth = 0
7143
- let diff = this.sizes.pinnedWidth - (this.sizes.outer.width - firstNonPinnedColumnWidth)
7205
+ let diff = this.sizes.pinnedWidth - (this.sizes.table.width - firstNonPinnedColumnWidth)
7144
7206
  let oldPinnedWidth = this.sizes.pinnedWidth
7145
7207
  this.sizes.pinnedWidth = 0
7146
7208
  // let colDiff = diff / this.pinnedColumns
@@ -7178,7 +7240,7 @@ class WebsyTable3 {
7178
7240
  else {
7179
7241
  this.vScrollRequired = false
7180
7242
  }
7181
- if (this.sizes.totalWidth > this.sizes.outer.width) {
7243
+ if (this.sizes.totalWidth.toFixed(3) > this.sizes.table.width.toFixed(3)) {
7182
7244
  this.hScrollRequired = true
7183
7245
  }
7184
7246
  else {
@@ -7543,7 +7605,6 @@ class WebsyTable3 {
7543
7605
  let vHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
7544
7606
  if (this.vScrollRequired === true) {
7545
7607
  vScrollEl.style.top = `${this.sizes.header.height + this.sizes.total.height}px`
7546
- // vScrollEl.style.left = `${this.sizes.outer.width - (this.options.isTouchDevice ? this.options.touchScrollWidth : this.options.scrollWidth)}px`
7547
7608
  vScrollEl.style.height = `${this.sizes.bodyHeight}px`
7548
7609
  if (this.isTouchDevice === true) {
7549
7610
  vScrollEl.style.visibility = `unset`
@@ -7656,7 +7717,8 @@ class WebsyTable3 {
7656
7717
  }
7657
7718
  }
7658
7719
  }
7659
- cumulativeWidth = 0
7720
+ cumulativeWidth = 0
7721
+ let lastColWidth = 0
7660
7722
  for (let i = this.startCol; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
7661
7723
  if (this.options.allColumns[this.options.allColumns.length - 1][i].show !== false) {
7662
7724
  cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
@@ -7671,9 +7733,22 @@ class WebsyTable3 {
7671
7733
  if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.scrollableWidth && actualLeft > 0) {
7672
7734
  this.startCol += 1
7673
7735
  }
7674
- if (scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >= scrollContainerEl.offsetWidth) {
7675
- this.startCol += 1
7676
- this.endCol += 1
7736
+ if (
7737
+ scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >=
7738
+ scrollContainerEl.offsetWidth - lastColWidth
7739
+ ) {
7740
+ this.endCol = this.options.allColumns[this.options.allColumns.length - 1].length - 1
7741
+ this.startCol = this.endCol + 1
7742
+ // one last measurement
7743
+ let finalAcc = 0
7744
+ for (let i = this.endCol; i > -1; i--) {
7745
+ if (this.options.allColumns[this.options.allColumns.length - 1][i].show !== false) {
7746
+ finalAcc += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
7747
+ if (finalAcc < this.sizes.scrollableWidth) {
7748
+ this.startCol--
7749
+ }
7750
+ }
7751
+ }
7677
7752
  }
7678
7753
  this.endCol = Math.max(this.startCol, this.endCol)
7679
7754
  this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns)
@@ -9786,6 +9861,14 @@ symbols
9786
9861
  if (this.options.data[xAxis].scale === 'Time') {
9787
9862
  xPos = this[`${xAxis}Axis`](this.parseX(d.x.value))
9788
9863
  }
9864
+ else {
9865
+ let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
9866
+ let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
9867
+ if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
9868
+ xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
9869
+ }
9870
+ // return xPos
9871
+ }
9789
9872
  // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9790
9873
  return `translate(${xPos}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9791
9874
  }
@@ -9812,6 +9895,14 @@ symbols.enter()
9812
9895
  if (this.options.data[xAxis].scale === 'Time') {
9813
9896
  xPos = this[`${xAxis}Axis`](this.parseX(d.x.value))
9814
9897
  }
9898
+ else {
9899
+ let xIndex = this[xAxis + 'Axis'].domain().indexOf(d.x.value)
9900
+ let xPos = this[`custom${xAxis.toInitialCaps()}Range`][xIndex]
9901
+ if (this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1]) {
9902
+ xPos = xPos + ((this[`custom${xAxis.toInitialCaps()}Range`][xIndex + 1] - xPos) / 2)
9903
+ }
9904
+ // return xPos
9905
+ }
9815
9906
  // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9816
9907
  return `translate(${xPos}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9817
9908
  }
@@ -10490,8 +10581,12 @@ class WebsyKPI {
10490
10581
  constructor (elementId, options) {
10491
10582
  const DEFAULTS = {
10492
10583
  tooltip: {},
10493
- label: {},
10494
- value: {}
10584
+ label: {
10585
+ value: ''
10586
+ },
10587
+ value: {
10588
+ value: ''
10589
+ }
10495
10590
  }
10496
10591
  this.elementId = elementId
10497
10592
  this.options = Object.assign({}, DEFAULTS, options)
@@ -10527,7 +10622,7 @@ class WebsyKPI {
10527
10622
  html += `
10528
10623
  <div class="websy-kpi-info">
10529
10624
  <div class="websy-kpi-label ${this.options.label.classes.join(' ') || ''}">
10530
- ${this.options.label.value || ''}
10625
+ ${(this.options.label || {}).value || ''}
10531
10626
  `
10532
10627
  if (this.options.tooltip && this.options.tooltip.value) {
10533
10628
  html += `
@@ -1560,6 +1560,18 @@ var WebsyDropdown = /*#__PURE__*/function () {
1560
1560
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
1561
1561
  var scrollEl = document.getElementById("".concat(this.elementId, "_itemsContainer"));
1562
1562
  var actionEl = document.getElementById("".concat(this.elementId, "_actionContainer"));
1563
+ var headerEl = document.getElementById("".concat(this.elementId, "_header"));
1564
+ var headerPos = WebsyUtils.getElementPos(headerEl);
1565
+ var contentPos = WebsyUtils.getElementPos(contentEl);
1566
+ if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1567
+ contentEl.style.right = 'unset';
1568
+ if (headerPos.bottom + contentPos.height > window.innerHeight) {
1569
+ // contentEl.classList.add('on-top')
1570
+ contentEl.style.bottom = 'unset';
1571
+ } else {
1572
+ contentEl.style.top = 'unset';
1573
+ }
1574
+ }
1563
1575
  if (actionEl) {
1564
1576
  actionEl.classList.remove('active');
1565
1577
  }
@@ -1585,7 +1597,7 @@ var WebsyDropdown = /*#__PURE__*/function () {
1585
1597
  return;
1586
1598
  }
1587
1599
  if (event.target.classList.contains('websy-dropdown-header')) {
1588
- this.open();
1600
+ this.open(event);
1589
1601
  } else if (event.target.classList.contains('websy-dropdown-mask')) {
1590
1602
  this.close();
1591
1603
  } else if (event.target.classList.contains('websy-dropdown-item')) {
@@ -1699,18 +1711,26 @@ var WebsyDropdown = /*#__PURE__*/function () {
1699
1711
  }
1700
1712
  }, {
1701
1713
  key: "open",
1702
- value: function open(options) {
1714
+ value: function open(event) {
1703
1715
  var override = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1704
1716
  var maskEl = document.getElementById("".concat(this.elementId, "_mask"));
1705
1717
  var contentEl = document.getElementById("".concat(this.elementId, "_content"));
1706
- var el = document.getElementById(this.elementId);
1707
- if (el) {
1708
- el.style.zIndex = 999;
1709
- }
1718
+ var headerEl = document.getElementById("".concat(this.elementId, "_header"));
1710
1719
  maskEl.classList.add('active');
1711
1720
  contentEl.classList.add('active');
1712
- if (WebsyUtils.getElementPos(contentEl).bottom > window.innerHeight) {
1713
- contentEl.classList.add('on-top');
1721
+ var headerPos = WebsyUtils.getElementPos(headerEl);
1722
+ var contentPos = WebsyUtils.getElementPos(contentEl);
1723
+ if (this.options.style === 'plain' && headerPos.width > 0 && headerPos.height > 0) {
1724
+ contentEl.style.right = "calc(100vw - ".concat(headerPos.right, "px)");
1725
+ if (headerPos.bottom + contentPos.height > window.innerHeight) {
1726
+ // contentEl.classList.add('on-top')
1727
+ contentEl.style.bottom = "calc(100vh - ".concat(headerPos.top, "px)");
1728
+ } else {
1729
+ contentEl.style.top = headerPos.bottom + 'px';
1730
+ }
1731
+ } else if (this.options.style === 'plain' && headerPos.width === 0 && headerPos.height === 0) {
1732
+ var targetPos = WebsyUtils.getElementPos(event.target);
1733
+ contentEl.style.right = "calc(100vw - ".concat(targetPos.right, "px)");
1714
1734
  }
1715
1735
  if (this.options.disableSearch !== true) {
1716
1736
  var searchEl = document.getElementById("".concat(this.elementId, "_search"));
@@ -5338,7 +5358,9 @@ var WebsyUtils = {
5338
5358
  top: rect.top + scrollTop,
5339
5359
  left: rect.left + scrollLeft,
5340
5360
  bottom: rect.top + scrollTop + el.clientHeight,
5341
- right: rect.left + scrollLeft + el.clientWidth
5361
+ right: rect.left + scrollLeft + el.clientWidth,
5362
+ width: rect.width,
5363
+ height: rect.height
5342
5364
  };
5343
5365
  },
5344
5366
  getLightDark: function getLightDark(backgroundColor) {
@@ -6392,7 +6414,8 @@ var WebsyTable3 = /*#__PURE__*/function () {
6392
6414
  disableInternalLoader: false,
6393
6415
  disableTouch: false,
6394
6416
  scrollWidth: 10,
6395
- touchScrollWidth: 30
6417
+ touchScrollWidth: 30,
6418
+ autoFitColumns: true
6396
6419
  };
6397
6420
  this.options = _extends({}, DEFAULTS, options);
6398
6421
  this.isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
@@ -6515,7 +6538,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6515
6538
  row.forEach(function (cell, cellIndex) {
6516
6539
  var sizeIndex = cell.level || cellIndex;
6517
6540
  var colIndex = cell.index || cellIndex;
6518
- if (typeof sizingColumns[sizeIndex] === 'undefined' || sizingColumns[sizeIndex].show === false) {
6541
+ if (typeof sizingColumns[sizeIndex] === 'undefined' || _this43.options.columns[_this43.options.columns.length - 1][colIndex].show === false) {
6519
6542
  return; // need to revisit this logic
6520
6543
  }
6521
6544
 
@@ -6706,7 +6729,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6706
6729
  if (typeof this.options.maxColWidth === 'number') {
6707
6730
  maxWidth = this.options.maxColWidth;
6708
6731
  } else if (this.options.maxColWidth.indexOf('%') !== -1) {
6709
- maxWidth = this.sizes.outer.width * (+this.options.maxColWidth.replace('%', '') / 100);
6732
+ maxWidth = this.sizes.table.width * (+this.options.maxColWidth.replace('%', '') / 100);
6710
6733
  } else if (this.options.maxColWidth.indexOf('px') !== -1) {
6711
6734
  maxWidth = +this.options.maxColWidth.replace('px', '');
6712
6735
  }
@@ -6718,7 +6741,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6718
6741
  this.sizes.total = footerEl.getBoundingClientRect();
6719
6742
  var rows = Array.from(tableEl.querySelectorAll('.websy-table-row'));
6720
6743
  var totalWidth = 0;
6721
- this.sizes.scrollableWidth = this.sizes.outer.width;
6744
+ this.sizes.scrollableWidth = this.sizes.table.width;
6722
6745
  var firstNonPinnedColumnWidth = 0;
6723
6746
  var columnsForSizing = this.options.columns[this.options.columns.length - 1].filter(function (c) {
6724
6747
  return c.show !== false;
@@ -6729,8 +6752,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6729
6752
  _this46.sizes.cellHeight = colSize.height;
6730
6753
  if (columnsForSizing[colIndex]) {
6731
6754
  if (!columnsForSizing[colIndex].actualWidth) {
6755
+ columnsForSizing[colIndex].potentialWidth = 0;
6732
6756
  columnsForSizing[colIndex].actualWidth = 0;
6733
6757
  }
6758
+ columnsForSizing[colIndex].potentialWidth = Math.max(columnsForSizing[colIndex].potentialWidth, colSize.width);
6734
6759
  columnsForSizing[colIndex].actualWidth = Math.min(Math.max(columnsForSizing[colIndex].actualWidth, colSize.width), maxWidth);
6735
6760
  // if (columnsForSizing[colIndex].width) {
6736
6761
  // columnsForSizing[colIndex].actualWidth = columnsForSizing[colIndex].width
@@ -6756,19 +6781,53 @@ var WebsyTable3 = /*#__PURE__*/function () {
6756
6781
  return a + (b.width || b.actualWidth);
6757
6782
  }, 0);
6758
6783
  this.sizes.pinnedWidth = this.sizes.totalWidth - this.sizes.totalNonPinnedWidth;
6759
- // const outerSize = outerEl.getBoundingClientRect()
6760
- if (this.sizes.totalWidth < this.sizes.outer.width) {
6761
- var equalWidth = (this.sizes.outer.width - this.sizes.totalWidth) / columnsForSizing.length;
6784
+ // const outerSize = outerEl.getBoundingClientRect()
6785
+ if (this.sizes.totalWidth < this.sizes.table.width) {
6786
+ var requiredSpace = 0;
6787
+ var availableSpace = this.sizes.table.width - this.sizes.totalWidth;
6788
+ columnsForSizing.forEach(function (c) {
6789
+ c.shouldGrow = true;
6790
+ if (_this46.options.autoFitColumns === false) {
6791
+ c.shouldGrow = false;
6792
+ if (c.potentialWidth > c.actualWidth) {
6793
+ c.shouldGrow = true;
6794
+ c.growDiff = c.potentialWidth - c.actualWidth;
6795
+ c.growDiffPerc = (c.potentialWidth - c.actualWidth) / availableSpace;
6796
+ requiredSpace += c.growDiff;
6797
+ }
6798
+ }
6799
+ });
6800
+ var equalWidth = (this.sizes.table.width - this.sizes.totalWidth) / columnsForSizing.filter(function (c) {
6801
+ return c.shouldGrow;
6802
+ }).length;
6762
6803
  this.sizes.totalWidth = 0;
6763
6804
  this.sizes.totalNonPinnedWidth = 0;
6764
6805
  columnsForSizing.forEach(function (c, i) {
6765
6806
  // if (!c.width) {
6766
6807
  // if (c.actualWidth < equalWidth) {
6767
6808
  // adjust the width
6768
- if (c.width) {
6769
- c.width += equalWidth;
6809
+ if (_this46.options.autoFitColumns === true) {
6810
+ if (c.width) {
6811
+ c.width += equalWidth;
6812
+ }
6813
+ c.actualWidth += equalWidth;
6814
+ } else {
6815
+ if (requiredSpace > 0 && requiredSpace <= availableSpace) {
6816
+ if (c.shouldGrow) {
6817
+ if (c.width) {
6818
+ c.width += c.growDiff;
6819
+ }
6820
+ c.actualWidth += c.growDiff;
6821
+ }
6822
+ } else {
6823
+ if (c.shouldGrow) {
6824
+ if (c.width) {
6825
+ c.width += availableSpace * (c.growDiff / requiredSpace);
6826
+ }
6827
+ c.actualWidth += availableSpace * (c.growDiff / requiredSpace);
6828
+ }
6829
+ }
6770
6830
  }
6771
- c.actualWidth += equalWidth;
6772
6831
  // }
6773
6832
  // }
6774
6833
  _this46.sizes.totalWidth += c.width || c.actualWidth;
@@ -6779,9 +6838,9 @@ var WebsyTable3 = /*#__PURE__*/function () {
6779
6838
  });
6780
6839
  }
6781
6840
  // check that we have enough from for all of the pinned columns plus 1 non pinned column
6782
- if (this.sizes.pinnedWidth > this.sizes.outer.width - firstNonPinnedColumnWidth) {
6841
+ if (this.sizes.pinnedWidth > this.sizes.table.width - firstNonPinnedColumnWidth) {
6783
6842
  this.sizes.totalWidth = 0;
6784
- var diff = this.sizes.pinnedWidth - (this.sizes.outer.width - firstNonPinnedColumnWidth);
6843
+ var diff = this.sizes.pinnedWidth - (this.sizes.table.width - firstNonPinnedColumnWidth);
6785
6844
  var oldPinnedWidth = this.sizes.pinnedWidth;
6786
6845
  this.sizes.pinnedWidth = 0;
6787
6846
  // let colDiff = diff / this.pinnedColumns
@@ -6818,7 +6877,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6818
6877
  } else {
6819
6878
  this.vScrollRequired = false;
6820
6879
  }
6821
- if (this.sizes.totalWidth > this.sizes.outer.width) {
6880
+ if (this.sizes.totalWidth.toFixed(3) > this.sizes.table.width.toFixed(3)) {
6822
6881
  this.hScrollRequired = true;
6823
6882
  } else {
6824
6883
  this.hScrollRequired = false;
@@ -7207,7 +7266,6 @@ var WebsyTable3 = /*#__PURE__*/function () {
7207
7266
  var vHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
7208
7267
  if (this.vScrollRequired === true) {
7209
7268
  vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
7210
- // vScrollEl.style.left = `${this.sizes.outer.width - (this.options.isTouchDevice ? this.options.touchScrollWidth : this.options.scrollWidth)}px`
7211
7269
  vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
7212
7270
  if (this.isTouchDevice === true) {
7213
7271
  vScrollEl.style.visibility = "unset";
@@ -7325,6 +7383,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
7325
7383
  }
7326
7384
  }
7327
7385
  cumulativeWidth = 0;
7386
+ var lastColWidth = 0;
7328
7387
  for (var _i10 = this.startCol; _i10 < this.options.allColumns[this.options.allColumns.length - 1].length; _i10++) {
7329
7388
  if (this.options.allColumns[this.options.allColumns.length - 1][_i10].show !== false) {
7330
7389
  cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][_i10].actualWidth;
@@ -7339,9 +7398,19 @@ var WebsyTable3 = /*#__PURE__*/function () {
7339
7398
  if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.scrollableWidth && actualLeft > 0) {
7340
7399
  this.startCol += 1;
7341
7400
  }
7342
- if (scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >= scrollContainerEl.offsetWidth) {
7343
- this.startCol += 1;
7344
- this.endCol += 1;
7401
+ if (scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >= scrollContainerEl.offsetWidth - lastColWidth) {
7402
+ this.endCol = this.options.allColumns[this.options.allColumns.length - 1].length - 1;
7403
+ this.startCol = this.endCol + 1;
7404
+ // one last measurement
7405
+ var finalAcc = 0;
7406
+ for (var _i11 = this.endCol; _i11 > -1; _i11--) {
7407
+ if (this.options.allColumns[this.options.allColumns.length - 1][_i11].show !== false) {
7408
+ finalAcc += this.options.allColumns[this.options.allColumns.length - 1][_i11].actualWidth;
7409
+ if (finalAcc < this.sizes.scrollableWidth) {
7410
+ this.startCol--;
7411
+ }
7412
+ }
7413
+ }
7345
7414
  }
7346
7415
  this.endCol = Math.max(this.startCol, this.endCol);
7347
7416
  this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns);
@@ -9235,6 +9304,13 @@ var WebsyChart = /*#__PURE__*/function () {
9235
9304
  } else {
9236
9305
  if (_this57.options.data[xAxis].scale === 'Time') {
9237
9306
  xPos = _this57["".concat(xAxis, "Axis")](_this57.parseX(d.x.value));
9307
+ } else {
9308
+ var _xIndex = _this57[xAxis + 'Axis'].domain().indexOf(d.x.value);
9309
+ var _xPos = _this57["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex];
9310
+ if (_this57["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex + 1]) {
9311
+ _xPos = _xPos + (_this57["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex + 1] - _xPos) / 2;
9312
+ }
9313
+ // return xPos
9238
9314
  }
9239
9315
  // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9240
9316
  return "translate(".concat(xPos, ", ").concat(_this57["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
@@ -9263,6 +9339,13 @@ var WebsyChart = /*#__PURE__*/function () {
9263
9339
  } else {
9264
9340
  if (_this57.options.data[xAxis].scale === 'Time') {
9265
9341
  xPos = _this57["".concat(xAxis, "Axis")](_this57.parseX(d.x.value));
9342
+ } else {
9343
+ var _xIndex2 = _this57[xAxis + 'Axis'].domain().indexOf(d.x.value);
9344
+ var _xPos2 = _this57["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2];
9345
+ if (_this57["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2 + 1]) {
9346
+ _xPos2 = _xPos2 + (_this57["custom".concat(xAxis.toInitialCaps(), "Range")][_xIndex2 + 1] - _xPos2) / 2;
9347
+ }
9348
+ // return xPos
9266
9349
  }
9267
9350
  // return `translate(${this[`${xAxis}Axis`](this.parseX(d.x.value)) + adjustment}, ${this[`${yAxis}Axis`](isNaN(d.y.value) ? 0 : d.y.value)})`
9268
9351
  return "translate(".concat(xPos, ", ").concat(_this57["".concat(yAxis, "Axis")](isNaN(d.y.value) ? 0 : d.y.value), ")");
@@ -9935,8 +10018,12 @@ var WebsyKPI = /*#__PURE__*/function () {
9935
10018
  _classCallCheck(this, WebsyKPI);
9936
10019
  var DEFAULTS = {
9937
10020
  tooltip: {},
9938
- label: {},
9939
- value: {}
10021
+ label: {
10022
+ value: ''
10023
+ },
10024
+ value: {
10025
+ value: ''
10026
+ }
9940
10027
  };
9941
10028
  this.elementId = elementId;
9942
10029
  this.options = _extends({}, DEFAULTS, options);
@@ -9969,7 +10056,7 @@ var WebsyKPI = /*#__PURE__*/function () {
9969
10056
  if (this.options.icon) {
9970
10057
  html += "\n <div class=\"websy-kpi-icon\"><img src=\"".concat(this.options.icon, "\"></div> \n ");
9971
10058
  }
9972
- html += " \n <div class=\"websy-kpi-info\">\n <div class=\"websy-kpi-label ".concat(this.options.label.classes.join(' ') || '', "\">\n ").concat(this.options.label.value || '', "\n ");
10059
+ html += " \n <div class=\"websy-kpi-info\">\n <div class=\"websy-kpi-label ".concat(this.options.label.classes.join(' ') || '', "\">\n ").concat((this.options.label || {}).value || '', "\n ");
9973
10060
  if (this.options.tooltip && this.options.tooltip.value) {
9974
10061
  html += "\n <div class=\"websy-info ".concat(this.options.tooltip.classes.join(' ') || '', "\" data-info=\"").concat(this.options.tooltip.value, "\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><title>ionicons-v5-e</title><path d=\"M256,56C145.72,56,56,145.72,56,256s89.72,200,200,200,200-89.72,200-200S366.28,56,256,56Zm0,82a26,26,0,1,1-26,26A26,26,0,0,1,256,138Zm48,226H216a16,16,0,0,1,0-32h28V244H228a16,16,0,0,1,0-32h32a16,16,0,0,1,16,16V332h28a16,16,0,0,1,0,32Z\"/></svg>\n </div> \n ");
9975
10062
  }