@websy/websy-designs 1.4.28 → 1.4.30

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.
@@ -5731,10 +5731,11 @@ class WebsyTable3 {
5731
5731
  allowPivoting: false,
5732
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>`,
5733
5733
  plusIcon: WebsyDesigns.Icons.PlusFilled,
5734
- minusIcon: WebsyDesigns.Icons.MinusFilled
5734
+ minusIcon: WebsyDesigns.Icons.MinusFilled
5735
5735
  }
5736
5736
  this.options = Object.assign({}, DEFAULTS, options)
5737
5737
  this.sizes = {}
5738
+ this.currentData = []
5738
5739
  this.scrollDragging = false
5739
5740
  this.cellDragging = false
5740
5741
  this.vScrollRequired = false
@@ -5811,14 +5812,16 @@ class WebsyTable3 {
5811
5812
  this.renderTotals()
5812
5813
  }
5813
5814
  appendRows (data) {
5814
- this.hideError()
5815
+ this.hideError()
5815
5816
  let bodyEl = document.getElementById(`${this.elementId}_tableBody`)
5816
5817
  if (bodyEl) {
5817
5818
  if (this.options.virtualScroll === true) {
5818
5819
  bodyEl.innerHTML = this.buildBodyHtml(data, true)
5820
+ this.currentData = data
5819
5821
  }
5820
5822
  else {
5821
5823
  bodyEl.innerHTML += this.buildBodyHtml(data, true)
5824
+ this.currentData = this.currentData.concat(data)
5822
5825
  }
5823
5826
  }
5824
5827
  // this.data = this.data.concat(data)
@@ -5879,7 +5882,8 @@ class WebsyTable3 {
5879
5882
  colspan='${cell.colspan || 1}'
5880
5883
  rowspan='${cell.rowspan || 1}'
5881
5884
  data-row-index='${rowIndex}'
5882
- data-col-index='${cellIndex}'
5885
+ data-cell-index='${cellIndex}'
5886
+ data-col-index='${sizeIndex}'
5883
5887
  `
5884
5888
  // if (useWidths === true) {
5885
5889
  // bodyHtml += `
@@ -5888,7 +5892,13 @@ class WebsyTable3 {
5888
5892
  // `
5889
5893
  // }
5890
5894
  bodyHtml += `
5891
- ><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
+ >`
5892
5902
  if (cell.expandable === true) {
5893
5903
  bodyHtml += `<i
5894
5904
  data-row-index='${rowIndex}'
@@ -5974,7 +5984,15 @@ class WebsyTable3 {
5974
5984
  // width='${col.width || col.actualWidth}'
5975
5985
  // `
5976
5986
  // }
5977
- 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>`
5978
5996
  })
5979
5997
  headerHtml += `</tr>`
5980
5998
  })
@@ -5995,7 +6013,13 @@ class WebsyTable3 {
5995
6013
  buildSearchIcon (col, index) {
5996
6014
  // return `<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
5997
6015
  return `<div class="websy-table-search-icon" data-col-index="${index}">
5998
- <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>
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>
5999
6023
  </div>`
6000
6024
  }
6001
6025
  buildTotalHtml (useWidths = false) {
@@ -6169,9 +6193,9 @@ class WebsyTable3 {
6169
6193
  }
6170
6194
  handleClick (event) {
6171
6195
  const colIndex = +event.target.getAttribute('data-col-index')
6196
+ const cellIndex = +event.target.getAttribute('data-cell-index')
6172
6197
  const rowIndex = +event.target.getAttribute('data-row-index')
6173
6198
  if (event.target.classList.contains('websy-table-search-icon')) {
6174
- // console.log('clicked on search icon')
6175
6199
  if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
6176
6200
  this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex])
6177
6201
  }
@@ -6192,6 +6216,27 @@ class WebsyTable3 {
6192
6216
  // out of box function
6193
6217
  }
6194
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
+ }
6195
6240
  }
6196
6241
  handleMouseDown (event) {
6197
6242
  if (event.target.classList.contains('websy-scroll-handle-y')) {
@@ -6277,6 +6277,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6277
6277
  };
6278
6278
  this.options = _extends({}, DEFAULTS, options);
6279
6279
  this.sizes = {};
6280
+ this.currentData = [];
6280
6281
  this.scrollDragging = false;
6281
6282
  this.cellDragging = false;
6282
6283
  this.vScrollRequired = false;
@@ -6330,8 +6331,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6330
6331
  if (bodyEl) {
6331
6332
  if (this.options.virtualScroll === true) {
6332
6333
  bodyEl.innerHTML = this.buildBodyHtml(data, true);
6334
+ this.currentData = data;
6333
6335
  } else {
6334
6336
  bodyEl.innerHTML += this.buildBodyHtml(data, true);
6337
+ this.currentData = this.currentData.concat(data);
6335
6338
  }
6336
6339
  } // this.data = this.data.concat(data)
6337
6340
  // this.rowCount = this.data.length
@@ -6403,14 +6406,14 @@ var WebsyTable3 = /*#__PURE__*/function () {
6403
6406
  } // console.log('rowspan', cell.rowspan)
6404
6407
 
6405
6408
 
6406
- 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) {
6407
6410
  // bodyHtml += `
6408
6411
  // style='width: ${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}px!important'
6409
6412
  // width='${sizingColumns[cellIndex].width || sizingColumns[cellIndex].actualWidth}'
6410
6413
  // `
6411
6414
  // }
6412
6415
 
6413
- 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 >");
6414
6417
 
6415
6418
  if (cell.expandable === true) {
6416
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>");
@@ -6488,7 +6491,7 @@ var WebsyTable3 = /*#__PURE__*/function () {
6488
6491
  // `
6489
6492
  // }
6490
6493
 
6491
- 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>");
6492
6495
  });
6493
6496
  headerHtml += "</tr>";
6494
6497
  });
@@ -6511,7 +6514,13 @@ var WebsyTable3 = /*#__PURE__*/function () {
6511
6514
  key: "buildSearchIcon",
6512
6515
  value: function buildSearchIcon(col, index) {
6513
6516
  // return `<div class="websy-table-search-icon" data-col-id="${col.dimId}" data-col-index="${index}">
6514
- 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\" data-col-index=\"".concat(index, "\">\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>");
6515
6524
  }
6516
6525
  }, {
6517
6526
  key: "buildTotalHtml",
@@ -6723,10 +6732,10 @@ var WebsyTable3 = /*#__PURE__*/function () {
6723
6732
  key: "handleClick",
6724
6733
  value: function handleClick(event) {
6725
6734
  var colIndex = +event.target.getAttribute('data-col-index');
6735
+ var cellIndex = +event.target.getAttribute('data-cell-index');
6726
6736
  var rowIndex = +event.target.getAttribute('data-row-index');
6727
6737
 
6728
6738
  if (event.target.classList.contains('websy-table-search-icon')) {
6729
- // console.log('clicked on search icon')
6730
6739
  if (this.options.columns[this.options.columns.length - 1][colIndex].onSearch) {
6731
6740
  this.options.columns[this.options.columns.length - 1][colIndex].onSearch(event, this.options.columns[this.options.columns.length - 1][colIndex]);
6732
6741
  }
@@ -6745,6 +6754,29 @@ var WebsyTable3 = /*#__PURE__*/function () {
6745
6754
  } else {// out of box function
6746
6755
  }
6747
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
+ }
6748
6780
  }
6749
6781
  }, {
6750
6782
  key: "handleMouseDown",