@revolist/revogrid 3.5.2 → 3.6.1

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.
@@ -616,9 +616,10 @@ class DimensionProvider {
616
616
  const dimension = this.stores[type].getCurrentState();
617
617
  this.viewports.stores[type].setViewport({ virtualSize: dimension.realSize });
618
618
  }
619
- drop() {
619
+ dropColumns() {
620
620
  for (let type of columnTypes) {
621
621
  this.stores[type].drop();
622
+ this.viewports.stores[type].clear();
622
623
  }
623
624
  }
624
625
  setColumns(type, newLength, sizes, noVirtual = false) {
@@ -3351,7 +3352,7 @@ const RevoGridComponent = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
3351
3352
  }
3352
3353
  }
3353
3354
  columnChanged(newVal = []) {
3354
- this.dimensionProvider.drop();
3355
+ this.dimensionProvider.dropColumns();
3355
3356
  const columnGather = ColumnDataProvider.getColumns(newVal, 0, this.columnTypes);
3356
3357
  this.beforecolumnsset.emit(columnGather);
3357
3358
  for (let type of columnTypes) {
@@ -270,21 +270,23 @@ class ViewportStore {
270
270
  const outsize = frameOffset * 2 * dimension.originItemSize;
271
271
  virtualSize += outsize;
272
272
  let maxCoordinate = virtualSize;
273
+ // if real size is bigger than virtual size, then the end will be real size decreased by virtual size
274
+ // but sometimes the real size slightly bigger than virtual size, so we need to check it and fallback max coordinate to virtual size
273
275
  if (dimension.realSize > virtualSize) {
274
- maxCoordinate = dimension.realSize - virtualSize;
276
+ maxCoordinate = Math.max(dimension.realSize - virtualSize, virtualSize);
275
277
  }
276
278
  let toUpdate = {
277
279
  lastCoordinate: position,
278
280
  };
279
281
  let pos = position;
280
282
  pos -= frameOffset * dimension.originItemSize;
281
- pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;
283
+ pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate; // todo: check if maxCoordinate can be removed
282
284
  const firstItem = getFirstItem(this.getItems());
283
285
  const lastItem = getLastItem(this.getItems());
284
286
  // left position changed
285
287
  if (!isActiveRange(pos, firstItem)) {
286
288
  toUpdate = Object.assign(Object.assign({}, toUpdate), getUpdatedItemsByPosition(pos, this.getItems(), this.store.get('realCount'), virtualSize, dimension));
287
- setStore(this.store, Object.assign({}, toUpdate));
289
+ this.setViewport(Object.assign({}, toUpdate));
288
290
  // right position changed
289
291
  }
290
292
  else if (firstItem && this.store.get('virtualSize') + pos > (lastItem === null || lastItem === void 0 ? void 0 : lastItem.end)) {
@@ -298,7 +300,7 @@ class ViewportStore {
298
300
  };
299
301
  updateMissingAndRange(items, missing, range);
300
302
  toUpdate = Object.assign(Object.assign(Object.assign({}, toUpdate), { items: [...items] }), range);
301
- setStore(this.store, Object.assign({}, toUpdate));
303
+ this.setViewport(Object.assign({}, toUpdate));
302
304
  }
303
305
  }
304
306
  }
@@ -317,6 +319,7 @@ class ViewportStore {
317
319
  if (dropToOriginalSize) {
318
320
  items = setItemSizes(items, start, dropToOriginalSize, this.store.get('lastCoordinate'));
319
321
  }
322
+ console.log('items', items);
320
323
  // loop through array from initial item after recombination
321
324
  while (i < count) {
322
325
  const item = items[start];
@@ -340,7 +343,7 @@ class ViewportStore {
340
343
  start = 0;
341
344
  }
342
345
  }
343
- setStore(this.store, { items: [...items] });
346
+ this.setViewport({ items: [...items] });
344
347
  }
345
348
  getItems() {
346
349
  return {
@@ -4464,9 +4464,10 @@ class DimensionProvider {
4464
4464
  const dimension = this.stores[type].getCurrentState();
4465
4465
  this.viewports.stores[type].setViewport({ virtualSize: dimension.realSize });
4466
4466
  }
4467
- drop() {
4467
+ dropColumns() {
4468
4468
  for (let type of columnTypes) {
4469
4469
  this.stores[type].drop();
4470
+ this.viewports.stores[type].clear();
4470
4471
  }
4471
4472
  }
4472
4473
  setColumns(type, newLength, sizes, noVirtual = false) {
@@ -4766,21 +4767,23 @@ class ViewportStore {
4766
4767
  const outsize = frameOffset * 2 * dimension.originItemSize;
4767
4768
  virtualSize += outsize;
4768
4769
  let maxCoordinate = virtualSize;
4770
+ // if real size is bigger than virtual size, then the end will be real size decreased by virtual size
4771
+ // but sometimes the real size slightly bigger than virtual size, so we need to check it and fallback max coordinate to virtual size
4769
4772
  if (dimension.realSize > virtualSize) {
4770
- maxCoordinate = dimension.realSize - virtualSize;
4773
+ maxCoordinate = Math.max(dimension.realSize - virtualSize, virtualSize);
4771
4774
  }
4772
4775
  let toUpdate = {
4773
4776
  lastCoordinate: position,
4774
4777
  };
4775
4778
  let pos = position;
4776
4779
  pos -= frameOffset * dimension.originItemSize;
4777
- pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;
4780
+ pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate; // todo: check if maxCoordinate can be removed
4778
4781
  const firstItem = getFirstItem(this.getItems());
4779
4782
  const lastItem = getLastItem(this.getItems());
4780
4783
  // left position changed
4781
4784
  if (!isActiveRange(pos, firstItem)) {
4782
4785
  toUpdate = Object.assign(Object.assign({}, toUpdate), getUpdatedItemsByPosition(pos, this.getItems(), this.store.get('realCount'), virtualSize, dimension));
4783
- setStore(this.store, Object.assign({}, toUpdate));
4786
+ this.setViewport(Object.assign({}, toUpdate));
4784
4787
  // right position changed
4785
4788
  }
4786
4789
  else if (firstItem && this.store.get('virtualSize') + pos > (lastItem === null || lastItem === void 0 ? void 0 : lastItem.end)) {
@@ -4794,7 +4797,7 @@ class ViewportStore {
4794
4797
  };
4795
4798
  updateMissingAndRange(items, missing, range);
4796
4799
  toUpdate = Object.assign(Object.assign(Object.assign({}, toUpdate), { items: [...items] }), range);
4797
- setStore(this.store, Object.assign({}, toUpdate));
4800
+ this.setViewport(Object.assign({}, toUpdate));
4798
4801
  }
4799
4802
  }
4800
4803
  }
@@ -4813,6 +4816,7 @@ class ViewportStore {
4813
4816
  if (dropToOriginalSize) {
4814
4817
  items = setItemSizes(items, start, dropToOriginalSize, this.store.get('lastCoordinate'));
4815
4818
  }
4819
+ console.log('items', items);
4816
4820
  // loop through array from initial item after recombination
4817
4821
  while (i < count) {
4818
4822
  const item = items[start];
@@ -4836,7 +4840,7 @@ class ViewportStore {
4836
4840
  start = 0;
4837
4841
  }
4838
4842
  }
4839
- setStore(this.store, { items: [...items] });
4843
+ this.setViewport({ items: [...items] });
4840
4844
  }
4841
4845
  getItems() {
4842
4846
  return {
@@ -25269,7 +25273,7 @@ const RevoGridComponent = class {
25269
25273
  }
25270
25274
  }
25271
25275
  columnChanged(newVal = []) {
25272
- this.dimensionProvider.drop();
25276
+ this.dimensionProvider.dropColumns();
25273
25277
  const columnGather = ColumnDataProvider.getColumns(newVal, 0, this.columnTypes);
25274
25278
  this.beforecolumnsset.emit(columnGather);
25275
25279
  for (let type of columnTypes) {
@@ -387,7 +387,7 @@ export class RevoGridComponent {
387
387
  }
388
388
  }
389
389
  columnChanged(newVal = []) {
390
- this.dimensionProvider.drop();
390
+ this.dimensionProvider.dropColumns();
391
391
  const columnGather = ColumnDataProvider.getColumns(newVal, 0, this.columnTypes);
392
392
  this.beforecolumnsset.emit(columnGather);
393
393
  for (let type of columnTypes) {
@@ -55,9 +55,10 @@ export default class DimensionProvider {
55
55
  const dimension = this.stores[type].getCurrentState();
56
56
  this.viewports.stores[type].setViewport({ virtualSize: dimension.realSize });
57
57
  }
58
- drop() {
58
+ dropColumns() {
59
59
  for (let type of columnTypes) {
60
60
  this.stores[type].drop();
61
+ this.viewports.stores[type].clear();
61
62
  }
62
63
  }
63
64
  setColumns(type, newLength, sizes, noVirtual = false) {
@@ -40,21 +40,23 @@ export default class ViewportStore {
40
40
  const outsize = frameOffset * 2 * dimension.originItemSize;
41
41
  virtualSize += outsize;
42
42
  let maxCoordinate = virtualSize;
43
+ // if real size is bigger than virtual size, then the end will be real size decreased by virtual size
44
+ // but sometimes the real size slightly bigger than virtual size, so we need to check it and fallback max coordinate to virtual size
43
45
  if (dimension.realSize > virtualSize) {
44
- maxCoordinate = dimension.realSize - virtualSize;
46
+ maxCoordinate = Math.max(dimension.realSize - virtualSize, virtualSize);
45
47
  }
46
48
  let toUpdate = {
47
49
  lastCoordinate: position,
48
50
  };
49
51
  let pos = position;
50
52
  pos -= frameOffset * dimension.originItemSize;
51
- pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;
53
+ pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate; // todo: check if maxCoordinate can be removed
52
54
  const firstItem = getFirstItem(this.getItems());
53
55
  const lastItem = getLastItem(this.getItems());
54
56
  // left position changed
55
57
  if (!isActiveRange(pos, firstItem)) {
56
58
  toUpdate = Object.assign(Object.assign({}, toUpdate), getUpdatedItemsByPosition(pos, this.getItems(), this.store.get('realCount'), virtualSize, dimension));
57
- setStore(this.store, Object.assign({}, toUpdate));
59
+ this.setViewport(Object.assign({}, toUpdate));
58
60
  // right position changed
59
61
  }
60
62
  else if (firstItem && this.store.get('virtualSize') + pos > (lastItem === null || lastItem === void 0 ? void 0 : lastItem.end)) {
@@ -68,7 +70,7 @@ export default class ViewportStore {
68
70
  };
69
71
  updateMissingAndRange(items, missing, range);
70
72
  toUpdate = Object.assign(Object.assign(Object.assign({}, toUpdate), { items: [...items] }), range);
71
- setStore(this.store, Object.assign({}, toUpdate));
73
+ this.setViewport(Object.assign({}, toUpdate));
72
74
  }
73
75
  }
74
76
  }
@@ -87,6 +89,7 @@ export default class ViewportStore {
87
89
  if (dropToOriginalSize) {
88
90
  items = setItemSizes(items, start, dropToOriginalSize, this.store.get('lastCoordinate'));
89
91
  }
92
+ console.log('items', items);
90
93
  // loop through array from initial item after recombination
91
94
  while (i < count) {
92
95
  const item = items[start];
@@ -110,7 +113,7 @@ export default class ViewportStore {
110
113
  start = 0;
111
114
  }
112
115
  }
113
- setStore(this.store, { items: [...items] });
116
+ this.setViewport({ items: [...items] });
114
117
  }
115
118
  getItems() {
116
119
  return {
@@ -4460,9 +4460,10 @@ class DimensionProvider {
4460
4460
  const dimension = this.stores[type].getCurrentState();
4461
4461
  this.viewports.stores[type].setViewport({ virtualSize: dimension.realSize });
4462
4462
  }
4463
- drop() {
4463
+ dropColumns() {
4464
4464
  for (let type of columnTypes) {
4465
4465
  this.stores[type].drop();
4466
+ this.viewports.stores[type].clear();
4466
4467
  }
4467
4468
  }
4468
4469
  setColumns(type, newLength, sizes, noVirtual = false) {
@@ -4762,21 +4763,23 @@ class ViewportStore {
4762
4763
  const outsize = frameOffset * 2 * dimension.originItemSize;
4763
4764
  virtualSize += outsize;
4764
4765
  let maxCoordinate = virtualSize;
4766
+ // if real size is bigger than virtual size, then the end will be real size decreased by virtual size
4767
+ // but sometimes the real size slightly bigger than virtual size, so we need to check it and fallback max coordinate to virtual size
4765
4768
  if (dimension.realSize > virtualSize) {
4766
- maxCoordinate = dimension.realSize - virtualSize;
4769
+ maxCoordinate = Math.max(dimension.realSize - virtualSize, virtualSize);
4767
4770
  }
4768
4771
  let toUpdate = {
4769
4772
  lastCoordinate: position,
4770
4773
  };
4771
4774
  let pos = position;
4772
4775
  pos -= frameOffset * dimension.originItemSize;
4773
- pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;
4776
+ pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate; // todo: check if maxCoordinate can be removed
4774
4777
  const firstItem = getFirstItem(this.getItems());
4775
4778
  const lastItem = getLastItem(this.getItems());
4776
4779
  // left position changed
4777
4780
  if (!isActiveRange(pos, firstItem)) {
4778
4781
  toUpdate = Object.assign(Object.assign({}, toUpdate), getUpdatedItemsByPosition(pos, this.getItems(), this.store.get('realCount'), virtualSize, dimension));
4779
- setStore(this.store, Object.assign({}, toUpdate));
4782
+ this.setViewport(Object.assign({}, toUpdate));
4780
4783
  // right position changed
4781
4784
  }
4782
4785
  else if (firstItem && this.store.get('virtualSize') + pos > (lastItem === null || lastItem === void 0 ? void 0 : lastItem.end)) {
@@ -4790,7 +4793,7 @@ class ViewportStore {
4790
4793
  };
4791
4794
  updateMissingAndRange(items, missing, range);
4792
4795
  toUpdate = Object.assign(Object.assign(Object.assign({}, toUpdate), { items: [...items] }), range);
4793
- setStore(this.store, Object.assign({}, toUpdate));
4796
+ this.setViewport(Object.assign({}, toUpdate));
4794
4797
  }
4795
4798
  }
4796
4799
  }
@@ -4809,6 +4812,7 @@ class ViewportStore {
4809
4812
  if (dropToOriginalSize) {
4810
4813
  items = setItemSizes(items, start, dropToOriginalSize, this.store.get('lastCoordinate'));
4811
4814
  }
4815
+ console.log('items', items);
4812
4816
  // loop through array from initial item after recombination
4813
4817
  while (i < count) {
4814
4818
  const item = items[start];
@@ -4832,7 +4836,7 @@ class ViewportStore {
4832
4836
  start = 0;
4833
4837
  }
4834
4838
  }
4835
- setStore(this.store, { items: [...items] });
4839
+ this.setViewport({ items: [...items] });
4836
4840
  }
4837
4841
  getItems() {
4838
4842
  return {
@@ -25265,7 +25269,7 @@ const RevoGridComponent = class {
25265
25269
  }
25266
25270
  }
25267
25271
  columnChanged(newVal = []) {
25268
- this.dimensionProvider.drop();
25272
+ this.dimensionProvider.dropColumns();
25269
25273
  const columnGather = ColumnDataProvider.getColumns(newVal, 0, this.columnTypes);
25270
25274
  this.beforecolumnsset.emit(columnGather);
25271
25275
  for (let type of columnTypes) {