ngx-deebodata 0.2.8 → 0.3.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.
@@ -375,6 +375,7 @@ class DataTableService {
375
375
  mapperWorkerId = 1;
376
376
  dTblHeight = 500;
377
377
  defltRHgt = "50px";
378
+ defltRHgtNum = 50;
378
379
  isSorting = signal(false, ...(ngDevMode ? [{ debugName: "isSorting" }] : /* istanbul ignore next */ []));
379
380
  isFiltering = signal(false, ...(ngDevMode ? [{ debugName: "isFiltering" }] : /* istanbul ignore next */ []));
380
381
  showCharts = signal(false, ...(ngDevMode ? [{ debugName: "showCharts" }] : /* istanbul ignore next */ []));
@@ -2393,7 +2394,7 @@ class RowGroupPanel {
2393
2394
  this.panelData = this.dataTableService.currFilData.filter(d => d[this.dataTableService.currGroup] === this.groupValue);
2394
2395
  this.count = this.panelData.length;
2395
2396
  let n = 0;
2396
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
2397
+ const defNum = this.dataTableService.defltRHgtNum;
2397
2398
  const init = Math.max(this.dataTableService.dTblHeight / defNum);
2398
2399
  const addCell = (text, prop, row, visible) => {
2399
2400
  if (prop && row) {
@@ -2489,8 +2490,7 @@ class RowGroupPanel {
2489
2490
  }
2490
2491
  setLastRowIndex() {
2491
2492
  const realMax = this.panelData.length - 1;
2492
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
2493
- const wannabeMax = (this.rows.length - 1) + Math.floor(this.aboveHgt / defNum);
2493
+ const wannabeMax = (this.rows.length - 1) + Math.floor(this.aboveHgt / this.dataTableService.defltRHgtNum);
2494
2494
  this.lastElRowIndex = Math.min(wannabeMax, realMax);
2495
2495
  return this.lastElRowIndex;
2496
2496
  }
@@ -2555,7 +2555,7 @@ class RowGroupPanel {
2555
2555
  const top = event.target.scrollTop;
2556
2556
  const left = event.target.scrollLeft;
2557
2557
  /*horiz scroll*/
2558
- requestAnimationFrame(() => { this.execHorizScroll(left); });
2558
+ this.execHorizScroll(left);
2559
2559
  /*horiz scroll*/
2560
2560
  /*vert scroll*/
2561
2561
  if (top === this.verticalRest) {
@@ -2563,7 +2563,7 @@ class RowGroupPanel {
2563
2563
  return this.setRowNumPlacement();
2564
2564
  }
2565
2565
  this.isScrolling = true;
2566
- requestAnimationFrame(() => { this.execVertScroll(top); });
2566
+ this.execVertScroll(top);
2567
2567
  /*vert scroll*/
2568
2568
  }
2569
2569
  execHorizScroll(left, reverse) {
@@ -2701,13 +2701,10 @@ class RowGroupPanel {
2701
2701
  return;
2702
2702
  const rTop = (bbds?.top - this.verticalRest);
2703
2703
  const gap = this.tblBot - rTop;
2704
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
2704
+ const defNum = this.dataTableService.defltRHgtNum;
2705
2705
  if (gap > 0) {
2706
2706
  let h = 0;
2707
2707
  let z = this.lastElRowIndex + 1;
2708
- const last = document.querySelector("#panelDataGrid" + this.elifyGrouping + " #dataTableRow" + this.lastElRowIndex);
2709
- if (last && this.dataTableService.elIsBelowFold(last, this.tblBot))
2710
- return;
2711
2708
  let bhToSub = 0;
2712
2709
  let ahToAdd = 0;
2713
2710
  const rowsInGap = Math.ceil(gap / defNum);
@@ -2745,10 +2742,10 @@ class RowGroupPanel {
2745
2742
  }
2746
2743
  h += 1;
2747
2744
  }
2748
- if (rowsToAdd.length)
2749
- this.rows = [...this.rows, ...rowsToAdd];
2750
2745
  if (bhToSub)
2751
2746
  this.belowHgt -= bhToSub;
2747
+ if (rowsToAdd.length)
2748
+ this.rows = [...this.rows, ...rowsToAdd];
2752
2749
  if (this.showRowNumbers)
2753
2750
  this.rowNums = [...this.rowNums, ...numsToAdd];
2754
2751
  if (ahToAdd)
@@ -2761,7 +2758,7 @@ class RowGroupPanel {
2761
2758
  const lastVisInd = this.columns.indexOf(this.dataTableService.visibleCols[(vlen - 1)]) + 1;
2762
2759
  const ael = this.aboveArea?.nativeElement;
2763
2760
  const abds = ael?.getBoundingClientRect();
2764
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
2761
+ const defNum = this.dataTableService.defltRHgtNum;
2765
2762
  const rbot = abds?.bottom || 0;
2766
2763
  const gap = rbot - this.tblTop;
2767
2764
  if (gap > 0) {
@@ -2772,6 +2769,7 @@ class RowGroupPanel {
2772
2769
  return;
2773
2770
  let bhToAdd = 0;
2774
2771
  let ahToSub = 0;
2772
+ let mRows = [...this.rows];
2775
2773
  const rowsInGap = Math.ceil(gap / defNum);
2776
2774
  const min = Math.max(0, (z - rowsInGap));
2777
2775
  for (z; z >= min; z--) {
@@ -2796,7 +2794,7 @@ class RowGroupPanel {
2796
2794
  cells.push(cell);
2797
2795
  }
2798
2796
  nRow.cells = [...cells];
2799
- this.rows = [nRow, ...this.rows];
2797
+ mRows = [nRow, ...mRows];
2800
2798
  if (this.showRowNumbers)
2801
2799
  this.rowNums = [(z + 1), ...this.rowNums];
2802
2800
  ahToSub += defNum;
@@ -2805,9 +2803,9 @@ class RowGroupPanel {
2805
2803
  }
2806
2804
  h += 1;
2807
2805
  }
2808
- if (ahToSub) {
2806
+ if (ahToSub)
2809
2807
  this.aboveHgt -= ahToSub;
2810
- }
2808
+ this.rows = [...mRows];
2811
2809
  if (bhToAdd)
2812
2810
  this.belowHgt += bhToAdd;
2813
2811
  }
@@ -2818,13 +2816,12 @@ class RowGroupPanel {
2818
2816
  const changes = justids.length;
2819
2817
  if (changes > 0) {
2820
2818
  const justindx = els.map((e, i) => i);
2821
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
2822
2819
  this.rows = this.rows.filter(r => !justids.includes(r.id));
2823
2820
  if (this.showRowNumbers)
2824
2821
  this.rowNums = this.rowNums.filter((c, i) => !justindx.includes(i));
2825
2822
  const item = this.dataTableService.mainData[(this.rows[0]?.index || -1)];
2826
2823
  if (item)
2827
- this.aboveHgt = this.dataTableService.findObjIndxInData(item, this.panelData) * defNum;
2824
+ this.aboveHgt = this.dataTableService.findObjIndxInData(item, this.panelData) * this.dataTableService.defltRHgtNum;
2828
2825
  }
2829
2826
  }
2830
2827
  clearBelowFoldRows() {
@@ -2832,7 +2829,6 @@ class RowGroupPanel {
2832
2829
  const justids = els.map(e => e.id);
2833
2830
  let changes = justids.length;
2834
2831
  if (changes > 0) {
2835
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
2836
2832
  this.rows = this.rows.filter(r => !justids.includes(r.id));
2837
2833
  if (this.showRowNumbers) {
2838
2834
  for (let p = (changes - 1); p >= 0; p--)
@@ -2841,7 +2837,7 @@ class RowGroupPanel {
2841
2837
  const rlen = this.rows.length;
2842
2838
  const item = this.dataTableService.mainData[(this.rows[(rlen - 1)]?.index || -1)];
2843
2839
  if (item)
2844
- this.belowHgt = ((this.panelData.length - 1) - this.dataTableService.findObjIndxInData(item, this.panelData)) * defNum;
2840
+ this.belowHgt = ((this.panelData.length - 1) - this.dataTableService.findObjIndxInData(item, this.panelData)) * this.dataTableService.defltRHgtNum;
2845
2841
  this.setLastRowIndex();
2846
2842
  }
2847
2843
  }
@@ -4873,8 +4869,10 @@ class NgxDeebodata {
4873
4869
  this.handleValidation();
4874
4870
  }
4875
4871
  execSetters() {
4876
- if (this.defRowHgt && /\d+px/g.test(this.defRowHgt))
4872
+ if (this.defRowHgt && /\d+px/g.test(this.defRowHgt)) {
4877
4873
  this.dataTableService.defltRHgt = this.defRowHgt;
4874
+ this.dataTableService.defltRHgtNum = parseInt(this.defRowHgt.replace(/[ ]?(px|vh|\%)/g, ""));
4875
+ }
4878
4876
  if (this.defGridHgt)
4879
4877
  this.dataTableService.dTblHeight = this.defGridHgt;
4880
4878
  if (this.myColumnSymbols)
@@ -5423,8 +5421,7 @@ class NgxDeebodata {
5423
5421
  }
5424
5422
  setLastRowIndex() {
5425
5423
  const realMax = this.dataTableService.currFilData.length - 1;
5426
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
5427
- const wannabeMax = (this.rows.length - 1) + Math.floor(this.aboveHgt() / defNum);
5424
+ const wannabeMax = (this.rows.length - 1) + Math.floor(this.aboveHgt() / this.dataTableService.defltRHgtNum);
5428
5425
  this.lastElRowIndex = Math.min(wannabeMax, realMax);
5429
5426
  return this.lastElRowIndex;
5430
5427
  }
@@ -5436,7 +5433,7 @@ class NgxDeebodata {
5436
5433
  const len = data.length;
5437
5434
  const colLen = cols.length;
5438
5435
  this.maxCols = this.setMaxCols();
5439
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
5436
+ const defNum = this.dataTableService.defltRHgtNum;
5440
5437
  const init = Math.max(this.dataTableService.dTblHeight / defNum);
5441
5438
  this.dataTableService.useColWid = Math.ceil((this.dataTableBody.nativeElement.getBoundingClientRect().width - 16) / Math.min(colLen, this.maxCols)) + "px";
5442
5439
  for (i; i < colLen; i++) {
@@ -5740,7 +5737,7 @@ class NgxDeebodata {
5740
5737
  const left = event.target.scrollLeft;
5741
5738
  /*horiz scroll*/
5742
5739
  if (left !== this.horizRest())
5743
- requestAnimationFrame(() => { this.execHorizScroll(left); });
5740
+ this.execHorizScroll(left);
5744
5741
  /*horiz scroll*/
5745
5742
  /*vert scroll*/
5746
5743
  if (top === this.verticalRest || this.lockVScroll) {
@@ -5750,7 +5747,7 @@ class NgxDeebodata {
5750
5747
  return this.setRowSelChecksPlacement();
5751
5748
  }
5752
5749
  this.isScrolling = true;
5753
- requestAnimationFrame(() => { this.execVertScroll(top); });
5750
+ this.execVertScroll(top);
5754
5751
  /*vert scroll*/
5755
5752
  if (top % 2 === 0)
5756
5753
  this.clearValidatedEdit();
@@ -5907,13 +5904,10 @@ class NgxDeebodata {
5907
5904
  const bbds = bel.getBoundingClientRect();
5908
5905
  const rTop = (bbds.top - this.verticalRest);
5909
5906
  const gap = this.dataTableService.tblBot - rTop;
5910
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
5907
+ const defNum = this.dataTableService.defltRHgtNum;
5911
5908
  if (gap > 0) {
5912
5909
  let h = 0;
5913
5910
  let z = this.lastElRowIndex + 1;
5914
- const last = document.getElementById("dataTableRow" + this.lastElRowIndex);
5915
- if (last && this.dataTableService.elIsBelowFold(last, this.dataTableService.tblBot))
5916
- return;
5917
5911
  let bhToSub = 0;
5918
5912
  let ahToAdd = 0;
5919
5913
  const rowsInGap = Math.ceil(gap / defNum);
@@ -5950,13 +5944,13 @@ class NgxDeebodata {
5950
5944
  }
5951
5945
  h += 1;
5952
5946
  }
5953
- this.rows = [...this.rows, ...rowsToAdd];
5954
5947
  if (bhToSub)
5955
5948
  this.belowHgt.set(Math.max(0, this.belowHgt() - bhToSub));
5956
- if (chksToAdd.length)
5957
- this.dtChecks = [...this.dtChecks, ...chksToAdd];
5949
+ this.rows = [...this.rows, ...rowsToAdd];
5958
5950
  if (ahToAdd)
5959
5951
  this.aboveHgt.set(this.aboveHgt() + ahToAdd);
5952
+ if (chksToAdd.length)
5953
+ this.dtChecks = [...this.dtChecks, ...chksToAdd];
5960
5954
  this.setLastRowIndex();
5961
5955
  }
5962
5956
  }
@@ -5966,7 +5960,7 @@ class NgxDeebodata {
5966
5960
  const lastVisInd = actvCols.indexOf(this.dataTableService.visibleCols[(vlen - 1)]) + 1;
5967
5961
  const ael = this.aboveArea.nativeElement;
5968
5962
  const abds = ael.getBoundingClientRect();
5969
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
5963
+ const defNum = this.dataTableService.defltRHgtNum;
5970
5964
  const rbot = abds.bottom;
5971
5965
  const gap = rbot - (this.dataTableService.tblTop);
5972
5966
  if (gap > 0) {
@@ -5977,6 +5971,8 @@ class NgxDeebodata {
5977
5971
  return;
5978
5972
  let bhToAdd = 0;
5979
5973
  let ahToSub = 0;
5974
+ let mRows = [...this.rows];
5975
+ let mChks = [...this.dtChecks];
5980
5976
  const rowsInGap = Math.ceil(gap / defNum);
5981
5977
  const min = Math.max(0, (z - rowsInGap));
5982
5978
  for (z; z >= min; z--) {
@@ -6001,8 +5997,8 @@ class NgxDeebodata {
6001
5997
  cells.push(cell);
6002
5998
  }
6003
5999
  nRow.cells = [...cells];
6004
- this.rows = [nRow, ...this.rows];
6005
- this.dtChecks = [index, ...this.dtChecks];
6000
+ mRows = [nRow, ...mRows];
6001
+ mChks = [index, ...mChks];
6006
6002
  ahToSub += defNum;
6007
6003
  }
6008
6004
  }
@@ -6011,8 +6007,10 @@ class NgxDeebodata {
6011
6007
  }
6012
6008
  if (ahToSub)
6013
6009
  this.aboveHgt.set(Math.max(0, (this.aboveHgt() - ahToSub)));
6010
+ this.rows = [...mRows];
6014
6011
  if (bhToAdd)
6015
6012
  this.belowHgt.set(this.belowHgt() + bhToAdd);
6013
+ this.dtChecks = [...mChks];
6016
6014
  }
6017
6015
  }
6018
6016
  clearAboveFoldRows() {
@@ -6021,12 +6019,11 @@ class NgxDeebodata {
6021
6019
  const justindx = els.map(e => e.index);
6022
6020
  const changes = justids.length;
6023
6021
  if (changes > 0) {
6024
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
6025
6022
  this.rows = this.rows.filter(r => justids.indexOf(r.id) < 0);
6026
6023
  this.dtChecks = this.dtChecks.filter(c => justindx.indexOf(c) < 0);
6027
6024
  const item = this.dataTableService.mainData[(this.rows[0]?.index || -1)];
6028
6025
  if (item)
6029
- this.aboveHgt.set(Math.max(0, this.dataTableService.findObjIndxInData(item, this.dataTableService.currFilData) * defNum));
6026
+ this.aboveHgt.set(Math.max(0, this.dataTableService.findObjIndxInData(item, this.dataTableService.currFilData) * this.dataTableService.defltRHgtNum));
6030
6027
  }
6031
6028
  }
6032
6029
  clearBelowFoldRows() {
@@ -6035,13 +6032,12 @@ class NgxDeebodata {
6035
6032
  const justindx = els.map(e => e.index);
6036
6033
  let changes = justids.length;
6037
6034
  if (changes > 0) {
6038
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
6039
6035
  this.rows = this.rows.filter(r => justids.indexOf(r.id) < 0);
6040
6036
  this.dtChecks = this.dtChecks.filter(c => justindx.indexOf(c) < 0);
6041
6037
  const rlen = this.rows.length;
6042
6038
  const item = this.dataTableService.mainData[(this.rows[(rlen - 1)]?.index || -1)];
6043
6039
  if (item)
6044
- this.belowHgt.set(Math.max(0, ((this.dataTableService.currFilData.length - 1) - this.dataTableService.findObjIndxInData(item, this.dataTableService.currFilData)) * defNum));
6040
+ this.belowHgt.set(Math.max(0, ((this.dataTableService.currFilData.length - 1) - this.dataTableService.findObjIndxInData(item, this.dataTableService.currFilData)) * this.dataTableService.defltRHgtNum));
6045
6041
  this.setLastRowIndex();
6046
6042
  }
6047
6043
  }
@@ -6049,8 +6045,7 @@ class NgxDeebodata {
6049
6045
  if (this.dataTableBody) {
6050
6046
  const ind = row - 1;
6051
6047
  const tbl = this.dataTableBody.nativeElement;
6052
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
6053
- tbl.scrollTop = ind * defNum;
6048
+ tbl.scrollTop = ind * this.dataTableService.defltRHgtNum;
6054
6049
  setTimeout(() => { this.setRowSelChecksPlacement(true); });
6055
6050
  }
6056
6051
  }
@@ -6625,7 +6620,7 @@ class NgxDeebodata {
6625
6620
  }
6626
6621
  this.lastElRowIndex = 0;
6627
6622
  let n = 0;
6628
- const defNum = parseInt(this.dataTableService.defltRHgt.replace(/[ ]?px/g, ""));
6623
+ const defNum = this.dataTableService.defltRHgtNum;
6629
6624
  const init = Math.max(this.dataTableService.dTblHeight / defNum);
6630
6625
  const len = this.dataTableService.currFilData.length;
6631
6626
  if (!len) { //always just add 1