@websy/websy-designs 1.9.11 → 1.9.13

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.
@@ -197,7 +197,8 @@ function ShopRoutes (dbHelper, engine, app) {
197
197
  basket.items = JSON.parse(basket.items)
198
198
  }
199
199
  catch (error) {
200
- console.log('Unable to parse basket')
200
+ console.log(`Unable to parse basket items for ${req.session.user.id}`)
201
+ console.log(`Basket items has a type of ${typeof basket.items}`)
201
202
  console.log(basket.items)
202
203
  }
203
204
  }
@@ -2584,7 +2584,9 @@ class MultiForm {
2584
2584
  this.elementId = elementId
2585
2585
  const DEFAULTS = {
2586
2586
  addButton: `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 512 512"><line x1="256" y1="112" x2="256" y2="400" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="400" y1="256" x2="112" y2="256" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`,
2587
- deleteButton: `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 512 512"><line x1="368" y1="368" x2="144" y2="144" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="368" y1="144" x2="144" y2="368" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`
2587
+ deleteButton: `<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 0 512 512"><line x1="368" y1="368" x2="144" y2="144" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/><line x1="368" y1="144" x2="144" y2="368" style="fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px"/></svg>`,
2588
+ allowAdd: true,
2589
+ allowDelete: true
2588
2590
  }
2589
2591
  this.options = Object.assign({}, DEFAULTS, options)
2590
2592
  this.formData = []
@@ -2649,7 +2651,9 @@ class MultiForm {
2649
2651
  deleteButtonEl.classList.remove('hidden')
2650
2652
  }
2651
2653
  // add new form
2652
- this.addEntry()
2654
+ if (this.options.allowAdd === true) {
2655
+ this.addEntry()
2656
+ }
2653
2657
  }
