@canvas-components/list-table 0.3.16 → 0.3.18

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.cjs CHANGED
@@ -666,15 +666,19 @@ function stretchColumnWidths(columns, containerWidth) {
666
666
  }
667
667
  const extra = containerWidth - totalWidth;
668
668
  const stretchableWidth = computeColumnWidths(stretchableColumns);
669
- const ratio = stretchableWidth > 0 ? extra / stretchableWidth : 0;
670
- for (const column of stretchableColumns) {
671
- column.width = Math.round(column.width * (1 + ratio));
672
- }
673
- const adjustedTotal = computeColumnWidths(columns);
674
- const remain = containerWidth - adjustedTotal;
675
- if (remain > 0) {
676
- stretchableColumns[stretchableColumns.length - 1].width += remain;
677
- }
669
+ let accumulatedWidth = 0;
670
+ let allocatedExtra = 0;
671
+ stretchableColumns.forEach((column, index) => {
672
+ accumulatedWidth += column.width;
673
+ const targetExtra = index === stretchableColumns.length - 1 ? extra : Math.min(
674
+ extra,
675
+ Math.floor(
676
+ extra * (stretchableWidth > 0 ? accumulatedWidth / stretchableWidth : (index + 1) / stretchableColumns.length)
677
+ )
678
+ );
679
+ column.width += targetExtra - allocatedExtra;
680
+ allocatedExtra = targetExtra;
681
+ });
678
682
  }
679
683
  function shrinkColumnWidthsToFit(columns, containerWidth) {
680
684
  let remaining = Math.max(
@@ -753,6 +757,7 @@ function normalizeColumn(column, depth, parentKey) {
753
757
  align: column.align ?? "left",
754
758
  headerAlign: column.headerAlign,
755
759
  fixed: column.fixed,
760
+ resizable: column.resizable,
756
761
  hidden: column.hidden,
757
762
  showExpandIcon: column.showExpandIcon,
758
763
  ellipsis: column.ellipsis,
@@ -8153,6 +8158,18 @@ var EMPTY_RANGE_HIGHLIGHT2 = {
8153
8158
  selectedColumnRange: null
8154
8159
  };
8155
8160
  function drawSummary(params) {
8161
+ const width = params.width ?? Math.max(
8162
+ 0,
8163
+ ...[
8164
+ ...params.leftColumns,
8165
+ ...params.centerColumns,
8166
+ ...params.rightColumns
8167
+ ].map((column) => column.drawX + column.width)
8168
+ );
8169
+ params.ctx.save();
8170
+ params.ctx.fillStyle = params.theme.backgroundColor;
8171
+ params.ctx.fillRect(0, params.summaryTop, width, params.summaryHeight);
8172
+ params.ctx.restore();
8156
8173
  const defaultTitleColumnKey = resolveDefaultSummaryTitleColumnKey([
8157
8174
  ...params.leftColumns,
8158
8175
  ...params.centerColumns,
@@ -29013,6 +29030,18 @@ function roundRect2(ctx, x, y, width, height, radius) {
29013
29030
 
29014
29031
  // src/rendering/pipeline/body-section-renderer.ts
29015
29032
  function drawListTableBodySections(params) {
29033
+ params.ctx.save();
29034
+ params.ctx.beginPath();
29035
+ params.ctx.rect(
29036
+ 0,
29037
+ params.headerHeight,
29038
+ params.width + 1,
29039
+ Math.max(
29040
+ params.bottomFrozenTop + params.bottomFrozenHeight - params.headerHeight,
29041
+ 0
29042
+ )
29043
+ );
29044
+ params.ctx.clip();
29016
29045
  const baseParams = {
29017
29046
  ctx: params.ctx,
29018
29047
  rowHeight: params.rowHeight,
@@ -29077,6 +29106,7 @@ function drawListTableBodySections(params) {
29077
29106
  borderColor: params.theme.borderColor
29078
29107
  });
29079
29108
  }
29109
+ params.ctx.restore();
29080
29110
  }
29081
29111
  function drawBodySection(params) {
29082
29112
  const { section, bodyHeight } = params;
@@ -29958,6 +29988,7 @@ function executeListTableRenderPipeline(params) {
29958
29988
  ctx,
29959
29989
  textSelection: selection.textSelection,
29960
29990
  summaryValues,
29991
+ width,
29961
29992
  summaryTop,
29962
29993
  summaryHeight: summaryRowHeight,
29963
29994
  leftColumns: leftSegment,
@@ -30507,9 +30538,10 @@ var ListTableRenderController = class {
30507
30538
  const availableHeight = this.options.getContainerClientHeight() > 0 ? this.options.getContainerClientHeight() : hostSize.height;
30508
30539
  const zoom = this.resolveZoom();
30509
30540
  const layoutWidth = hostSize.width / zoom;
30510
- const layoutAvailableHeight = availableHeight / zoom;
30511
- const currentSnapshot = this.currentRenderSnapshot;
30512
- const measureSnapshot = currentSnapshot && currentSnapshot.width === layoutWidth && currentSnapshot.groupingBarHeight === (this.options.getGroupBarVisible?.() ? currentSnapshot.rowHeight : 0) && currentSnapshot.groupingColumns.map((column) => column.key).join("") === (this.options.getGroupColumnKeys?.() ?? []).join("") ? currentSnapshot : this.buildSnapshot(layoutWidth, layoutAvailableHeight, false);
30541
+ const measureSnapshot = this.buildSnapshot(
30542
+ layoutWidth,
30543
+ hostSize.height / zoom
30544
+ );
30513
30545
  if (!measureSnapshot) {
30514
30546
  this.options.setFittedHeight(null);
30515
30547
  return;
@@ -30528,10 +30560,13 @@ var ListTableRenderController = class {
30528
30560
  summaryHeight: measureSnapshot.bodyLayout.summaryHeight
30529
30561
  });
30530
30562
  const paginationElement = this.options.getPaginationElement();
30563
+ const scrollbar = this.options.getOptions().scrollbar;
30564
+ const horizontal = utils.resolveCanvasScrollbarAxis(scrollbar, "horizontal");
30565
+ const horizontalReserve = horizontal.visible && measureSnapshot.columnMetrics.centerContentWidth - measureSnapshot.columnMetrics.availableCenterWidth > 1 ? horizontal.thickness + Math.max(scrollbar?.horizontalBottom ?? 0, 0) : 0;
30531
30566
  const paginationHeight = paginationElement && paginationElement.style.display !== "none" ? paginationElement.offsetHeight : 0;
30532
30567
  const fittedHeight = resolveFittedTableHeight({
30533
30568
  availableHeight,
30534
- contentHeight: contentHeight * zoom + paginationHeight
30569
+ contentHeight: (contentHeight + horizontalReserve) * zoom + paginationHeight
30535
30570
  });
30536
30571
  this.options.setFittedHeight(
30537
30572
  fittedHeight == null ? null : fittedHeight + TABLE_CONTENT_BORDER_SIZE