@taocompany/magic-grid 0.4.6 → 0.4.8

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.es.js CHANGED
@@ -9044,7 +9044,7 @@ var Dm = class {
9044
9044
  deferRowDestroyOnScroll = !1;
9045
9045
  cellRendererPresentation = "deferred";
9046
9046
  scrollActive = !1;
9047
- pendingDestroyTasks = [];
9047
+ pendingDestroyTasks = /* @__PURE__ */ new Map();
9048
9048
  constructor(e, t) {
9049
9049
  this.rowsContainer = e, this.rowModel = t.rowModel, this.columnModel = t.columnModel, this.rowHeight = t.rowHeight ?? me, this.rowBuffer = t.rowBuffer ?? 10, this.stripe = t.stripe ?? !1, this.frameService = t.frameService ?? null, this.onUnmountRenderer = t.onUnmountRenderer, this.onUnmountEditor = t.onUnmountEditor, this.indexColumnOptions = t.indexColumnOptions, this.selectionColumnOptions = t.selectionColumnOptions, this.rowAutoHeightService = t.rowAutoHeightService ?? null, this.isRowDragHandleEnabled = t.isRowDragHandleEnabled, this.enableCellSpan = t.enableCellSpan ?? !1, this.cellSpanService = t.cellSpanService ?? null, this.embedFullWidthRows = t.embedFullWidthRows ?? !1, this.rowExpansionHost = t.rowExpansionHost, this.rowGroupingHost = t.rowGroupingHost, this.treeTableHost = t.treeTableHost, this.cellCommentHost = t.cellCommentHost, this.resolveBusinessRowId = t.resolveBusinessRowId, this.getCellDisableContext = t.getCellDisableContext ?? this.getCellDisableContext, this.getCellStyleContext = t.getCellStyleContext ?? this.getCellStyleContext, this.cellRendererDefer = t.cellRendererDefer ?? "always", this.deferRowDestroyOnScroll = t.deferRowDestroyOnScroll ?? !1, this.cellRendererPresentation = t.cellRendererPresentation ?? "deferred", this.rowCompFactory = t.rowCompFactory ?? { create: () => new Om(this.rowsContainer, {
9050
9050
  stripe: this.stripe,
@@ -9170,14 +9170,17 @@ var Dm = class {
9170
9170
  return e;
9171
9171
  }
9172
9172
  flushDeferredDestroys() {
9173
- if (this.pendingDestroyTasks.length === 0) return;
9174
- let e = this.pendingDestroyTasks.splice(0);
9175
- if (this.frameService && !this.compressedScroll) {
9173
+ if (this.pendingDestroyTasks.size === 0) return;
9174
+ let e = [...this.pendingDestroyTasks.values()];
9175
+ if (this.pendingDestroyTasks.clear(), this.frameService && !this.compressedScroll) {
9176
9176
  for (let t of e) this.frameService.addDestroyTask(t);
9177
9177
  return;
9178
9178
  }
9179
9179
  for (let t of e) t();
9180
9180
  }
9181
+ cancelPendingDestroy(e) {
9182
+ this.pendingDestroyTasks.delete(e);
9183
+ }
9181
9184
  redraw(e, t, n, r = !1) {
9182
9185
  this.scrollTop = e, this.columnWindow = n;
9183
9186
  let i = {
@@ -9203,7 +9206,7 @@ var Dm = class {
9203
9206
  this.rowPool.clear(), this.spannedRowRenderer?.destroy(), this.fullWidthRowRenderer?.destroy(), this.activeIndices.clear();
9204
9207
  }
9205
9208
  invalidate() {
9206
- this.frameService && this.frameService.flushAllFrames(), this.rowPool.clear(), this.spannedRowRenderer?.invalidate(), this.fullWidthRowRenderer?.invalidate(), this.activeIndices.clear(), this.currentWindow = {
9209
+ this.frameService && this.frameService.flushAllFrames(), this.pendingDestroyTasks.clear(), this.rowPool.clear(), this.spannedRowRenderer?.invalidate(), this.fullWidthRowRenderer?.invalidate(), this.activeIndices.clear(), this.currentWindow = {
9207
9210
  firstRow: 0,
9208
9211
  lastRow: -1,
9209
9212
  firstCol: 0,
@@ -9387,7 +9390,7 @@ var Dm = class {
9387
9390
  let n = t.id, r = () => {
9388
9391
  this.rowPool.release(n);
9389
9392
  };
9390
- this.frameService && !this.compressedScroll ? this.deferRowDestroyOnScroll && this.scrollActive ? this.pendingDestroyTasks.push(r) : this.frameService.addDestroyTask(r) : r();
9393
+ this.frameService && !this.compressedScroll ? this.deferRowDestroyOnScroll && this.scrollActive ? this.pendingDestroyTasks.set(n, r) : this.frameService.addDestroyTask(r) : r();
9391
9394
  }
9392
9395
  for (let e of n.toUpdate) this.updateRowAtIndex(e, t ? { columnStructureChanged: !0 } : void 0);
9393
9396
  for (let e of n.toCreate) {
@@ -9405,6 +9408,7 @@ var Dm = class {
9405
9408
  updateRowAtIndex(e, t) {
9406
9409
  let n = this.rowModel.getRow(e);
9407
9410
  if (!n || U(n) && !this.embedFullWidthRows) return;
9411
+ this.cancelPendingDestroy(n.id);
9408
9412
  let r = this.rowPool.acquire(n.id, () => this.rowCompFactory.create()), i = this.rowModel.getRowCount();
9409
9413
  r.setData(n, this.columnModel, this.columnWindow, this.valueCacheVersion, i > 0 && e === i - 1, t), r.setRowTop(this.compressedScroll ? n.rowTop - this.scrollTop : n.rowTop), r.setSelected?.(this.selectedRowIds.has(n.id)), r.setSelectionDisabled?.(!this.isRowNodeSelectable(n)), r.setIndexFocused?.(this.indexFocusedRowIds.has(n.id)), r.setIndexColumnRangeHighlight?.(this.indexColumnHighlightChecker?.(e) ?? !1), r.setFocusedColId?.(this.focusedCell?.rowId === n.id ? this.focusedCell.colId : null);
9410
9414
  }