@canvas-components/list-table 0.3.1 → 0.3.2
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/README.md +3 -1
- package/dist/index.cjs +70 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +70 -66
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -3928,11 +3928,25 @@ function drawImagePlaceholder(ctx, x, y, width, height, backgroundColor = PLACEH
|
|
|
3928
3928
|
var SYMBOL_COLOR_MAP = {
|
|
3929
3929
|
star: "#fadb14",
|
|
3930
3930
|
sun: "#faad14",
|
|
3931
|
-
moon: "#597ef7"
|
|
3931
|
+
moon: "#597ef7",
|
|
3932
|
+
check: "#52c41a",
|
|
3933
|
+
close: "#ff4d4f"
|
|
3932
3934
|
};
|
|
3933
3935
|
function drawCellSymbol(ctx, params) {
|
|
3934
3936
|
const { type, x, y, size, activeColor, inactiveColor } = params;
|
|
3935
3937
|
const fillRatio = Math.min(Math.max(params.fillRatio, 0), 1);
|
|
3938
|
+
if (type === "check" || type === "close") {
|
|
3939
|
+
drawStatusSymbol(ctx, {
|
|
3940
|
+
type,
|
|
3941
|
+
x,
|
|
3942
|
+
y,
|
|
3943
|
+
size,
|
|
3944
|
+
activeColor,
|
|
3945
|
+
inactiveColor,
|
|
3946
|
+
fillRatio
|
|
3947
|
+
});
|
|
3948
|
+
return;
|
|
3949
|
+
}
|
|
3936
3950
|
appendCellSymbolPath(ctx, type, x, y, size);
|
|
3937
3951
|
ctx.fillStyle = inactiveColor;
|
|
3938
3952
|
ctx.fill("evenodd");
|
|
@@ -3950,6 +3964,10 @@ function resolveCellSymbolColor(type) {
|
|
|
3950
3964
|
return SYMBOL_COLOR_MAP[type];
|
|
3951
3965
|
}
|
|
3952
3966
|
function appendCellSymbolPath(ctx, type, x, y, size) {
|
|
3967
|
+
if (type === "check" || type === "close") {
|
|
3968
|
+
appendStatusSymbolPath(ctx, type, x, y, size);
|
|
3969
|
+
return;
|
|
3970
|
+
}
|
|
3953
3971
|
if (type === "moon") {
|
|
3954
3972
|
appendMoonPath(ctx, x, y, size);
|
|
3955
3973
|
return;
|
|
@@ -3970,6 +3988,38 @@ function appendCellSymbolPath(ctx, type, x, y, size) {
|
|
|
3970
3988
|
}
|
|
3971
3989
|
ctx.closePath();
|
|
3972
3990
|
}
|
|
3991
|
+
function drawStatusSymbol(ctx, params) {
|
|
3992
|
+
const { type, x, y, size, activeColor, inactiveColor, fillRatio } = params;
|
|
3993
|
+
ctx.save();
|
|
3994
|
+
ctx.lineCap = "round";
|
|
3995
|
+
ctx.lineJoin = "round";
|
|
3996
|
+
ctx.lineWidth = Math.max(size * 0.12, 1.5);
|
|
3997
|
+
appendStatusSymbolPath(ctx, type, x, y, size);
|
|
3998
|
+
ctx.strokeStyle = inactiveColor;
|
|
3999
|
+
ctx.stroke();
|
|
4000
|
+
if (fillRatio > 0) {
|
|
4001
|
+
ctx.beginPath();
|
|
4002
|
+
ctx.rect(x, y, size * fillRatio, size);
|
|
4003
|
+
ctx.clip();
|
|
4004
|
+
appendStatusSymbolPath(ctx, type, x, y, size);
|
|
4005
|
+
ctx.strokeStyle = activeColor;
|
|
4006
|
+
ctx.stroke();
|
|
4007
|
+
}
|
|
4008
|
+
ctx.restore();
|
|
4009
|
+
}
|
|
4010
|
+
function appendStatusSymbolPath(ctx, type, x, y, size) {
|
|
4011
|
+
ctx.beginPath();
|
|
4012
|
+
if (type === "check") {
|
|
4013
|
+
ctx.moveTo(x + size * 0.16, y + size * 0.52);
|
|
4014
|
+
ctx.lineTo(x + size * 0.4, y + size * 0.76);
|
|
4015
|
+
ctx.lineTo(x + size * 0.84, y + size * 0.26);
|
|
4016
|
+
return;
|
|
4017
|
+
}
|
|
4018
|
+
ctx.moveTo(x + size * 0.22, y + size * 0.22);
|
|
4019
|
+
ctx.lineTo(x + size * 0.78, y + size * 0.78);
|
|
4020
|
+
ctx.moveTo(x + size * 0.78, y + size * 0.22);
|
|
4021
|
+
ctx.lineTo(x + size * 0.22, y + size * 0.78);
|
|
4022
|
+
}
|
|
3973
4023
|
function appendMoonPath(ctx, x, y, size) {
|
|
3974
4024
|
ctx.beginPath();
|
|
3975
4025
|
ctx.moveTo(x + size * 0.64, y + size * 0.04);
|
|
@@ -6239,6 +6289,7 @@ function resolveColumnFormItemProps(column, context) {
|
|
|
6239
6289
|
// src/rendering/cell-content/cell-content-renderer.ts
|
|
6240
6290
|
var CONTENT_HORIZONTAL_PADDING = 12;
|
|
6241
6291
|
var CONTENT_GAP = 8;
|
|
6292
|
+
var LINK_CONTENT_GAP = 4;
|
|
6242
6293
|
var CONTENT_VERTICAL_PADDING = 6;
|
|
6243
6294
|
function resolveBodyCellContents(params) {
|
|
6244
6295
|
return resolveRawBodyCellContents(params).filter(
|
|
@@ -6673,8 +6724,8 @@ function drawBodyCellContents(params) {
|
|
|
6673
6724
|
align: column.align
|
|
6674
6725
|
});
|
|
6675
6726
|
line.items.forEach((item, itemIndex) => {
|
|
6676
|
-
if (itemIndex > 0
|
|
6677
|
-
cursorX +=
|
|
6727
|
+
if (itemIndex > 0) {
|
|
6728
|
+
cursorX += item.gapBefore;
|
|
6678
6729
|
}
|
|
6679
6730
|
const itemDescriptors = [];
|
|
6680
6731
|
drawExpandedBodyContent({
|
|
@@ -6769,7 +6820,7 @@ function measureBodyCellContentsWidth(params) {
|
|
|
6769
6820
|
currentLineWidth = 0;
|
|
6770
6821
|
return;
|
|
6771
6822
|
}
|
|
6772
|
-
const gapWidth = currentLineWidth > 0
|
|
6823
|
+
const gapWidth = currentLineWidth > 0 ? item.gapBefore : 0;
|
|
6773
6824
|
currentLineWidth += gapWidth + contentWidth;
|
|
6774
6825
|
});
|
|
6775
6826
|
return Math.ceil(
|
|
@@ -6800,10 +6851,11 @@ function expandBodyContents(contents) {
|
|
|
6800
6851
|
const textOnly = contents.every((content) => content.type === "text");
|
|
6801
6852
|
const expanded = [];
|
|
6802
6853
|
contents.forEach((content, contentIndex) => {
|
|
6854
|
+
const previousContent = contents[contentIndex - 1];
|
|
6803
6855
|
expanded.push({
|
|
6804
6856
|
content,
|
|
6805
6857
|
contentIndex,
|
|
6806
|
-
gapBefore: expanded.length
|
|
6858
|
+
gapBefore: expanded.length === 0 || textOnly ? 0 : previousContent?.type === "link" && content.type === "link" ? LINK_CONTENT_GAP : CONTENT_GAP
|
|
6807
6859
|
});
|
|
6808
6860
|
if ((content.type === "checkbox" || content.type === "radio") && content.label) {
|
|
6809
6861
|
const textLabelContent = {
|
|
@@ -6816,7 +6868,7 @@ function expandBodyContents(contents) {
|
|
|
6816
6868
|
expanded.push({
|
|
6817
6869
|
content: textLabelContent,
|
|
6818
6870
|
contentIndex,
|
|
6819
|
-
gapBefore:
|
|
6871
|
+
gapBefore: CONTENT_GAP
|
|
6820
6872
|
});
|
|
6821
6873
|
}
|
|
6822
6874
|
});
|
|
@@ -6857,7 +6909,7 @@ function buildSingleLineLayout(ctx, contents, availableWidth, theme) {
|
|
|
6857
6909
|
}
|
|
6858
6910
|
break;
|
|
6859
6911
|
}
|
|
6860
|
-
const gapWidth = line.items.length > 0
|
|
6912
|
+
const gapWidth = line.items.length > 0 ? item.gapBefore : 0;
|
|
6861
6913
|
const remainingWidth = availableWidth - line.width - gapWidth;
|
|
6862
6914
|
if (remainingWidth <= 0) {
|
|
6863
6915
|
truncated = true;
|
|
@@ -6925,7 +6977,7 @@ function buildWrappedLineLayout(ctx, contents, availableWidth, maxLines, theme)
|
|
|
6925
6977
|
items: [
|
|
6926
6978
|
{
|
|
6927
6979
|
...currentItem,
|
|
6928
|
-
gapBefore:
|
|
6980
|
+
gapBefore: 0,
|
|
6929
6981
|
width: fullWidth2
|
|
6930
6982
|
}
|
|
6931
6983
|
],
|
|
@@ -6956,7 +7008,7 @@ function buildWrappedLineLayout(ctx, contents, availableWidth, maxLines, theme)
|
|
|
6956
7008
|
{
|
|
6957
7009
|
...currentItem,
|
|
6958
7010
|
content: fittedContent2,
|
|
6959
|
-
gapBefore:
|
|
7011
|
+
gapBefore: 0,
|
|
6960
7012
|
width: fittedWidth
|
|
6961
7013
|
}
|
|
6962
7014
|
],
|
|
@@ -6978,11 +7030,11 @@ function buildWrappedLineLayout(ctx, contents, availableWidth, maxLines, theme)
|
|
|
6978
7030
|
currentItem = {
|
|
6979
7031
|
...currentItem,
|
|
6980
7032
|
content: setBreakableContentText(currentItem.content, remainingText2),
|
|
6981
|
-
gapBefore:
|
|
7033
|
+
gapBefore: 0
|
|
6982
7034
|
};
|
|
6983
7035
|
continue;
|
|
6984
7036
|
}
|
|
6985
|
-
const gapWidth = currentLine.items.length > 0
|
|
7037
|
+
const gapWidth = currentLine.items.length > 0 ? currentItem.gapBefore : 0;
|
|
6986
7038
|
const remainingWidth = availableWidth - currentLine.width - gapWidth;
|
|
6987
7039
|
if (remainingWidth <= 0) {
|
|
6988
7040
|
if (lines.length + 1 >= maxLines) {
|
|
@@ -6996,7 +7048,7 @@ function buildWrappedLineLayout(ctx, contents, availableWidth, maxLines, theme)
|
|
|
6996
7048
|
currentLine = { items: [], width: 0 };
|
|
6997
7049
|
currentItem = {
|
|
6998
7050
|
...currentItem,
|
|
6999
|
-
gapBefore:
|
|
7051
|
+
gapBefore: 0
|
|
7000
7052
|
};
|
|
7001
7053
|
continue;
|
|
7002
7054
|
}
|
|
@@ -7016,7 +7068,7 @@ function buildWrappedLineLayout(ctx, contents, availableWidth, maxLines, theme)
|
|
|
7016
7068
|
currentLine = { items: [], width: 0 };
|
|
7017
7069
|
currentItem = {
|
|
7018
7070
|
...currentItem,
|
|
7019
|
-
gapBefore:
|
|
7071
|
+
gapBefore: 0
|
|
7020
7072
|
};
|
|
7021
7073
|
continue;
|
|
7022
7074
|
}
|
|
@@ -7056,7 +7108,7 @@ function buildWrappedLineLayout(ctx, contents, availableWidth, maxLines, theme)
|
|
|
7056
7108
|
currentLine = { items: [], width: 0 };
|
|
7057
7109
|
currentItem = {
|
|
7058
7110
|
...currentItem,
|
|
7059
|
-
gapBefore:
|
|
7111
|
+
gapBefore: 0
|
|
7060
7112
|
};
|
|
7061
7113
|
continue;
|
|
7062
7114
|
}
|
|
@@ -7084,7 +7136,7 @@ function buildWrappedLineLayout(ctx, contents, availableWidth, maxLines, theme)
|
|
|
7084
7136
|
currentItem = {
|
|
7085
7137
|
...currentItem,
|
|
7086
7138
|
content: setBreakableContentText(currentItem.content, remainingText),
|
|
7087
|
-
gapBefore:
|
|
7139
|
+
gapBefore: 0
|
|
7088
7140
|
};
|
|
7089
7141
|
}
|
|
7090
7142
|
if (truncated) {
|
|
@@ -7597,10 +7649,10 @@ function applyTrailingEllipsis(ctx, line, theme, availableWidth) {
|
|
|
7597
7649
|
continue;
|
|
7598
7650
|
}
|
|
7599
7651
|
const widthBefore = line.items.slice(0, index).reduce((sum, current, currentIndex) => {
|
|
7600
|
-
const gapWidth2 = currentIndex > 0
|
|
7652
|
+
const gapWidth2 = currentIndex > 0 ? current.gapBefore : 0;
|
|
7601
7653
|
return sum + gapWidth2 + current.width;
|
|
7602
7654
|
}, 0);
|
|
7603
|
-
const gapWidth = index > 0
|
|
7655
|
+
const gapWidth = index > 0 ? item.gapBefore : 0;
|
|
7604
7656
|
const nextContent = truncateExpandedContent(
|
|
7605
7657
|
ctx,
|
|
7606
7658
|
item.content,
|
|
@@ -20127,7 +20179,7 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20127
20179
|
options.scrollbar?.thickness ?? DEFAULT_SCROLLBAR_THICKNESS,
|
|
20128
20180
|
6
|
|
20129
20181
|
);
|
|
20130
|
-
let width = hostWidth;
|
|
20182
|
+
let width = Math.max(hostWidth - scrollbarThickness, 0);
|
|
20131
20183
|
let height = hostHeight;
|
|
20132
20184
|
const sourceNormalizedColumns = normalizeColumns(
|
|
20133
20185
|
getResolvedColumns(options, selectedRowKeys)
|
|
@@ -20402,54 +20454,6 @@ function buildListTableRenderSnapshot(params) {
|
|
|
20402
20454
|
fixedWidthRight: columnMetrics.fixedWidthRight,
|
|
20403
20455
|
scroll
|
|
20404
20456
|
});
|
|
20405
|
-
for (let index = 0; index < 2 && scrollbarThickness > 0; index += 1) {
|
|
20406
|
-
const nextWidth = Math.max(
|
|
20407
|
-
hostWidth - (viewportResult.viewport.maxScrollTop > 0 ? scrollbarThickness : 0),
|
|
20408
|
-
0
|
|
20409
|
-
);
|
|
20410
|
-
const nextHeight = Math.max(
|
|
20411
|
-
hostHeight - (viewportResult.viewport.maxScrollLeft > 0 ? scrollbarThickness : 0),
|
|
20412
|
-
0
|
|
20413
|
-
);
|
|
20414
|
-
if (nextWidth === width && nextHeight === height) {
|
|
20415
|
-
break;
|
|
20416
|
-
}
|
|
20417
|
-
width = nextWidth;
|
|
20418
|
-
height = nextHeight;
|
|
20419
|
-
bodyState = resolveCurrentBodyState();
|
|
20420
|
-
if (plainRowWindow) {
|
|
20421
|
-
bodyState.frozenRows.scroll.windowed = true;
|
|
20422
|
-
bodyState.frozenRows.scroll.dataRowIndexAligned = true;
|
|
20423
|
-
bodyState.frozenRows.scroll.rowIndexMap = plainRowWindow.rowIndexMap;
|
|
20424
|
-
bodyState.frozenRows.scroll.rowOffsetMap = plainRowWindow.rowOffsetMap;
|
|
20425
|
-
bodyState.bodyLayout = resolveBodyLayout({
|
|
20426
|
-
height,
|
|
20427
|
-
headerHeight,
|
|
20428
|
-
summaryRowHeight,
|
|
20429
|
-
hasSummary,
|
|
20430
|
-
rowHeight,
|
|
20431
|
-
totalBodyHeight: plainRowWindow.totalBodyHeight,
|
|
20432
|
-
topFrozenRowCount: 0,
|
|
20433
|
-
bottomFrozenRowCount: 0,
|
|
20434
|
-
scrollRowCount: plainRowWindow.totalRowCount
|
|
20435
|
-
});
|
|
20436
|
-
}
|
|
20437
|
-
columnMetrics = resolveColumnMetrics({
|
|
20438
|
-
columns: leafColumns,
|
|
20439
|
-
tableWidth: width
|
|
20440
|
-
});
|
|
20441
|
-
viewportResult = computeViewport({
|
|
20442
|
-
width,
|
|
20443
|
-
height,
|
|
20444
|
-
headerHeight,
|
|
20445
|
-
bodyHeight: bodyState.bodyLayout.scrollBodyHeight,
|
|
20446
|
-
totalWidth: columnMetrics.totalWidth,
|
|
20447
|
-
totalBodyHeight: bodyState.bodyLayout.totalBodyHeight,
|
|
20448
|
-
fixedWidthLeft: columnMetrics.fixedWidthLeft,
|
|
20449
|
-
fixedWidthRight: columnMetrics.fixedWidthRight,
|
|
20450
|
-
scroll
|
|
20451
|
-
});
|
|
20452
|
-
}
|
|
20453
20457
|
scrollPageSize = resolveScrollPageSize({
|
|
20454
20458
|
options,
|
|
20455
20459
|
pageSize: query.pagination.pageSize,
|