@taocompany/magic-grid 0.12.4 → 0.12.5

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
@@ -2503,7 +2503,7 @@ function zs(e) {
2503
2503
  }
2504
2504
  //#endregion
2505
2505
  //#region src/core/types/loadMoreRow.ts
2506
- var Bs = "__MG_LOAD_MORE__", Vs = ji(Ci), Hs = "mg-full-width-row--load-more", Us = "mg-full-width-row__load-more-viewport";
2506
+ var Bs = "__MG_LOAD_MORE__", Vs = ji(Ci), Hs = "mg-full-width-row--load-more", Us = "mg-full-width-row__load-more-anchor";
2507
2507
  function Ws(e = {}) {
2508
2508
  return {
2509
2509
  loadMore: e.loadMore?.trim() || "加载更多",
@@ -12420,15 +12420,16 @@ function Db(e, t) {
12420
12420
  }
12421
12421
  var Ob = class {
12422
12422
  element;
12423
- viewportEl;
12424
12423
  contentEl;
12425
- frameService;
12426
12424
  onUnmountRenderer;
12427
12425
  loadMoreRowRenderer;
12428
12426
  rowNode = null;
12429
12427
  renderParams = null;
12428
+ layoutTop = NaN;
12430
12429
  constructor(e, t = {}) {
12431
- this.frameService = t.frameService ?? null, this.onUnmountRenderer = t.onUnmountRenderer, this.element = document.createElement("div"), this.element.className = `${St} ${Hs}`, this.element.dataset.rowKind = "LOAD_MORE", this.viewportEl = document.createElement("div"), this.viewportEl.className = Us, this.contentEl = document.createElement("div"), this.contentEl.className = Ct, this.viewportEl.appendChild(this.contentEl), this.element.appendChild(this.viewportEl), e.appendChild(this.element);
12430
+ this.onUnmountRenderer = t.onUnmountRenderer, this.element = document.createElement("div"), this.element.className = `${St} ${Hs}`, this.element.dataset.rowKind = "LOAD_MORE";
12431
+ let n = document.createElement("div");
12432
+ n.className = Us, this.contentEl = document.createElement("div"), this.contentEl.className = Ct, n.appendChild(this.contentEl), this.element.appendChild(n), e.appendChild(this.element);
12432
12433
  }
12433
12434
  setLoadMoreRowRenderer(e) {
12434
12435
  this.loadMoreRowRenderer = e, this.renderParams && this.renderContent(this.renderParams);
@@ -12445,18 +12446,15 @@ var Ob = class {
12445
12446
  syncRowLayout(e) {
12446
12447
  this.rowNode = e, this.element.style.height = `${e.rowHeight}px`;
12447
12448
  }
12448
- syncViewportWidth(e) {
12449
- this.viewportEl.style.width = `${e}px`;
12450
- }
12451
12449
  setRowTop(e) {
12452
- this.element.style.transform = `translateY(${e}px)`;
12450
+ let t = Math.round(e);
12451
+ t !== this.layoutTop && (this.layoutTop = t, this.element.style.transform = `translate3d(0, ${t}px, 0)`);
12453
12452
  }
12454
12453
  destroy() {
12455
12454
  this.onUnmountRenderer?.(this.contentEl), this.contentEl.replaceChildren(), this.element.remove(), this.rowNode = null, this.renderParams = null;
12456
12455
  }
12457
12456
  renderContent(e) {
12458
12457
  ic(this.contentEl, e, this.loadMoreRowRenderer, {
12459
- frameService: this.frameService,
12460
12458
  onUnmountRenderer: this.onUnmountRenderer,
12461
12459
  rowIndex: this.rowNode?.rowIndex ?? 0
12462
12460
  });
@@ -12478,9 +12476,7 @@ var Ob = class {
12478
12476
  }, Ab = class {
12479
12477
  container;
12480
12478
  rowModel;
12481
- columnModel;
12482
12479
  rowPool = new kb();
12483
- frameService;
12484
12480
  onUnmountRenderer;
12485
12481
  getLoadMoreRowEnabled;
12486
12482
  getLoadMoreRowRenderer;
@@ -12490,14 +12486,13 @@ var Ob = class {
12490
12486
  getLoadMoreRowLabels;
12491
12487
  onLoadMore;
12492
12488
  getApi;
12493
- getViewportClientWidth;
12494
12489
  compressedScroll = !1;
12495
12490
  scrollTop = 0;
12496
12491
  invokeLoadMore = () => {
12497
12492
  this.onLoadMore?.();
12498
12493
  };
12499
12494
  constructor(e) {
12500
- this.container = e.container, this.rowModel = e.rowModel, this.columnModel = e.columnModel, this.frameService = e.frameService ?? null, this.onUnmountRenderer = e.onUnmountRenderer, this.getLoadMoreRowEnabled = e.getLoadMoreRowEnabled, this.getLoadMoreRowRenderer = e.getLoadMoreRowRenderer, this.getLoadMoreRowLoading = e.getLoadMoreRowLoading, this.getLoadMoreRowHasMore = e.getLoadMoreRowHasMore, this.getLoadMoreRowGridSize = e.getLoadMoreRowGridSize, this.getLoadMoreRowLabels = e.getLoadMoreRowLabels, this.onLoadMore = e.onLoadMore, this.getApi = e.getApi, this.getViewportClientWidth = e.getViewportClientWidth;
12495
+ this.container = e.container, this.rowModel = e.rowModel, this.onUnmountRenderer = e.onUnmountRenderer, this.getLoadMoreRowEnabled = e.getLoadMoreRowEnabled, this.getLoadMoreRowRenderer = e.getLoadMoreRowRenderer, this.getLoadMoreRowLoading = e.getLoadMoreRowLoading, this.getLoadMoreRowHasMore = e.getLoadMoreRowHasMore, this.getLoadMoreRowGridSize = e.getLoadMoreRowGridSize, this.getLoadMoreRowLabels = e.getLoadMoreRowLabels, this.onLoadMore = e.onLoadMore, this.getApi = e.getApi;
12501
12496
  }
12502
12497
  setCompressedScroll(e) {
12503
12498
  this.compressedScroll = e;
@@ -12522,7 +12517,7 @@ var Ob = class {
12522
12517
  return;
12523
12518
  }
12524
12519
  if (this.rowPool.get()) {
12525
- this.syncLoadMoreRowLayout(i);
12520
+ this.applyLoadMoreRowLayout(i);
12526
12521
  return;
12527
12522
  }
12528
12523
  this.updateLoadMoreRow(i);
@@ -12534,17 +12529,20 @@ var Ob = class {
12534
12529
  !t || t.rowKind !== "LOAD_MORE" || this.updateLoadMoreRow(t);
12535
12530
  }
12536
12531
  syncColumnLayouts() {
12537
- this.rowPool.get()?.syncViewportWidth(this.resolveLoadMoreViewportWidth());
12532
+ this.syncVisibleRowLayouts();
12538
12533
  }
12539
12534
  syncVisibleRowLayouts() {
12540
12535
  let e = this.rowModel.getRowCount();
12541
12536
  if (e === 0) return;
12542
12537
  let t = this.rowModel.getRow(e - 1);
12543
- !t || !qs(t) || !this.rowPool.get() || this.syncLoadMoreRowLayout(t);
12538
+ !t || !qs(t) || !this.rowPool.get() || this.applyLoadMoreRowLayout(t);
12544
12539
  }
12545
- syncLoadMoreRowLayout(e) {
12540
+ applyLoadMoreRowLayout(e) {
12546
12541
  let t = this.rowPool.get();
12547
- t && (t.syncRowLayout(e), t.syncViewportWidth(this.resolveLoadMoreViewportWidth()), t.setRowTop(this.compressedScroll ? e.rowTop - this.scrollTop : e.rowTop));
12542
+ if (!t) return;
12543
+ t.syncRowLayout(e);
12544
+ let n = this.compressedScroll ? e.rowTop - this.scrollTop : e.rowTop;
12545
+ t.setRowTop(n);
12548
12546
  }
12549
12547
  invalidate() {
12550
12548
  this.clear();
@@ -12555,10 +12553,7 @@ var Ob = class {
12555
12553
  updateLoadMoreRow(e) {
12556
12554
  let t = this.getApi?.();
12557
12555
  if (!t || !this.onLoadMore) return;
12558
- let n = this.rowPool.acquire(() => new Ob(this.container, {
12559
- frameService: this.frameService ?? void 0,
12560
- onUnmountRenderer: this.onUnmountRenderer
12561
- })), r = {
12556
+ let n = this.rowPool.acquire(() => new Ob(this.container, { onUnmountRenderer: this.onUnmountRenderer })), r = {
12562
12557
  loading: this.getLoadMoreRowLoading?.() ?? !1,
12563
12558
  hasMore: this.getLoadMoreRowHasMore?.() ?? !0,
12564
12559
  size: this.getLoadMoreRowGridSize?.() ?? "default",
@@ -12566,13 +12561,7 @@ var Ob = class {
12566
12561
  onLoadMore: this.invokeLoadMore,
12567
12562
  api: t
12568
12563
  };
12569
- n.setData(e, r, this.getLoadMoreRowRenderer?.()), this.syncLoadMoreRowLayout(e);
12570
- }
12571
- resolveLoadMoreViewportWidth() {
12572
- let e = this.getViewportClientWidth?.() ?? 0;
12573
- if (e > 0) return e;
12574
- let t = this.container.clientWidth;
12575
- return t > 0 ? t : this.columnModel.getTotalWidth();
12564
+ n.setData(e, r, this.getLoadMoreRowRenderer?.()), this.applyLoadMoreRowLayout(e);
12576
12565
  }
12577
12566
  clear() {
12578
12567
  this.rowPool.clear();
@@ -12698,8 +12687,6 @@ var Ob = class {
12698
12687
  }) : null, this.loadMoreRowRenderer = t.fullWidthRowsContainerEl ? new Ab({
12699
12688
  container: t.fullWidthRowsContainerEl,
12700
12689
  rowModel: this.rowModel,
12701
- columnModel: this.columnModel,
12702
- frameService: this.frameService ?? void 0,
12703
12690
  onUnmountRenderer: this.onUnmountRenderer,
12704
12691
  getLoadMoreRowEnabled: t.getLoadMoreRowEnabled,
12705
12692
  getLoadMoreRowRenderer: t.getLoadMoreRowRenderer,
@@ -12708,8 +12695,7 @@ var Ob = class {
12708
12695
  getLoadMoreRowGridSize: t.getLoadMoreRowGridSize,
12709
12696
  getLoadMoreRowLabels: t.getLoadMoreRowLabels,
12710
12697
  onLoadMore: t.onLoadMore,
12711
- getApi: t.getApi,
12712
- getViewportClientWidth: t.getViewportClientWidth
12698
+ getApi: t.getApi
12713
12699
  }) : null;
12714
12700
  }
12715
12701
  setEmbedFullWidthRows(e) {
@@ -23028,7 +23014,9 @@ var FO = class {
23028
23014
  redrawViewport(e, t) {
23029
23015
  let n = this.getViewportHeight();
23030
23016
  this.syncCompressedLayerHeight(n);
23031
- let r = e ?? this.getLogicalScrollTop(), i = t ?? this.deps.viewportEl.scrollLeft, a = this.deps.viewportEl.clientWidth, o = eD(this.deps.columnModel, i, a);
23017
+ let r = e ?? this.getLogicalScrollTop(), i = t ?? this.deps.viewportEl.scrollLeft, a = this.deps.viewportEl.clientWidth;
23018
+ this.syncViewportInlineSize(a);
23019
+ let o = eD(this.deps.columnModel, i, a);
23032
23020
  o !== i && (this.deps.viewportEl.scrollLeft = o, this.lastScrollLeft = o, this.deps.headerScrollEl.scrollLeft = o, this.syncFooterScrollLeft(), this.syncFloatingFilterScrollLeft());
23033
23021
  let s = this.getRenderViewportHeightInternal(), c = this.deps.columnViewport.update(o, a), l = this.deps.columnViewport.getWindow();
23034
23022
  c && (this.reorderHeaderCells(!0), this.isColumnMoveLiveDragging() ? this.syncColumnCellLayouts() : (this.deps.refreshFooter?.(), this.deps.refreshFloatingFilter?.()), this.deps.applyFocusVisuals()), this.syncFooterScrollLeft(), this.syncFloatingFilterScrollLeft(), this.syncPinnedRows(), this.deps.ensureInfiniteRowsLoaded?.(r, s), this.deps.rowRenderer.redraw(r, s, l, c), this.deps.applyCellRangeVisuals?.(), this.syncIndexColumnFill(), this.onAfterRedraw?.();
@@ -23163,6 +23151,9 @@ var FO = class {
23163
23151
  syncCompressedLayerHeight(e) {
23164
23152
  this.getScrollRange(e).compressed && (this.deps.rowsLayerEl.style.height = `${e}px`, this.deps.viewportEl.style.setProperty("--mg-viewport-px", `${e}px`));
23165
23153
  }
23154
+ syncViewportInlineSize(e) {
23155
+ e > 0 && this.deps.viewportEl.style.setProperty("--mg-viewport-inline-size", `${e}px`);
23156
+ }
23166
23157
  syncIndexColumnFill() {
23167
23158
  let { indexColumnFillHostEl: e, indexColumnFillEl: t } = this.deps;
23168
23159
  if (!this.deps.showIndexColumn) {
@@ -25899,8 +25890,7 @@ function uA(e, t, n) {
25899
25890
  onLoadMore: () => {
25900
25891
  r.eventBus.emit("loadMore", {});
25901
25892
  },
25902
- getApi: () => n.getApi(),
25903
- getViewportClientWidth: () => x.viewportEl.clientWidth
25893
+ getApi: () => n.getApi()
25904
25894
  }), r.selectionOps = new YO({
25905
25895
  mountEl: r.mountEl,
25906
25896
  rowModel: r.rowModel,