@canvas-components/list-table 0.3.4 → 0.3.6

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/dist/index.js CHANGED
@@ -10253,6 +10253,25 @@ var ListTableAnimationController = class {
10253
10253
  }
10254
10254
  return getAnimationValue(animation, this.scheduler.now());
10255
10255
  }
10256
+ /**
10257
+ * 清理指定列的控制动画及历史值,避免离屏单元格再次出现时播放过期动画。
10258
+ */
10259
+ resetControlAnimationsForColumn(columnKey) {
10260
+ Array.from(this.runtime.controlAnimations.keys()).forEach((key) => {
10261
+ if (isControlAnimationKeyForColumn(key, columnKey)) {
10262
+ this.runtime.controlAnimations.delete(key);
10263
+ }
10264
+ });
10265
+ Array.from(this.runtime.lastControlValues.keys()).forEach((key) => {
10266
+ if (isControlAnimationKeyForColumn(key, columnKey)) {
10267
+ this.runtime.lastControlValues.delete(key);
10268
+ }
10269
+ });
10270
+ if (this.runtime.controlAnimations.size === 0 && this.runtime.controlAnimationFrameId != null) {
10271
+ this.scheduler.cancelAnimationFrame(this.runtime.controlAnimationFrameId);
10272
+ this.runtime.controlAnimationFrameId = null;
10273
+ }
10274
+ }
10256
10275
  getNestedTableHighlight(params) {
10257
10276
  return this.runtime.nestedTableHighlights.get(
10258
10277
  getNestedTableHighlightKey(
@@ -10463,6 +10482,14 @@ function createDefaultAnimationScheduler() {
10463
10482
  clearInterval: (id) => window.clearInterval(id)
10464
10483
  };
10465
10484
  }
10485
+ function isControlAnimationKeyForColumn(key, columnKey) {
10486
+ const contentSeparatorIndex = key.lastIndexOf("::");
10487
+ if (contentSeparatorIndex < 0) {
10488
+ return false;
10489
+ }
10490
+ const columnSeparatorIndex = key.lastIndexOf("::", contentSeparatorIndex - 1);
10491
+ return columnSeparatorIndex >= 0 && key.slice(columnSeparatorIndex + 2, contentSeparatorIndex) === columnKey;
10492
+ }
10466
10493
 
10467
10494
  // src/shared/carousel/carousel.ts
10468
10495
  function resolveCarouselScrollInterval(params) {
@@ -18076,6 +18103,7 @@ var ListTableHeaderActionController = class {
18076
18103
  this.options.clearExpandedRows();
18077
18104
  this.options.clearCollapsedRows();
18078
18105
  this.options.filterPanel.hide();
18106
+ this.options.persistColumnConfig();
18079
18107
  this.options.applyFilterQueryAsync();
18080
18108
  }
18081
18109
  };
@@ -18525,7 +18553,8 @@ var ListTablePersistenceController = class {
18525
18553
  __publicField(this, "options");
18526
18554
  this.options = options;
18527
18555
  }
18528
- async loadStoredConfig() {
18556
+ async loadStoredConfig(options = {}) {
18557
+ const { restoreQueryState = true } = options;
18529
18558
  const tableOptions = this.options.getOptions();
18530
18559
  const stored = await loadListTableStoredConfig({
18531
18560
  storageKey: tableOptions.storageKey,
@@ -18534,10 +18563,10 @@ var ListTablePersistenceController = class {
18534
18563
  if (!stored) {
18535
18564
  return;
18536
18565
  }
18537
- if (stored.sortState) {
18566
+ if (restoreQueryState && stored.sortState) {
18538
18567
  this.options.setSortState(stored.sortState);
18539
18568
  }
18540
- if (stored.filterState) {
18569
+ if (restoreQueryState && stored.filterState) {
18541
18570
  this.options.setFilterState(stored.filterState);
18542
18571
  }
18543
18572
  if (stored.zoom != null) {
@@ -21321,13 +21350,14 @@ function syncListTablePagination(params) {
21321
21350
  scrollPageSize
21322
21351
  },
21323
21352
  onChange: (page, nextPageSize) => {
21324
- store.dispatch(setPaginationAction(updatePaginationState(
21325
- store.getSnapshot().query.pagination,
21326
- {
21327
- currentPage: page,
21328
- pageSize: nextPageSize
21329
- }
21330
- )));
21353
+ store.dispatch(
21354
+ setPaginationAction(
21355
+ updatePaginationState(store.getSnapshot().query.pagination, {
21356
+ currentPage: page,
21357
+ pageSize: nextPageSize
21358
+ })
21359
+ )
21360
+ );
21331
21361
  if (options.pagination) {
21332
21362
  options.pagination.onChange?.(page, nextPageSize);
21333
21363
  }
@@ -21338,15 +21368,17 @@ function syncListTablePagination(params) {
21338
21368
  }
21339
21369
  },
21340
21370
  onPageSizeChange: (page, nextPageSize) => {
21341
- store.dispatch(setPaginationAction(updatePaginationState(
21342
- store.getSnapshot().query.pagination,
21343
- {
21344
- currentPage: page,
21345
- pageSize: nextPageSize
21346
- }
21347
- )));
21371
+ store.dispatch(
21372
+ setPaginationAction(
21373
+ updatePaginationState(store.getSnapshot().query.pagination, {
21374
+ currentPage: page,
21375
+ pageSize: nextPageSize
21376
+ })
21377
+ )
21378
+ );
21348
21379
  if (options.pagination) {
21349
21380
  options.pagination.onShowSizeChange?.(page, nextPageSize);
21381
+ options.pagination.onChange?.(page, nextPageSize);
21350
21382
  }
21351
21383
  if (options.query?.onChange) {
21352
21384
  emitQueryChange("paginate");
@@ -25734,6 +25766,9 @@ var ListTableRowActionController = class {
25734
25766
  if (!nextKeys) {
25735
25767
  return;
25736
25768
  }
25769
+ this.options.animationController.resetControlAnimationsForColumn(
25770
+ ROW_SELECTION_COLUMN_KEY
25771
+ );
25737
25772
  this.updateSelectedRowKeys(nextKeys, "all");
25738
25773
  this.options.requestRender();
25739
25774
  }
@@ -27198,7 +27233,7 @@ var ListTableCore = class {
27198
27233
  this.hideFloatingOverlays({ includeLoading: true });
27199
27234
  this.refreshRuntimeColumns();
27200
27235
  this.renderController.render();
27201
- this.persistenceController.loadStoredConfig();
27236
+ this.persistenceController.loadStoredConfig({ restoreQueryState: false });
27202
27237
  host.tableId = options.tableId?.trim() ? options.tableId : host.tableId;
27203
27238
  host.rowDragController.syncRegistration();
27204
27239
  }