@limetech/lime-elements 37.55.1 → 37.55.2

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## [37.55.2](https://github.com/Lundalogik/lime-elements/compare/v37.55.1...v37.55.2) (2024-07-29)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+
7
+ * **table:** make sorting work again ([2834ccd](https://github.com/Lundalogik/lime-elements/commit/2834ccd04df027cb440f2bb5f60df8dd535013fe))
8
+
1
9
  ## [37.55.1](https://github.com/Lundalogik/lime-elements/compare/v37.55.0...v37.55.1) (2024-07-29)
2
10
 
3
11
 
@@ -24260,18 +24260,18 @@ const Table = class {
24260
24260
  this.formatRows();
24261
24261
  }
24262
24262
  updateData(newData = [], oldData = []) {
24263
- const newIds = new Set(newData.map((item) => { var _a; return (_a = item.id) !== null && _a !== void 0 ? _a : item; }));
24264
- if (oldData.every((item) => { var _a; return newIds.has((_a = item.id) !== null && _a !== void 0 ? _a : item); })) {
24265
- this.tabulator.updateOrAddData(newData);
24266
- return;
24267
- }
24268
24263
  this.pool.releaseAll();
24264
+ const shouldReplace = this.shouldReplaceData(newData, oldData);
24269
24265
  setTimeout(() => {
24270
24266
  if (!this.tabulator) {
24271
24267
  return;
24272
24268
  }
24273
- this.tabulator.replaceData(this.data);
24274
- this.setSelection();
24269
+ if (shouldReplace) {
24270
+ this.tabulator.replaceData(newData);
24271
+ this.setSelection();
24272
+ return;
24273
+ }
24274
+ this.tabulator.updateOrAddData(newData);
24275
24275
  });
24276
24276
  }
24277
24277
  updateColumns(newColumns, oldColumns) {
@@ -24327,6 +24327,21 @@ const Table = class {
24327
24327
  }
24328
24328
  this.tabulator.setSort(newSorting);
24329
24329
  }
24330
+ shouldReplaceData(newData, oldData) {
24331
+ const newIds = newData.map((item) => { var _a; return (_a = item.id) !== null && _a !== void 0 ? _a : item; });
24332
+ const oldIds = oldData.map((item) => { var _a; return (_a = item.id) !== null && _a !== void 0 ? _a : item; });
24333
+ return (!this.areEqualIds(newIds, oldIds) ||
24334
+ !this.isSameOrder(newIds, oldIds));
24335
+ }
24336
+ areEqualIds(newIds, oldIds) {
24337
+ const newIdSet = new Set(newIds);
24338
+ const oldIdSet = new Set(oldIds);
24339
+ return (newIdSet.size === oldIdSet.size &&
24340
+ newIds.every((id) => oldIdSet.has(id)));
24341
+ }
24342
+ isSameOrder(newIds, oldIds) {
24343
+ return newIds.every((id, index) => id === oldIds[index]);
24344
+ }
24330
24345
  areSameColumns(newColumns, oldColumns) {
24331
24346
  return (newColumns.length === oldColumns.length &&
24332
24347
  newColumns.every((column) => oldColumns.includes(column)));