@websy/websy-designs 1.4.27 → 1.4.29

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.
@@ -2613,7 +2613,6 @@ class WebsyNavigationMenu {
2613
2613
  })
2614
2614
  })
2615
2615
  }
2616
- console.log('visibleItems', visibleItems)
2617
2616
  }
2618
2617
  normaliseString (text) {
2619
2618
  return text.replace(/-/g, '').replace(/\s/g, '_')
@@ -4732,6 +4731,9 @@ const WebsyUtils = {
4732
4731
  },
4733
4732
  toQlikDateNum: d => {
4734
4733
  return Math.floor(d.getTime() / 86400000 + 25570)
4734
+ },
4735
+ toQlikDate: d => {
4736
+ return Math.floor(d.getTime() / 86400000 + 25570)
4735
4737
  }
4736
4738
  }
4737
4739
 
@@ -5729,10 +5731,11 @@ class WebsyTable3 {
5729
5731
  allowPivoting: false,
5730
5732
  searchIcon: `<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>`,
5731
5733
  plusIcon: WebsyDesigns.Icons.PlusFilled,
5732
- minusIcon: WebsyDesigns.Icons.MinusFilled
5734
+ minusIcon: WebsyDesigns.Icons.MinusFilled
5733
5735
  }
5734
5736
  this.options = Object.assign({}, DEFAULTS, options)
5735
5737
  this.sizes = {}
5738
+ this.currentData = []
5736
5739
  this.scrollDragging = false
5737
5740
  this.cellDragging = false
5738
5741
  this.vScrollRequired = false
@@ -5809,14 +5812,16 @@ class WebsyTable3 {
5809
5812
  this.renderTotals()
5810
5813
  }
5811
5814
  appendRows (data) {
5812
- this.hideError()
5815
+ this.hideError()
5813
5816
  let bodyEl = document.getElementById(`${this.elementId}_tableBody`)
5814
5817
  if (bodyEl) {
5815
5818
  if (this.options.virtualScroll === true) {
5816
5819
  bodyEl.innerHTML = this.buildBodyHtml(data, true)
5820
+ this.currentData = data
5817
5821
  }
5818
5822
  else {
5819
5823
  bodyEl.innerHTML += this.buildBodyHtml(data, true)
5824
+ this.currentData = this.currentData.concat(data)
5820
5825
  }
5821
5826
  }
5822
5827
  // this.data = this.data.concat(data)
@@ -5877,7 +5882,8 @@ class WebsyTable3 {
5877
5882
  colspan='${cell.colspan || 1}'
5878
5883
  rowspan='${cell.rowspan || 1}'
5879
5884
  data-row-index='${rowIndex}'
5880
- data-col-index='${cellIndex}'
5885
+ data-cell-index='${cellIndex}'
5886
+ data-col-index='${sizeIndex}'
5881
5887
  `
5882
5888
  // if (useWidths === true) {
5883
5889
  // bodyHtml += `
@@ -5886,7 +5892,13 @@ class WebsyTable3 {
5886
5892
  // `
5887
5893
  // }
5888
5894
  bodyHtml += `
5889
- ><div style='${divStyle}'>`
5895
+ ><div
5896
+ style='${divStyle}'
5897
+ class='websy-table-cell-content'
5898
+ data-row-index='${rowIndex}'
5899
+ data-cell-index='${cellIndex}'
5900
+ data-col-index='${sizeIndex}'
5901
+ >`
5890
5902
  if (cell.expandable === true) {
5891
5903
  bodyHtml += `<i
5892
5904
  data-row-index='${rowIndex}'
@@ -5972,7 +5984,15 @@ class WebsyTable3 {
5972
5984
  // width='${col.width || col.actualWidth}'
5973
5985
  // `
5974
5986
  // }
5975
- headerHtml += `><div style='${divStyle}'>${col.name}${col.searchable === true ? this.buildSearchIcon(col, colIndex) : ''}</div></td>`
5987
+ headerHtml += `>
5988
+ <div
5989
+ style='${divStyle}'
5990
+ data-col-index="${colIndex}"
5991
+ class='${['asc', 'desc'].indexOf(col.sort) !== -1 ? 'sortable-column' : ''}'
5992
+ >
5993
+ ${col.name}${col.activeSort ? this.buildSortIcon(col.sort, colIndex) : ''}${col.searchable === true ? this.buildSearchIcon(col, colIndex) : ''}
5994
+ </div>
5995
+ </td>`
5976
5996
  })
5977
5997
  headerHtml += `</tr>`
5978
5998
  })
@@ -5992,8 +6012,14 @@ class WebsyTable3 {
5992
6012
  }
