@canvas-components/list-table 0.3.8 → 0.3.10
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 +47 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +47 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2848,8 +2848,8 @@ function resolveContentTextDecoration(content) {
|
|
|
2848
2848
|
function resolveContentTextIndent(content) {
|
|
2849
2849
|
return content.style?.textIndent ?? 0;
|
|
2850
2850
|
}
|
|
2851
|
-
function resolveContentTextAlign(content) {
|
|
2852
|
-
return content.style?.textAlign ??
|
|
2851
|
+
function resolveContentTextAlign(content, fallback = "left") {
|
|
2852
|
+
return content.style?.textAlign ?? fallback;
|
|
2853
2853
|
}
|
|
2854
2854
|
function resolveContentLayoutWidth(content, intrinsicWidth) {
|
|
2855
2855
|
return Math.max(content.style?.width ?? intrinsicWidth, intrinsicWidth);
|
|
@@ -5882,7 +5882,7 @@ function drawBodyTagContent(params) {
|
|
|
5882
5882
|
fontFamily: resolveContentFontFamily(content, theme)
|
|
5883
5883
|
});
|
|
5884
5884
|
ctx.textAlign = "left";
|
|
5885
|
-
ctx.textBaseline = "
|
|
5885
|
+
ctx.textBaseline = "alphabetic";
|
|
5886
5886
|
const bounds = measureTextBounds(ctx, content.text);
|
|
5887
5887
|
const textBoxWidth = Math.max(width - paddingInline * 2, 0);
|
|
5888
5888
|
const textX = resolveAlignedTextX({
|
|
@@ -5890,9 +5890,14 @@ function drawBodyTagContent(params) {
|
|
|
5890
5890
|
boxWidth: textBoxWidth,
|
|
5891
5891
|
textWidth: bounds.width,
|
|
5892
5892
|
textIndent,
|
|
5893
|
-
textAlign: resolveContentTextAlign(content)
|
|
5893
|
+
textAlign: resolveContentTextAlign(content, "center")
|
|
5894
5894
|
});
|
|
5895
5895
|
const centerY = rect.y + rect.height / 2;
|
|
5896
|
+
const textY = resolveCenteredTextBaselineY({
|
|
5897
|
+
centerY,
|
|
5898
|
+
ascent: bounds.ascent,
|
|
5899
|
+
descent: bounds.descent
|
|
5900
|
+
});
|
|
5896
5901
|
drawSelectableTextSelectionBackground({
|
|
5897
5902
|
ctx,
|
|
5898
5903
|
text: content.text,
|
|
@@ -5902,11 +5907,11 @@ function drawBodyTagContent(params) {
|
|
|
5902
5907
|
fragmentKey,
|
|
5903
5908
|
textSelection,
|
|
5904
5909
|
textOriginX: textX,
|
|
5905
|
-
textTop:
|
|
5910
|
+
textTop: textY - bounds.ascent,
|
|
5906
5911
|
textHeight: bounds.height,
|
|
5907
5912
|
color: theme.textSelectionBackgroundColor ?? "#99c2ff"
|
|
5908
5913
|
});
|
|
5909
|
-
ctx.fillText(content.text, textX,
|
|
5914
|
+
ctx.fillText(content.text, textX, textY);
|
|
5910
5915
|
const textFont = ctx.font;
|
|
5911
5916
|
drawTextDecoration({
|
|
5912
5917
|
ctx,
|
|
@@ -5928,7 +5933,7 @@ function drawBodyTagContent(params) {
|
|
|
5928
5933
|
contentIndex,
|
|
5929
5934
|
fragmentKey,
|
|
5930
5935
|
textOriginX: textX,
|
|
5931
|
-
textTop:
|
|
5936
|
+
textTop: textY - bounds.ascent,
|
|
5932
5937
|
textWidth: bounds.width,
|
|
5933
5938
|
textHeight: bounds.height,
|
|
5934
5939
|
fixed: column.fixed,
|
|
@@ -5971,7 +5976,7 @@ function applyTagTextStyle(ctx, content, theme) {
|
|
|
5971
5976
|
fontFamily: resolveContentFontFamily(content, theme)
|
|
5972
5977
|
});
|
|
5973
5978
|
ctx.textAlign = "left";
|
|
5974
|
-
ctx.textBaseline = "
|
|
5979
|
+
ctx.textBaseline = "alphabetic";
|
|
5975
5980
|
}
|
|
5976
5981
|
function resolveTagPalette(content) {
|
|
5977
5982
|
if (content.style?.backgroundColor || content.style?.color || content.backgroundColor || content.borderColor || content.textColor) {
|
|
@@ -6791,7 +6796,7 @@ function drawBodyCellContents(params) {
|
|
|
6791
6796
|
rect: lineRect,
|
|
6792
6797
|
visibleRect: lineVisibleRect,
|
|
6793
6798
|
lineWidth: line.width,
|
|
6794
|
-
align: column.align
|
|
6799
|
+
align: resolveBodyContentLineAlign(line, column.align)
|
|
6795
6800
|
});
|
|
6796
6801
|
line.items.forEach((item, itemIndex) => {
|
|
6797
6802
|
if (itemIndex > 0) {
|
|
@@ -7918,6 +7923,12 @@ function resolveLineStartX(rect, lineWidth, align) {
|
|
|
7918
7923
|
}
|
|
7919
7924
|
return rect.x;
|
|
7920
7925
|
}
|
|
7926
|
+
function resolveBodyContentLineAlign(line, columnAlign) {
|
|
7927
|
+
if (columnAlign != null) {
|
|
7928
|
+
return columnAlign;
|
|
7929
|
+
}
|
|
7930
|
+
return line.items.length > 0 && line.items.every((item) => item.content.type === "tag") ? "center" : columnAlign;
|
|
7931
|
+
}
|
|
7921
7932
|
function resolveStickyLineStartX(params) {
|
|
7922
7933
|
const { rect, visibleRect, lineWidth, align } = params;
|
|
7923
7934
|
const preferredX = resolveLineStartX(rect, lineWidth, align);
|
|
@@ -18375,8 +18386,9 @@ async function getColumnConfig(key) {
|
|
|
18375
18386
|
// src/services/column-config-service.ts
|
|
18376
18387
|
function applyStoredColumnConfig(columns, storedColumns) {
|
|
18377
18388
|
if (!storedColumns) {
|
|
18378
|
-
return;
|
|
18389
|
+
return false;
|
|
18379
18390
|
}
|
|
18391
|
+
let columnWidthsChanged = false;
|
|
18380
18392
|
const applyToColumns = (cols) => {
|
|
18381
18393
|
for (const col of cols) {
|
|
18382
18394
|
if (!col.key) {
|
|
@@ -18384,6 +18396,9 @@ function applyStoredColumnConfig(columns, storedColumns) {
|
|
|
18384
18396
|
}
|
|
18385
18397
|
const stored = storedColumns[col.key];
|
|
18386
18398
|
if (stored) {
|
|
18399
|
+
if ((col.width ?? 160) !== stored.width) {
|
|
18400
|
+
columnWidthsChanged = true;
|
|
18401
|
+
}
|
|
18387
18402
|
col.width = stored.width;
|
|
18388
18403
|
col.hidden = !!stored.hidden;
|
|
18389
18404
|
if ("align" in stored) {
|
|
@@ -18428,6 +18443,7 @@ function applyStoredColumnConfig(columns, storedColumns) {
|
|
|
18428
18443
|
}
|
|
18429
18444
|
};
|
|
18430
18445
|
applyToColumns(columns);
|
|
18446
|
+
return columnWidthsChanged;
|
|
18431
18447
|
}
|
|
18432
18448
|
function buildStoredColumnConfig(columns, sortState, filterState, zoom, summaryRowHeight, density) {
|
|
18433
18449
|
const result = {};
|
|
@@ -18547,7 +18563,7 @@ async function loadListTableStoredConfig(params) {
|
|
|
18547
18563
|
if (!stored) {
|
|
18548
18564
|
return null;
|
|
18549
18565
|
}
|
|
18550
|
-
applyStoredColumnConfig(columns, stored.columns);
|
|
18566
|
+
const columnWidthsChanged = applyStoredColumnConfig(columns, stored.columns);
|
|
18551
18567
|
return {
|
|
18552
18568
|
sortState: stored.sort?.key ? {
|
|
18553
18569
|
key: stored.sort.key,
|
|
@@ -18556,7 +18572,8 @@ async function loadListTableStoredConfig(params) {
|
|
|
18556
18572
|
filterState: stored.filters ? stored.filters : null,
|
|
18557
18573
|
zoom: typeof stored.zoom === "number" && Number.isFinite(stored.zoom) && stored.zoom > 0 ? stored.zoom : null,
|
|
18558
18574
|
summaryRowHeight: typeof stored.summaryRowHeight === "number" && Number.isFinite(stored.summaryRowHeight) && stored.summaryRowHeight >= 0 ? stored.summaryRowHeight : null,
|
|
18559
|
-
density: stored.density === 26 || stored.density === 32 || stored.density === 48 || stored.density === 56 || stored.density === "auto" ? stored.density : null
|
|
18575
|
+
density: stored.density === 26 || stored.density === 32 || stored.density === 48 || stored.density === 56 || stored.density === "auto" ? stored.density : null,
|
|
18576
|
+
columnWidthsChanged
|
|
18560
18577
|
};
|
|
18561
18578
|
}
|
|
18562
18579
|
|
|
@@ -18589,6 +18606,12 @@ var ListTablePersistenceController = class {
|
|
|
18589
18606
|
this.options.canvasHost.setContentZoom(nextZoom);
|
|
18590
18607
|
}
|
|
18591
18608
|
let currentOptions = this.options.getOptions();
|
|
18609
|
+
if (stored.columnWidthsChanged && currentOptions.stretchColumns !== false) {
|
|
18610
|
+
currentOptions = {
|
|
18611
|
+
...currentOptions,
|
|
18612
|
+
stretchColumns: false
|
|
18613
|
+
};
|
|
18614
|
+
}
|
|
18592
18615
|
if (stored.density != null) {
|
|
18593
18616
|
const densitySizes = resolveDensitySizes(
|
|
18594
18617
|
stored.density === "auto" ? "auto" : stored.density === 26 ? "ultra-compact" : stored.density === 32 ? "compact" : stored.density === 56 ? "comfortable" : "middle"
|
|
@@ -20500,6 +20523,10 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20500
20523
|
if (leafColumns.length === 0) {
|
|
20501
20524
|
return null;
|
|
20502
20525
|
}
|
|
20526
|
+
const columnMetrics = resolveColumnMetrics({
|
|
20527
|
+
columns: leafColumns,
|
|
20528
|
+
tableWidth: width
|
|
20529
|
+
});
|
|
20503
20530
|
const headerInfo = buildHeaderTree(normalizedColumns, leafColumns);
|
|
20504
20531
|
const sourceQueryRows = {
|
|
20505
20532
|
baseRows: baseRowsOverride ?? getBaseDisplayRows({
|
|
@@ -20541,8 +20568,11 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20541
20568
|
(col) => col.summary != null || col.summaryTitle != null
|
|
20542
20569
|
);
|
|
20543
20570
|
const hasSummary = queryRows.displayRows.length > 0 && options.summaryRowHeight !== 0 && (options.summaryRowHeight != null || hasConfiguredSummary);
|
|
20571
|
+
const hasHorizontalScrollbar = options.scrollbar?.visible !== false && columnMetrics.centerContentWidth - columnMetrics.availableCenterWidth > 1;
|
|
20572
|
+
const horizontalScrollbarReserve = hasSummary && hasHorizontalScrollbar ? scrollbarThickness + Math.max(options.scrollbar?.horizontalBottom ?? 0, 0) : 0;
|
|
20573
|
+
const contentHeight = Math.max(height - horizontalScrollbarReserve, 0);
|
|
20544
20574
|
const initialBodyLayout = resolveBodyLayout({
|
|
20545
|
-
height,
|
|
20575
|
+
height: contentHeight,
|
|
20546
20576
|
headerHeight,
|
|
20547
20577
|
summaryRowHeight,
|
|
20548
20578
|
hasSummary,
|
|
@@ -20672,7 +20702,7 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20672
20702
|
}
|
|
20673
20703
|
},
|
|
20674
20704
|
bodyLayout: resolveBodyLayout({
|
|
20675
|
-
height,
|
|
20705
|
+
height: contentHeight,
|
|
20676
20706
|
headerHeight,
|
|
20677
20707
|
summaryRowHeight,
|
|
20678
20708
|
hasSummary,
|
|
@@ -20694,7 +20724,7 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20694
20724
|
visibleRows: filteredVisibleRows,
|
|
20695
20725
|
frozenState: frozenRows,
|
|
20696
20726
|
getRowKey: (row) => row.kind === "data" ? row.rowKey : null,
|
|
20697
|
-
height,
|
|
20727
|
+
height: contentHeight,
|
|
20698
20728
|
headerHeight,
|
|
20699
20729
|
summaryRowHeight,
|
|
20700
20730
|
hasSummary,
|
|
@@ -20707,7 +20737,7 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20707
20737
|
bodyState.frozenRows.scroll.rowIndexMap = plainRowWindow.rowIndexMap;
|
|
20708
20738
|
bodyState.frozenRows.scroll.rowOffsetMap = plainRowWindow.rowOffsetMap;
|
|
20709
20739
|
bodyState.bodyLayout = resolveBodyLayout({
|
|
20710
|
-
height,
|
|
20740
|
+
height: contentHeight,
|
|
20711
20741
|
headerHeight,
|
|
20712
20742
|
summaryRowHeight,
|
|
20713
20743
|
hasSummary,
|
|
@@ -20731,7 +20761,7 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20731
20761
|
bodyState.frozenRows.scroll.rowIndexMap = plainRowWindow.rowIndexMap;
|
|
20732
20762
|
bodyState.frozenRows.scroll.rowOffsetMap = plainRowWindow.rowOffsetMap;
|
|
20733
20763
|
bodyState.bodyLayout = resolveBodyLayout({
|
|
20734
|
-
height,
|
|
20764
|
+
height: contentHeight,
|
|
20735
20765
|
headerHeight,
|
|
20736
20766
|
summaryRowHeight,
|
|
20737
20767
|
hasSummary,
|
|
@@ -20742,10 +20772,6 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20742
20772
|
scrollRowCount: plainRowWindow.totalRowCount
|
|
20743
20773
|
});
|
|
20744
20774
|
}
|
|
20745
|
-
let columnMetrics = resolveColumnMetrics({
|
|
20746
|
-
columns: leafColumns,
|
|
20747
|
-
tableWidth: width
|
|
20748
|
-
});
|
|
20749
20775
|
let viewportResult = computeViewport({
|
|
20750
20776
|
width,
|
|
20751
20777
|
height,
|