2654
2658
  if (event.target.classList.contains('websy-multi-form-delete')) {
2655
2659
  // delete form based on index
@@ -2685,25 +2689,33 @@ class MultiForm {
2685
2689
  <div id='${this.elementId}_${d.formId}_formContainer' class='websy-multi-form-form-container'>
2686
2690
  <div id='${this.elementId}_${d.formId}_form' class='websy-multi-form-form'>
2687
2691
  </div>
2692
+ `
2693
+ if (this.options.allowDelete === true) {
2694
+ html += `
2688
2695
  <button id='${this.elementId}_${d.formId}_deleteButton' data-formid='${d.formId}' data-rowid='${d.id}' class='websy-multi-form-delete'>
2689
2696
  ${this.options.deleteButton}
2690
- </button>
2697
+ </button>
2698
+ `
2699
+ }
2700
+ html += `
2691
2701
  </div>
2692
2702
  `
2693
2703
  })
2694
2704
  let id = WebsyDesigns.Utils.createIdentity()
2695
- html += `
2696
- <div id='${this.elementId}_${id}_formContainer' class='websy-multi-form-form-container'>
2697
- <div id='${this.elementId}_${id}_form' class='websy-multi-form-form'>
2705
+ if (this.options.allowAdd === true) {
2706
+ html += `
2707
+ <div id='${this.elementId}_${id}_formContainer' class='websy-multi-form-form-container'>
2708
+ <div id='${this.elementId}_${id}_form' class='websy-multi-form-form'>
2709
+ </div>
2710
+ <button id='${this.elementId}_${id}_deleteButton' data-formid='${id}' class='hidden websy-multi-form-delete'>
2711
+ ${this.options.deleteButton}
2712
+ </button>
2713
+ <button id='${this.elementId}_${id}_addButton' data-formid='${id}' class='websy-multi-form-add'>
2714
+ ${this.options.addButton}
2715
+ </button>
2698
2716
  </div>
2699
- <button id='${this.elementId}_${id}_deleteButton' data-formid='${id}' class='hidden websy-multi-form-delete'>
2700
- ${this.options.deleteButton}
2701
- </button>
2702
- <button id='${this.elementId}_${id}_addButton' data-formid='${id}' class='websy-multi-form-add'>
2703
- ${this.options.addButton}
2704
- </button>
2705
- </div>
2706
- `
2717
+ `
2718
+ }
2707
2719
  el.innerHTML = html
2708
2720
  this.formData.forEach(d => {
2709
2721
  let formOptions = Object.assign({}, this.options)
@@ -2711,8 +2723,10 @@ class MultiForm {
2711
2723
  formObject.data = d
2712
2724
  this.forms.push(formObject)
2713
2725
  })
2714
- let formOptions = Object.assign({}, this.options)
2715
- this.forms.push(new WebsyDesigns.Form(`${this.elementId}_${id}_form`, formOptions))
2726
+ if (this.options.allowAdd === true) {
2727
+ let formOptions = Object.assign({}, this.options)
2728
+ this.forms.push(new WebsyDesigns.Form(`${this.elementId}_${id}_form`, formOptions))
2729
+ }
2716
2730
  }
2717
2731
  }
2718
2732
  validateForm () {
@@ -6264,7 +6278,8 @@ class WebsyTable3 {
6264
6278
  disableInternalLoader: false,
6265
6279
  disableTouch: false,
6266
6280
  scrollWidth: 10,
6267
- touchScrollWidth: 30
6281
+ touchScrollWidth: 30,
6282
+ autoFitColumns: true
6268
6283
  }
6269
6284
  this.options = Object.assign({}, DEFAULTS, options)
6270
6285
  this.isTouchDevice = ('ontouchstart' in window) || (navigator.maxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)
@@ -6642,7 +6657,7 @@ class WebsyTable3 {
6642
6657
  maxWidth = this.options.maxColWidth
6643
6658
  }
6644
6659
  else if (this.options.maxColWidth.indexOf('%') !== -1) {
6645
- maxWidth = this.sizes.outer.width * (+(this.options.maxColWidth.replace('%', '')) / 100)
6660
+ maxWidth = this.sizes.table.width * (+(this.options.maxColWidth.replace('%', '')) / 100)
6646
6661
  }
6647
6662
  else if (this.options.maxColWidth.indexOf('px') !== -1) {
6648
6663
  maxWidth = +this.options.maxColWidth.replace('px', '')
@@ -6655,7 +6670,7 @@ class WebsyTable3 {
6655
6670
  this.sizes.total = footerEl.getBoundingClientRect()
6656
6671
  const rows = Array.from(tableEl.querySelectorAll('.websy-table-row'))
6657
6672
  let totalWidth = 0
6658
- this.sizes.scrollableWidth = this.sizes.outer.width
6673
+ this.sizes.scrollableWidth = this.sizes.table.width
6659
6674
  let firstNonPinnedColumnWidth = 0
6660
6675
  let columnsForSizing = this.options.columns[this.options.columns.length - 1].filter(c => c.show !== false)
6661
6676
  rows.forEach((row, rowIndex) => {
@@ -6664,8 +6679,10 @@ class WebsyTable3 {
6664
6679
  this.sizes.cellHeight = colSize.height
6665
6680
  if (columnsForSizing[colIndex]) {
6666
6681
  if (!columnsForSizing[colIndex].actualWidth) {
6682
+ columnsForSizing[colIndex].potentialWidth = 0
6667
6683
  columnsForSizing[colIndex].actualWidth = 0
6668
6684
  }
6685
+ columnsForSizing[colIndex].potentialWidth = Math.max(columnsForSizing[colIndex].potentialWidth, colSize.width)
6669
6686
  columnsForSizing[colIndex].actualWidth = Math.min(Math.max(columnsForSizing[colIndex].actualWidth, colSize.width), maxWidth)
6670
6687
  // if (columnsForSizing[colIndex].width) {
6671
6688
  // columnsForSizing[colIndex].actualWidth = columnsForSizing[colIndex].width
@@ -6685,19 +6702,53 @@ class WebsyTable3 {
6685
6702
  this.sizes.totalWidth = columnsForSizing.reduce((a, b) => a + (b.width || b.actualWidth), 0)
6686
6703
  this.sizes.totalNonPinnedWidth = columnsForSizing.filter((c, i) => i >= this.pinnedColumns).reduce((a, b) => a + (b.width || b.actualWidth), 0)
6687
6704
  this.sizes.pinnedWidth = this.sizes.totalWidth - this.sizes.totalNonPinnedWidth
6688
- // const outerSize = outerEl.getBoundingClientRect()
6689
- if (this.sizes.totalWidth < this.sizes.outer.width) {
6690
- let equalWidth = (this.sizes.outer.width - this.sizes.totalWidth) / columnsForSizing.length
6705
+ // const outerSize = outerEl.getBoundingClientRect()
6706
+ if (this.sizes.totalWidth < this.sizes.table.width) {
6707
+ let requiredSpace = 0
6708
+ let availableSpace = (this.sizes.table.width - this.sizes.totalWidth)
6709
+ columnsForSizing.forEach(c => {
6710
+ c.shouldGrow = true
6711
+ if (this.options.autoFitColumns === false) {
6712
+ c.shouldGrow = false
6713
+ if (c.potentialWidth > c.actualWidth) {
6714
+ c.shouldGrow = true
6715
+ c.growDiff = c.potentialWidth - c.actualWidth
6716
+ c.growDiffPerc = (c.potentialWidth - c.actualWidth) / availableSpace
6717
+ requiredSpace += c.growDiff
6718
+ }
6719
+ }
6720
+ })
6721
+ let equalWidth = (this.sizes.table.width - this.sizes.totalWidth) / columnsForSizing.filter(c => c.shouldGrow).length
6691
6722
  this.sizes.totalWidth = 0
6692
6723
  this.sizes.totalNonPinnedWidth = 0
6693
6724
  columnsForSizing.forEach((c, i) => {
6694
6725
  // if (!c.width) {
6695
6726
  // if (c.actualWidth < equalWidth) {
6696
6727
  // adjust the width
6697
- if (c.width) {
6698
- c.width += equalWidth
6728
+ if (this.options.autoFitColumns === true) {
6729
+ if (c.width) {
6730
+ c.width += equalWidth
6731
+ }
6732
+ c.actualWidth += equalWidth
6733
+ }
6734
+ else {
6735
+ if (requiredSpace > 0 && requiredSpace <= availableSpace) {
6736
+ if (c.shouldGrow) {
6737
+ if (c.width) {
6738
+ c.width += c.growDiff
6739
+ }
6740
+ c.actualWidth += c.growDiff
6741
+ }
6742
+ }
6743
+ else {
6744
+ if (c.shouldGrow) {
6745
+ if (c.width) {
6746
+ c.width += availableSpace * (c.growDiff / requiredSpace)
6747
+ }
6748
+ c.actualWidth += availableSpace * (c.growDiff / requiredSpace)
6749
+ }
6750
+ }
6699
6751
  }
6700
- c.actualWidth += equalWidth
6701
6752
  // }
6702
6753
  // }
6703
6754
  this.sizes.totalWidth += c.width || c.actualWidth
@@ -6708,9 +6759,9 @@ class WebsyTable3 {
6708
6759
  })
6709
6760
  }
6710
6761
  // check that we have enough from for all of the pinned columns plus 1 non pinned column
6711
- if (this.sizes.pinnedWidth > (this.sizes.outer.width - firstNonPinnedColumnWidth)) {
6762
+ if (this.sizes.pinnedWidth > (this.sizes.table.width - firstNonPinnedColumnWidth)) {
6712
6763
  this.sizes.totalWidth = 0
6713
- let diff = this.sizes.pinnedWidth - (this.sizes.outer.width - firstNonPinnedColumnWidth)
6764
+ let diff = this.sizes.pinnedWidth - (this.sizes.table.width - firstNonPinnedColumnWidth)
6714
6765
  let oldPinnedWidth = this.sizes.pinnedWidth
6715
6766
  this.sizes.pinnedWidth = 0
6716
6767
  // let colDiff = diff / this.pinnedColumns
@@ -6748,7 +6799,7 @@ class WebsyTable3 {
6748
6799
  else {
6749
6800
  this.vScrollRequired = false
6750
6801
  }
6751
- if (this.sizes.totalWidth > this.sizes.outer.width) {
6802
+ if (this.sizes.totalWidth.toFixed(3) > this.sizes.table.width.toFixed(3)) {
6752
6803
  this.hScrollRequired = true
6753
6804
  }
6754
6805
  else {
@@ -7113,7 +7164,6 @@ class WebsyTable3 {
7113
7164
  let vHandleEl = document.getElementById(`${this.elementId}_vScrollHandle`)
7114
7165
  if (this.vScrollRequired === true) {
7115
7166
  vScrollEl.style.top = `${this.sizes.header.height + this.sizes.total.height}px`
7116
- // vScrollEl.style.left = `${this.sizes.outer.width - (this.options.isTouchDevice ? this.options.touchScrollWidth : this.options.scrollWidth)}px`
7117
7167
  vScrollEl.style.height = `${this.sizes.bodyHeight}px`
7118
7168
  if (this.isTouchDevice === true) {
7119
7169
  vScrollEl.style.visibility = `unset`
@@ -7226,7 +7276,8 @@ class WebsyTable3 {
7226
7276
  }
7227
7277
  }
7228
7278
  }
7229
- cumulativeWidth = 0
7279
+ cumulativeWidth = 0
7280
+ let lastColWidth = 0
7230
7281
  for (let i = this.startCol; i < this.options.allColumns[this.options.allColumns.length - 1].length; i++) {
7231
7282
  if (this.options.allColumns[this.options.allColumns.length - 1][i].show !== false) {
7232
7283
  cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
@@ -7241,9 +7292,22 @@ class WebsyTable3 {
7241
7292
  if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.scrollableWidth && actualLeft > 0) {
7242
7293
  this.startCol += 1
7243
7294
  }
7244
- if (scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >= scrollContainerEl.offsetWidth) {
7245
- this.startCol += 1
7246
- this.endCol += 1
7295
+ if (
7296
+ scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >=
7297
+ scrollContainerEl.offsetWidth - lastColWidth
7298
+ ) {
7299
+ this.endCol = this.options.allColumns[this.options.allColumns.length - 1].length - 1
7300
+ this.startCol = this.endCol + 1
7301
+ // one last measurement
7302
+ let finalAcc = 0
7303
+ for (let i = this.endCol; i > -1; i--) {
7304
+ if (this.options.allColumns[this.options.allColumns.length - 1][i].show !== false) {
7305
+ finalAcc += this.options.allColumns[this.options.allColumns.length - 1][i].actualWidth
7306
+ if (finalAcc < this.sizes.scrollableWidth) {
7307
+ this.startCol--
7308
+ }
7309
+ }
7310
+ }
7247
7311
  }
7248
7312
  this.endCol = Math.max(this.startCol, this.endCol)
7249
7313
  this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns)
@@ -8284,6 +8348,7 @@ else {
8284
8348
  let rangeLength = bottomDomain.length
8285
8349
  this.options.data.bottomBrush = {}
8286
8350
  this.options.data.leftBrush = {}
8351
+ this.options.data.rightBrush = {}
8287
8352
  if (this.options.orientation === 'vertical') {
8288
8353
  this.options.data.bottom.bandWidth = proposedBandWidth
8289
8354
  this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints
@@ -8291,6 +8356,7 @@ else {
8291
8356
  else {
8292
8357
  this.options.data.left.bandWidth = proposedBandWidth
8293
8358
  this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
8359
+ this.options.data.rightBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints
8294
8360
  }
8295
8361
  this.brushBandPadding = this.totalBandPadding / noOfGroups
8296
8362
  if (this.options.orientation === 'vertical') {
@@ -8494,7 +8560,8 @@ else {
8494
8560
  // Configure the left axis
8495
8561
  let leftDomain = this.createDomain('left')
8496
8562
  let leftBrushDomain = this.createDomain('left')
8497
- let rightDomain = this.createDomain('right')
8563
+ let rightDomain = this.createDomain('right')
8564
+ let rightBrushDomain = this.createDomain('right')
8498
8565
  this.leftAxis = d3[`scale${this.options.data.left.scale || 'Linear'}`]()
8499
8566
  .domain(leftDomain)
8500
8567
  .range(leftRange)
@@ -8567,6 +8634,9 @@ else {
8567
8634
  this.rightAxis = d3[`scale${this.options.data.right.scale || 'Linear'}`]()
8568
8635
  .domain(rightDomain)
8569
8636
  .range([this.plotHeight, 0])
8637
+ this.rightBrushAxis = d3[`scale${this.options.data.right.scale || 'Linear'}`]()
8638
+ .domain(rightBrushDomain)
8639
+ .range(leftBrushRange)
8570
8640
  if (this.rightAxis.nice) {
8571
8641
  this.rightAxis.nice()
8572
8642
  }
@@ -9157,10 +9227,10 @@ if (this.options.orientation === 'horizontal') {
9157
9227
  yAxis = 'bottom'
9158
9228
  }
9159
9229
  let xBrushAxis = 'bottomBrush'
9160
- let yBrushAxis = 'leftBrush'
9230
+ let yBrushAxis = series.axis === 'secondary' ? 'rightBrush' : 'leftBrush'
9161
9231
  if (this.options.orientation === 'horizontal') {
9162
9232
  xBrushAxis = 'leftBrush'
9163
- yBrushAxis = 'bottomBrush'
9233
+ yBrushAxis = 'bottomBrush'
9164
9234
  }
9165
9235
  let lines = this.lineLayer.selectAll(`.line_${series.key}`)
9166
9236
  .data([series.data])
@@ -2565,7 +2565,9 @@ var MultiForm = /*#__PURE__*/function () {
2565
2565
  this.elementId = elementId;
2566
2566
  var DEFAULTS = {
2567
2567
  addButton: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"40\" height=\"40\" viewBox=\"0 0 512 512\"><line x1=\"256\" y1=\"112\" x2=\"256\" y2=\"400\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"400\" y1=\"256\" x2=\"112\" y2=\"256\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>",
2568
- deleteButton: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"40\" height=\"40\" viewBox=\"0 0 512 512\"><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>"
2568
+ deleteButton: "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"40\" height=\"40\" viewBox=\"0 0 512 512\"><line x1=\"368\" y1=\"368\" x2=\"144\" y2=\"144\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/><line x1=\"368\" y1=\"144\" x2=\"144\" y2=\"368\" style=\"fill:none;stroke-linecap:round;stroke-linejoin:round;stroke-width:32px\"/></svg>",
2569
+ allowAdd: true,
2570
+ allowDelete: true
2569
2571
  };
2570
2572
  this.options = _extends({}, DEFAULTS, options);
2571
2573
  this.formData = [];
@@ -2631,7 +2633,9 @@ var MultiForm = /*#__PURE__*/function () {
2631
2633
  deleteButtonEl.classList.remove('hidden');
2632
2634
  }
2633
2635
  // add new form
2634
- this.addEntry();
2636
+ if (this.options.allowAdd === true) {
2637
+ this.addEntry();
2638
+ }
2635
2639
  }
2636
2640
  if (event.target.classList.contains('websy-multi-form-delete')) {
2637
2641
  // delete form based on index
@@ -2666,10 +2670,16 @@ var MultiForm = /*#__PURE__*/function () {
2666
2670
  var html = '';
2667
2671
  this.formData.forEach(function (d) {
2668
2672
  d.formId = WebsyDesigns.Utils.createIdentity();
2669
- html += "\n <div id='".concat(_this19.elementId, "_").concat(d.formId, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(_this19.elementId, "_").concat(d.formId, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(_this19.elementId, "_").concat(d.formId, "_deleteButton' data-formid='").concat(d.formId, "' data-rowid='").concat(d.id, "' class='websy-multi-form-delete'>\n ").concat(_this19.options.deleteButton, "\n </button> \n </div>\n ");
2673
+ html += "\n <div id='".concat(_this19.elementId, "_").concat(d.formId, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(_this19.elementId, "_").concat(d.formId, "_form' class='websy-multi-form-form'>\n </div>\n ");
2674
+ if (_this19.options.allowDelete === true) {
2675
+ html += "\n <button id='".concat(_this19.elementId, "_").concat(d.formId, "_deleteButton' data-formid='").concat(d.formId, "' data-rowid='").concat(d.id, "' class='websy-multi-form-delete'>\n ").concat(_this19.options.deleteButton, "\n </button>\n ");
2676
+ }
2677
+ html += "\n </div>\n ";
2670
2678
  });
2671
2679
  var id = WebsyDesigns.Utils.createIdentity();
2672
- html += "\n <div id='".concat(this.elementId, "_").concat(id, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(this.elementId, "_").concat(id, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(this.elementId, "_").concat(id, "_deleteButton' data-formid='").concat(id, "' class='hidden websy-multi-form-delete'>\n ").concat(this.options.deleteButton, "\n </button> \n <button id='").concat(this.elementId, "_").concat(id, "_addButton' data-formid='").concat(id, "' class='websy-multi-form-add'>\n ").concat(this.options.addButton, "\n </button> \n </div>\n ");
2680
+ if (this.options.allowAdd === true) {
2681
+ html += "\n <div id='".concat(this.elementId, "_").concat(id, "_formContainer' class='websy-multi-form-form-container'>\n <div id='").concat(this.elementId, "_").concat(id, "_form' class='websy-multi-form-form'>\n </div>\n <button id='").concat(this.elementId, "_").concat(id, "_deleteButton' data-formid='").concat(id, "' class='hidden websy-multi-form-delete'>\n ").concat(this.options.deleteButton, "\n </button> \n <button id='").concat(this.elementId, "_").concat(id, "_addButton' data-formid='").concat(id, "' class='websy-multi-form-add'>\n ").concat(this.options.addButton, "\n </button> \n </div>\n ");
2682
+ }
2673
2683
  el.innerHTML = html;
2674
2684
  this.formData.forEach(function (d) {
2675
2685
  var formOptions = _extends({}, _this19.options);
@@ -2677,8 +2687,10 @@ var MultiForm = /*#__PURE__*/function () {
2677
2687
  formObject.data = d;
2678
2688
  _this19.forms.push(formObject);
2679
2689
  });
2680
- var formOptions = _extends({}, this.options);
2681
- this.forms.push(new WebsyDesigns.Form("".concat(this.elementId, "_").concat(id, "_form"), formOptions));
2690
+ if (this.options.allowAdd === true) {
2691
+ var formOptions = _extends({}, this.options);
2692
+ this.forms.push(new WebsyDesigns.Form("".concat(this.elementId, "_").concat(id, "_form"), formOptions));
2693
+ }
2682
2694
  }
2683
2695
  }
2684
2696
  }, {
@@ -5987,7 +5999,8 @@ var WebsyTable3 = /*#__PURE__*/function () {
5987
5999
  disableInternalLoader: false,
5988
6000
  disableTouch: false,
5989
6001
  scrollWidth: 10,
5990
- touchScrollWidth: 30
6002
+ touchScrollWidth: 30,
6003
+ autoFitColumns: true
5991
6004
  };
5992
6005
  this.options = _extends({}, DEFAULTS, options);
5993
6006
  this.isTouchDevice = 'ontouchstart' in window || navigator.maxTouchPoints > 0 || navigator.msMaxTouchPoints > 0;
@@ -6301,7 +6314,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6301
6314
  if (typeof this.options.maxColWidth === 'number') {
6302
6315
  maxWidth = this.options.maxColWidth;
6303
6316
  } else if (this.options.maxColWidth.indexOf('%') !== -1) {
6304
- maxWidth = this.sizes.outer.width * (+this.options.maxColWidth.replace('%', '') / 100);
6317
+ maxWidth = this.sizes.table.width * (+this.options.maxColWidth.replace('%', '') / 100);
6305
6318
  } else if (this.options.maxColWidth.indexOf('px') !== -1) {
6306
6319
  maxWidth = +this.options.maxColWidth.replace('px', '');
6307
6320
  }
@@ -6313,7 +6326,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6313
6326
  this.sizes.total = footerEl.getBoundingClientRect();
6314
6327
  var rows = Array.from(tableEl.querySelectorAll('.websy-table-row'));
6315
6328
  var totalWidth = 0;
6316
- this.sizes.scrollableWidth = this.sizes.outer.width;
6329
+ this.sizes.scrollableWidth = this.sizes.table.width;
6317
6330
  var firstNonPinnedColumnWidth = 0;
6318
6331
  var columnsForSizing = this.options.columns[this.options.columns.length - 1].filter(function (c) {
6319
6332
  return c.show !== false;
@@ -6324,8 +6337,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6324
6337
  _this43.sizes.cellHeight = colSize.height;
6325
6338
  if (columnsForSizing[colIndex]) {
6326
6339
  if (!columnsForSizing[colIndex].actualWidth) {
6340
+ columnsForSizing[colIndex].potentialWidth = 0;
6327
6341
  columnsForSizing[colIndex].actualWidth = 0;
6328
6342
  }
6343
+ columnsForSizing[colIndex].potentialWidth = Math.max(columnsForSizing[colIndex].potentialWidth, colSize.width);
6329
6344
  columnsForSizing[colIndex].actualWidth = Math.min(Math.max(columnsForSizing[colIndex].actualWidth, colSize.width), maxWidth);
6330
6345
  // if (columnsForSizing[colIndex].width) {
6331
6346
  // columnsForSizing[colIndex].actualWidth = columnsForSizing[colIndex].width
@@ -6351,19 +6366,53 @@ var WebsyTable3 = /*#__PURE__*/function () {
6351
6366
  return a + (b.width || b.actualWidth);
6352
6367
  }, 0);
6353
6368
  this.sizes.pinnedWidth = this.sizes.totalWidth - this.sizes.totalNonPinnedWidth;
6354
- // const outerSize = outerEl.getBoundingClientRect()
6355
- if (this.sizes.totalWidth < this.sizes.outer.width) {
6356
- var equalWidth = (this.sizes.outer.width - this.sizes.totalWidth) / columnsForSizing.length;
6369
+ // const outerSize = outerEl.getBoundingClientRect()
6370
+ if (this.sizes.totalWidth < this.sizes.table.width) {
6371
+ var requiredSpace = 0;
6372
+ var availableSpace = this.sizes.table.width - this.sizes.totalWidth;
6373
+ columnsForSizing.forEach(function (c) {
6374
+ c.shouldGrow = true;
6375
+ if (_this43.options.autoFitColumns === false) {
6376
+ c.shouldGrow = false;
6377
+ if (c.potentialWidth > c.actualWidth) {
6378
+ c.shouldGrow = true;
6379
+ c.growDiff = c.potentialWidth - c.actualWidth;
6380
+ c.growDiffPerc = (c.potentialWidth - c.actualWidth) / availableSpace;
6381
+ requiredSpace += c.growDiff;
6382
+ }
6383
+ }
6384
+ });
6385
+ var equalWidth = (this.sizes.table.width - this.sizes.totalWidth) / columnsForSizing.filter(function (c) {
6386
+ return c.shouldGrow;
6387
+ }).length;
6357
6388
  this.sizes.totalWidth = 0;
6358
6389
  this.sizes.totalNonPinnedWidth = 0;
6359
6390
  columnsForSizing.forEach(function (c, i) {
6360
6391
  // if (!c.width) {
6361
6392
  // if (c.actualWidth < equalWidth) {
6362
6393
  // adjust the width
6363
- if (c.width) {
6364
- c.width += equalWidth;
6394
+ if (_this43.options.autoFitColumns === true) {
6395
+ if (c.width) {
6396
+ c.width += equalWidth;
6397
+ }
6398
+ c.actualWidth += equalWidth;
6399
+ } else {
6400
+ if (requiredSpace > 0 && requiredSpace <= availableSpace) {
6401
+ if (c.shouldGrow) {
6402
+ if (c.width) {
6403
+ c.width += c.growDiff;
6404
+ }
6405
+ c.actualWidth += c.growDiff;
6406
+ }
6407
+ } else {
6408
+ if (c.shouldGrow) {
6409
+ if (c.width) {
6410
+ c.width += availableSpace * (c.growDiff / requiredSpace);
6411
+ }
6412
+ c.actualWidth += availableSpace * (c.growDiff / requiredSpace);
6413
+ }
6414
+ }
6365
6415
  }
6366
- c.actualWidth += equalWidth;
6367
6416
  // }
6368
6417
  // }
6369
6418
  _this43.sizes.totalWidth += c.width || c.actualWidth;
@@ -6374,9 +6423,9 @@ var WebsyTable3 = /*#__PURE__*/function () {
6374
6423
  });
6375
6424
  }
6376
6425
  // check that we have enough from for all of the pinned columns plus 1 non pinned column
6377
- if (this.sizes.pinnedWidth > this.sizes.outer.width - firstNonPinnedColumnWidth) {
6426
+ if (this.sizes.pinnedWidth > this.sizes.table.width - firstNonPinnedColumnWidth) {
6378
6427
  this.sizes.totalWidth = 0;
6379
- var diff = this.sizes.pinnedWidth - (this.sizes.outer.width - firstNonPinnedColumnWidth);
6428
+ var diff = this.sizes.pinnedWidth - (this.sizes.table.width - firstNonPinnedColumnWidth);
6380
6429
  var oldPinnedWidth = this.sizes.pinnedWidth;
6381
6430
  this.sizes.pinnedWidth = 0;
6382
6431
  // let colDiff = diff / this.pinnedColumns
@@ -6413,7 +6462,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6413
6462
  } else {
6414
6463
  this.vScrollRequired = false;
6415
6464
  }
6416
- if (this.sizes.totalWidth > this.sizes.outer.width) {
6465
+ if (this.sizes.totalWidth.toFixed(3) > this.sizes.table.width.toFixed(3)) {
6417
6466
  this.hScrollRequired = true;
6418
6467
  } else {
6419
6468
  this.hScrollRequired = false;
@@ -6802,7 +6851,6 @@ var WebsyTable3 = /*#__PURE__*/function () {
6802
6851
  var vHandleEl = document.getElementById("".concat(this.elementId, "_vScrollHandle"));
6803
6852
  if (this.vScrollRequired === true) {
6804
6853
  vScrollEl.style.top = "".concat(this.sizes.header.height + this.sizes.total.height, "px");
6805
- // vScrollEl.style.left = `${this.sizes.outer.width - (this.options.isTouchDevice ? this.options.touchScrollWidth : this.options.scrollWidth)}px`
6806
6854
  vScrollEl.style.height = "".concat(this.sizes.bodyHeight, "px");
6807
6855
  if (this.isTouchDevice === true) {
6808
6856
  vScrollEl.style.visibility = "unset";
@@ -6920,6 +6968,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6920
6968
  }
6921
6969
  }
6922
6970
  cumulativeWidth = 0;
6971
+ var lastColWidth = 0;
6923
6972
  for (var _i10 = this.startCol; _i10 < this.options.allColumns[this.options.allColumns.length - 1].length; _i10++) {
6924
6973
  if (this.options.allColumns[this.options.allColumns.length - 1][_i10].show !== false) {
6925
6974
  cumulativeWidth += this.options.allColumns[this.options.allColumns.length - 1][_i10].actualWidth;
@@ -6934,9 +6983,19 @@ var WebsyTable3 = /*#__PURE__*/function () {
6934
6983
  if (this.endCol === this.options.allColumns[this.options.allColumns.length - 1].length - 1 && cumulativeWidth > this.sizes.scrollableWidth && actualLeft > 0) {
6935
6984
  this.startCol += 1;
6936
6985
  }
6937
- if (scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >= scrollContainerEl.offsetWidth) {
6938
- this.startCol += 1;
6939
- this.endCol += 1;
6986
+ if (scrollHandleEl.offsetWidth + scrollHandleEl.offsetLeft >= scrollContainerEl.offsetWidth - lastColWidth) {
6987
+ this.endCol = this.options.allColumns[this.options.allColumns.length - 1].length - 1;
6988
+ this.startCol = this.endCol + 1;
6989
+ // one last measurement
6990
+ var finalAcc = 0;
6991
+ for (var _i11 = this.endCol; _i11 > -1; _i11--) {
6992
+ if (this.options.allColumns[this.options.allColumns.length - 1][_i11].show !== false) {
6993
+ finalAcc += this.options.allColumns[this.options.allColumns.length - 1][_i11].actualWidth;
6994
+ if (finalAcc < this.sizes.scrollableWidth) {
6995
+ this.startCol--;
6996
+ }
6997
+ }
6998
+ }
6940
6999
  }
6941
7000
  this.endCol = Math.max(this.startCol, this.endCol);
6942
7001
  this.options.onScroll('y', this.startRow, this.endRow, this.startCol - this.pinnedColumns, this.endCol - this.pinnedColumns);
@@ -7918,12 +7977,14 @@ var WebsyChart = /*#__PURE__*/function () {
7918
7977
  var rangeLength = bottomDomain.length;
7919
7978
  this.options.data.bottomBrush = {};
7920
7979
  this.options.data.leftBrush = {};
7980
+ this.options.data.rightBrush = {};
7921
7981
  if (this.options.orientation === 'vertical') {
7922
7982
  this.options.data.bottom.bandWidth = proposedBandWidth;
7923
7983
  this.options.data.bottomBrush.bandWidth = (this.plotWidth - this.totalBandPadding) / noOfPoints;
7924
7984
  } else {
7925
7985
  this.options.data.left.bandWidth = proposedBandWidth;
7926
7986
  this.options.data.leftBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints;
7987
+ this.options.data.rightBrush.bandWidth = (this.plotHeight - this.totalBandPadding) / noOfPoints;
7927
7988
  }
7928
7989
  this.brushBandPadding = this.totalBandPadding / noOfGroups;
7929
7990
  if (this.options.orientation === 'vertical') {
@@ -8100,6 +8161,7 @@ var WebsyChart = /*#__PURE__*/function () {
8100
8161
  var leftDomain = this.createDomain('left');
8101
8162
  var leftBrushDomain = this.createDomain('left');
8102
8163
  var rightDomain = this.createDomain('right');
8164
+ var rightBrushDomain = this.createDomain('right');
8103
8165
  this.leftAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftDomain).range(leftRange);
8104
8166
  this.leftBrushAxis = d3["scale".concat(this.options.data.left.scale || 'Linear')]().domain(leftBrushDomain).range(leftBrushRange);
8105
8167
  if (this.leftAxis.padding && this.options.data.left.padding) {
@@ -8139,6 +8201,7 @@ var WebsyChart = /*#__PURE__*/function () {
8139
8201
  // Configure the right axis
8140
8202
  if (rightDomain.length > 0) {
8141
8203
  this.rightAxis = d3["scale".concat(this.options.data.right.scale || 'Linear')]().domain(rightDomain).range([this.plotHeight, 0]);
8204
+ this.rightBrushAxis = d3["scale".concat(this.options.data.right.scale || 'Linear')]().domain(rightBrushDomain).range(leftBrushRange);
8142
8205
  if (this.rightAxis.nice) {
8143
8206
  this.rightAxis.nice();
8144
8207
  }
@@ -8682,7 +8745,7 @@ var WebsyChart = /*#__PURE__*/function () {
8682
8745
  yAxis = 'bottom';
8683
8746
  }
8684
8747
  var xBrushAxis = 'bottomBrush';
8685
- var yBrushAxis = 'leftBrush';
8748
+ var yBrushAxis = series.axis === 'secondary' ? 'rightBrush' : 'leftBrush';
8686
8749
  if (this.options.orientation === 'horizontal') {
8687
8750
  xBrushAxis = 'leftBrush';
8688
8751
  yBrushAxis = 'bottomBrush';