5993
6013
  buildSearchIcon (col, index) {
5994
6014
  // return `<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
5995
- return `<div class="websy-table-search-icon" data-col-index="${index}">
5996
- <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>
6015
+ return `<div class="websy-table-search-icon">
6016
+ <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 512 512"><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>
6017
+ </div>`
6018
+ }
6019
+ buildSortIcon (direction, index) {
6020
+ // return `<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
6021
+ return `<div class="websy-table-sort-icon ${direction}" data-col-index="${index}">
6022
+ <svg xmlns="http://www.w3.org/2000/svg" width="15" height="15" viewBox="0 0 512 512"><path d="M98,190.06,237.78,353.18a24,24,0,0,0,36.44,0L414,190.06c13.34-15.57,2.28-39.62-18.22-39.62H116.18C95.68,150.44,84.62,174.49,98,190.06Z"/></svg>
5997
6023
  </div>`
5998
6024
  }
5999
6025
  buildTotalHtml (useWidths = false) {
@@ -6167,9 +6193,9 @@ class WebsyTable3 {
6167
6193
  }
6168
6194
  handleClick (event) {
6169
6195
  const colIndex = +event.target.getAttribute('data-col-index')
6196
+ const cellIndex = +event.target.getAttribute('data-cell-index')
6170
6197
  const rowIndex = +event.target.getAttribute('data-row-index')
6171
6198
  if (event.target.classList.contains('websy-table-search-icon')) {
6172
- // console.log('clicked on search icon')
6173
6199
  if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
6174
6200
  this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex])
6175
6201
  }
@@ -6190,6 +6216,27 @@ class WebsyTable3 {
6190
6216
  // out of box function
6191
6217
  }
6192
6218
  }
6219
+ if (event.target.classList.contains('sortable-column')) {
6220
+ // const sortIndex = +event.target.getAttribute('data-sort-index')
6221
+ const column = this.options.columns[this.options.columns.length - 1][colIndex]
6222
+ if (this.options.onSort) {
6223
+ this.options.onSort(event, column, colIndex)
6224
+ }
6225
+ else {
6226
+ this.internalSort(column, colIndex)
6227
+ }
6228
+ }
6229
+ if (event.target.classList.contains('websy-table-cell-content')) {
6230
+ if (this.options.onCellSelect) {
6231
+ this.options.onCellSelect(event, {
6232
+ cellIndex,
6233
+ colIndex,
6234
+ rowIndex,
6235
+ cell: (this.currentData[rowIndex] || [])[cellIndex],
6236
+ column: (this.options.columns[this.options.columns.length - 1] || [])[colIndex]
6237
+ })
6238
+ }
6239
+ }
6193
6240
  }
6194
6241
  handleMouseDown (event) {
6195
6242
  if (event.target.classList.contains('websy-scroll-handle-y')) {
@@ -2781,8 +2781,6 @@ var WebsyNavigationMenu = /*#__PURE__*/function () {
2781
2781
  });
2782
2782
  });
2783
2783
  }
2784
-
2785
- console.log('visibleItems', visibleItems);
2786
2784
  }
2787
2785
  }, {
2788
2786
  key: "normaliseString",
@@ -5266,6 +5264,9 @@ var WebsyUtils = {
5266
5264
  },
5267
5265
  toQlikDateNum: function toQlikDateNum(d) {
5268
5266
  return Math.floor(d.getTime() / 86400000 + 25570);
5267
+ },
5268
+ toQlikDate: function toQlikDate(d) {
5269
+ return Math.floor(d.getTime() / 86400000 + 25570);
5269
5270
  }
5270
5271
  };
5271
5272
  /* global WebsyDesigns */
@@ -6276,6 +6277,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6276
6277
  };
6277
6278
  this.options = _extends({}, DEFAULTS, options);
6278
6279
  this.sizes = {};
6280
+ this.currentData = [];
6279
6281
  this.scrollDragging = false;
6280
6282
  this.cellDragging = false;
6281
6283
  this.vScrollRequired = false;
@@ -6329,8 +6331,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6329
6331
  if (bodyEl) {
6330
6332
  if (this.options.virtualScroll === true) {
6331
6333
  bodyEl.innerHTML = this.buildBodyHtml(data, true);
6334
+ this.currentData = data;
6332
6335
  } else {
6333
6336
  bodyEl.innerHTML += this.buildBodyHtml(data, true);
6337
+ this.currentData = this.currentData.concat(data);
6334
6338
  }
6335
6339
  } // this.data = this.data.concat(data)
6336
6340
  // this.rowCount = this.data.length
@@ -6402,14 +6406,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
6402
6406
  } // console.log('rowspan', cell.rowspan)
6403
6407
 
6404
6408
 
6405
- bodyHtml += "<td \n class='websy-table-cell ".concat(sizeIndex < _this37.pinnedColumns ? 'pinned' : 'unpinned', " ").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) {
6409
+ bodyHtml += "<td \n class='websy-table-cell ".concat(sizeIndex < _this37.pinnedColumns ? 'pinned' : 'unpinned', " ").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-cell-index='").concat(cellIndex, "'\n data-col-index='").concat(sizeIndex, "'\n "); // if (useWidths === true) {
6406
6410
  // bodyHtml += `
6407
6411
  // style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
6408
6412
  // width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
6409
6413
  // `
6410
6414
  // }
6411
6415
 
6412
- bodyHtml += "\n ><div style='".concat(divStyle, "'>");
6416
+ bodyHtml += "\n ><div \n style='".concat(divStyle, "' \n class='websy-table-cell-content'\n data-row-index='").concat(rowIndex, "'\n data-cell-index='").concat(cellIndex, "'\n data-col-index='").concat(sizeIndex, "'\n >");
6413
6417
 
6414
6418
  if (cell.expandable === true) {
6415
6419
  bodyHtml += "<i \n data-row-index='".concat(rowIndex, "'\n data-col-index='").concat(cell.level || cellIndex, "'\n class='websy-table-cell-expand'\n >").concat(_this37.options.plusIcon, "</i>");
@@ -6487,7 +6491,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6487
6491
  // `
6488
6492
  // }
6489
6493
 
6490
- headerHtml += "><div style='".concat(divStyle, "'>").concat(col.name).concat(col.searchable === true ? _this38.buildSearchIcon(col, colIndex) : '', "</div></td>");
6494
+ headerHtml += ">\n <div \n style='".concat(divStyle, "'\n data-col-index=\"").concat(colIndex, "\"\n class='").concat(['asc', 'desc'].indexOf(col.sort) !== -1 ? 'sortable-column' : '', "'\n >\n ").concat(col.name).concat(col.activeSort ? _this38.buildSortIcon(col.sort, colIndex) : '').concat(col.searchable === true ? _this38.buildSearchIcon(col, colIndex) : '', "\n </div>\n </td>");
6491
6495
  });
6492
6496
  headerHtml += "</tr>";
6493
6497
  });
@@ -6510,7 +6514,13 @@ var WebsyTable3 = /*#__PURE__*/function () {
6510
6514
  key: "buildSearchIcon",
6511
6515
  value: function buildSearchIcon(col, index) {
6512
6516
  // return `<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
6513
- return "<div class=\"websy-table-search-icon\" 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>");
6517
+ return "<div class=\"websy-table-search-icon\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"20\" height=\"20\" viewBox=\"0 0 512 512\"><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>";
6518
+ }
6519
+ }, {
6520
+ key: "buildSortIcon",
6521
+ value: function buildSortIcon(direction, index) {
6522
+ // return `<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
6523
+ return "<div class=\"websy-table-sort-icon ".concat(direction, "\" data-col-index=\"").concat(index, "\">\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"15\" height=\"15\" viewBox=\"0 0 512 512\"><path d=\"M98,190.06,237.78,353.18a24,24,0,0,0,36.44,0L414,190.06c13.34-15.57,2.28-39.62-18.22-39.62H116.18C95.68,150.44,84.62,174.49,98,190.06Z\"/></svg>\n </div>");
6514
6524
  }
6515
6525
  }, {
6516
6526
  key: "buildTotalHtml",
@@ -6722,10 +6732,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6722
6732
  key: "handleClick",
6723
6733
  value: function handleClick(event) {
6724
6734
  var colIndex = +event.target.getAttribute('data-col-index');
6735
+ var cellIndex = +event.target.getAttribute('data-cell-index');
6725
6736
  var rowIndex = +event.target.getAttribute('data-row-index');
6726
6737
 
6727
6738
  if (event.target.classList.contains('websy-table-search-icon')) {
6728
- // console.log('clicked on search icon')
6729
6739
  if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
6730
6740
  this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex]);
6731
6741
  }
@@ -6744,6 +6754,29 @@ var WebsyTable3 = /*#__PURE__*/function () {
6744
6754
  } else {// out of box function
6745
6755
  }
6746
6756
  }
6757
+
6758
+ if (event.target.classList.contains('sortable-column')) {
6759
+ // const sortIndex = +event.target.getAttribute('data-sort-index')
6760
+ var column = this.options.columns[this.options.columns.length - 1][colIndex];
6761
+
6762
+ if (this.options.onSort) {
6763
+ this.options.onSort(event, column, colIndex);
6764
+ } else {
6765
+ this.internalSort(column, colIndex);
6766
+ }
6767
+ }
6768
+
6769
+ if (event.target.classList.contains('websy-table-cell-content')) {
6770
+ if (this.options.onCellSelect) {
6771
+ this.options.onCellSelect(event, {
6772
+ cellIndex: cellIndex,
6773
+ colIndex: colIndex,
6774
+ rowIndex: rowIndex,
6775
+ cell: (this.currentData[rowIndex] || [])[cellIndex],
6776
+ column: (this.options.columns[this.options.columns.length - 1] || [])[colIndex]
6777
+ });
6778
+ }
6779
+ }
6747
6780
  }
6748
6781
  }, {
6749
6782
  key: "handleMouseDown",