@canvas-components/list-table 0.3.20 → 0.3.22
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 +97 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +97 -17
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -951,15 +951,23 @@ function setColumnFixed(columns, targetKey, direction, initialColumns) {
|
|
|
951
951
|
}
|
|
952
952
|
updateColumnFixed(columns, targetKey, direction, initialColumns);
|
|
953
953
|
}
|
|
954
|
-
function setNestedColumnWidth(columns, targetKey, newWidth) {
|
|
954
|
+
function setNestedColumnWidth(columns, targetKey, newWidth, expandMaxWidth = false) {
|
|
955
955
|
ensureColumnKeysInPlace(columns);
|
|
956
956
|
for (const column of columns) {
|
|
957
957
|
if (column.key === targetKey) {
|
|
958
958
|
column.width = newWidth;
|
|
959
|
+
if (expandMaxWidth && newWidth > (column.maxWidth ?? DEFAULT_MAX_WIDTH)) {
|
|
960
|
+
column.maxWidth = newWidth;
|
|
961
|
+
}
|
|
959
962
|
return;
|
|
960
963
|
}
|
|
961
964
|
if (column.children?.length) {
|
|
962
|
-
setNestedColumnWidth(
|
|
965
|
+
setNestedColumnWidth(
|
|
966
|
+
column.children,
|
|
967
|
+
targetKey,
|
|
968
|
+
newWidth,
|
|
969
|
+
expandMaxWidth
|
|
970
|
+
);
|
|
963
971
|
}
|
|
964
972
|
}
|
|
965
973
|
}
|
|
@@ -1506,6 +1514,7 @@ var ListTableDomHost = class {
|
|
|
1506
1514
|
wrapper.style.display = "flex";
|
|
1507
1515
|
wrapper.style.flexDirection = "column";
|
|
1508
1516
|
wrapper.style.minWidth = "0";
|
|
1517
|
+
wrapper.style.maxWidth = "100%";
|
|
1509
1518
|
wrapper.style.boxSizing = "border-box";
|
|
1510
1519
|
wrapper.style.overflow = "visible";
|
|
1511
1520
|
const contentLayer = document.createElement("div");
|
|
@@ -8359,7 +8368,7 @@ function resolveHeaderTextLayout(params) {
|
|
|
8359
8368
|
Math.min(baseX - textLeft, textRight - baseX) * 2,
|
|
8360
8369
|
0
|
|
8361
8370
|
);
|
|
8362
|
-
if (centeredWidth >= 12) {
|
|
8371
|
+
if (centeredWidth >= Math.max(params.contentWidth ?? 0, 12)) {
|
|
8363
8372
|
return {
|
|
8364
8373
|
align,
|
|
8365
8374
|
x: baseX,
|
|
@@ -9135,7 +9144,7 @@ function drawSummaryCell(ctx, rect, column, theme, summaryValues, selectedHeader
|
|
|
9135
9144
|
const fontSize = style?.fontSize ?? theme.fontSize;
|
|
9136
9145
|
const paddingInline = style?.paddingInline ?? 12;
|
|
9137
9146
|
const paddingBlock = style?.paddingBlock ?? 0;
|
|
9138
|
-
const
|
|
9147
|
+
const centerY = style?.verticalAlign === "top" ? rect.y + paddingBlock + fontSize / 2 : style?.verticalAlign === "bottom" ? rect.y + rect.height - paddingBlock - fontSize / 2 : rect.y + rect.height / 2;
|
|
9139
9148
|
if (!cellClip) {
|
|
9140
9149
|
ctx.restore();
|
|
9141
9150
|
return;
|
|
@@ -9160,7 +9169,7 @@ function drawSummaryCell(ctx, rect, column, theme, summaryValues, selectedHeader
|
|
|
9160
9169
|
ctx.clip();
|
|
9161
9170
|
ctx.fillStyle = style?.color ?? theme.headerTextColor;
|
|
9162
9171
|
ctx.font = `${style?.fontWeight ?? "600"} ${fontSize}px ${style?.fontFamily ?? theme.fontFamily}`;
|
|
9163
|
-
ctx.textBaseline = "
|
|
9172
|
+
ctx.textBaseline = "alphabetic";
|
|
9164
9173
|
const align = style?.textAlign ?? column.align ?? "left";
|
|
9165
9174
|
ctx.textAlign = align;
|
|
9166
9175
|
const contentInsetStart = column.key === inlineContentInset?.columnKey ? inlineContentInset.width : 0;
|
|
@@ -9181,9 +9190,15 @@ function drawSummaryCell(ctx, rect, column, theme, summaryValues, selectedHeader
|
|
|
9181
9190
|
visibleRect,
|
|
9182
9191
|
padding: paddingInline
|
|
9183
9192
|
});
|
|
9184
|
-
const
|
|
9193
|
+
const bounds = measureTextBounds(ctx, displayText);
|
|
9194
|
+
const textY = resolveCenteredTextBaselineY({
|
|
9195
|
+
centerY,
|
|
9196
|
+
ascent: bounds.ascent,
|
|
9197
|
+
descent: bounds.descent
|
|
9198
|
+
});
|
|
9199
|
+
const textWidth = bounds.width;
|
|
9185
9200
|
const textOriginX = textX - (align === "right" ? textWidth : align === "center" ? textWidth / 2 : 0);
|
|
9186
|
-
const textTop = textY -
|
|
9201
|
+
const textTop = textY - bounds.ascent;
|
|
9187
9202
|
const fragmentKey = `summary:${column.key}`;
|
|
9188
9203
|
drawSelectableTextSelectionBackground({
|
|
9189
9204
|
ctx,
|
|
@@ -9191,7 +9206,7 @@ function drawSummaryCell(ctx, rect, column, theme, summaryValues, selectedHeader
|
|
|
9191
9206
|
textSelection,
|
|
9192
9207
|
textOriginX,
|
|
9193
9208
|
textTop,
|
|
9194
|
-
textHeight:
|
|
9209
|
+
textHeight: bounds.height,
|
|
9195
9210
|
rowIndex: Number.MAX_SAFE_INTEGER,
|
|
9196
9211
|
columnKey: column.key,
|
|
9197
9212
|
contentIndex: 0,
|
|
@@ -9211,7 +9226,7 @@ function drawSummaryCell(ctx, rect, column, theme, summaryValues, selectedHeader
|
|
|
9211
9226
|
x: textOriginX,
|
|
9212
9227
|
y: textTop,
|
|
9213
9228
|
width: textWidth,
|
|
9214
|
-
height:
|
|
9229
|
+
height: bounds.height
|
|
9215
9230
|
},
|
|
9216
9231
|
cellClip
|
|
9217
9232
|
) ?? void 0,
|
|
@@ -11325,12 +11340,24 @@ function drawBodyTagContent(params) {
|
|
|
11325
11340
|
const textColor = resolveTagTextColor(content, palette.textColor);
|
|
11326
11341
|
const textIndent = resolveContentTextIndent(content);
|
|
11327
11342
|
const paddingInline = content.paddingInline ?? TAG_HORIZONTAL_PADDING;
|
|
11343
|
+
const drawLeft = Math.round(cursorX);
|
|
11344
|
+
const drawTop = Math.round(top);
|
|
11345
|
+
const drawWidth = Math.max(Math.round(cursorX + width) - drawLeft, 1);
|
|
11346
|
+
const drawHeight = Math.max(Math.round(top + height) - drawTop, 1);
|
|
11328
11347
|
ctx.save();
|
|
11329
11348
|
ctx.globalAlpha *= resolveContentOpacity(content);
|
|
11330
|
-
drawRoundedRectPath2(ctx,
|
|
11349
|
+
drawRoundedRectPath2(ctx, drawLeft, drawTop, drawWidth, drawHeight, radius);
|
|
11331
11350
|
ctx.fillStyle = content.style?.backgroundColor ?? palette.backgroundColor;
|
|
11332
11351
|
ctx.fill();
|
|
11333
11352
|
if (bordered) {
|
|
11353
|
+
drawRoundedRectPath2(
|
|
11354
|
+
ctx,
|
|
11355
|
+
drawLeft + 0.5,
|
|
11356
|
+
drawTop + 0.5,
|
|
11357
|
+
Math.max(drawWidth - 1, 0),
|
|
11358
|
+
Math.max(drawHeight - 1, 0),
|
|
11359
|
+
Math.max(radius - 0.5, 0)
|
|
11360
|
+
);
|
|
11334
11361
|
ctx.strokeStyle = palette.borderColor;
|
|
11335
11362
|
ctx.lineWidth = 1;
|
|
11336
11363
|
ctx.stroke();
|
|
@@ -26080,18 +26107,58 @@ function autoFitListTableColumnWidths(params) {
|
|
|
26080
26107
|
);
|
|
26081
26108
|
}
|
|
26082
26109
|
const nextWidth = Math.ceil(
|
|
26083
|
-
utils.clamp(measuredWidth, column.minWidth, column.maxWidth)
|
|
26110
|
+
params.fillContainerWidth == null ? utils.clamp(measuredWidth, column.minWidth, column.maxWidth) : Math.max(measuredWidth, column.minWidth)
|
|
26084
26111
|
);
|
|
26085
26112
|
column.width = nextWidth;
|
|
26086
|
-
|
|
26113
|
+
if (params.fillContainerWidth != null) {
|
|
26114
|
+
column.maxWidth = Math.max(column.maxWidth, nextWidth);
|
|
26115
|
+
}
|
|
26116
|
+
setNestedColumnWidth(
|
|
26117
|
+
options.columns,
|
|
26118
|
+
column.key,
|
|
26119
|
+
nextWidth,
|
|
26120
|
+
params.fillContainerWidth != null
|
|
26121
|
+
);
|
|
26087
26122
|
fitted = true;
|
|
26088
26123
|
});
|
|
26124
|
+
if (fitted && params.fillContainerWidth != null) {
|
|
26125
|
+
const hostWidth = params.hostWidth;
|
|
26126
|
+
const measuredTotalWidth = leafColumns.reduce(
|
|
26127
|
+
(sum, column) => sum + column.width,
|
|
26128
|
+
0
|
|
26129
|
+
);
|
|
26130
|
+
const shouldPreserveOverflow = hostWidth != null && measuredTotalWidth > params.fillContainerWidth && measuredTotalWidth <= hostWidth;
|
|
26131
|
+
fillAutoFitColumnWidths(leafColumns, params.fillContainerWidth);
|
|
26132
|
+
if (shouldPreserveOverflow && hostWidth != null) {
|
|
26133
|
+
fillAutoFitColumnWidths(leafColumns, Math.ceil(hostWidth) + 1);
|
|
26134
|
+
}
|
|
26135
|
+
leafColumns.forEach((column) => {
|
|
26136
|
+
if (!isSystemColumnKey(column.key)) {
|
|
26137
|
+
setNestedColumnWidth(options.columns, column.key, column.width, true);
|
|
26138
|
+
}
|
|
26139
|
+
});
|
|
26140
|
+
}
|
|
26089
26141
|
ctx.restore();
|
|
26090
26142
|
if (fitted) {
|
|
26091
26143
|
options.stretchColumns = false;
|
|
26092
26144
|
}
|
|
26093
26145
|
return fitted;
|
|
26094
26146
|
}
|
|
26147
|
+
function fillAutoFitColumnWidths(columns, containerWidth) {
|
|
26148
|
+
let remaining = Math.max(
|
|
26149
|
+
Math.round(
|
|
26150
|
+
containerWidth - columns.reduce((sum, column) => sum + column.width, 0)
|
|
26151
|
+
),
|
|
26152
|
+
0
|
|
26153
|
+
);
|
|
26154
|
+
const candidates = columns.filter((column) => !isSystemColumnKey(column.key));
|
|
26155
|
+
candidates.forEach((column, index) => {
|
|
26156
|
+
const extra = Math.ceil(remaining / (candidates.length - index));
|
|
26157
|
+
column.width += extra;
|
|
26158
|
+
column.maxWidth = Math.max(column.maxWidth, column.width);
|
|
26159
|
+
remaining -= extra;
|
|
26160
|
+
});
|
|
26161
|
+
}
|
|
26095
26162
|
function resolveAutoFitMeasureRows(rows, range = {}) {
|
|
26096
26163
|
if (rows.length === 0) {
|
|
26097
26164
|
return [];
|
|
@@ -26308,6 +26375,10 @@ function createListTableContextMenuActions(params) {
|
|
|
26308
26375
|
params.hideMenu();
|
|
26309
26376
|
params.onAutoFitAllColumns?.();
|
|
26310
26377
|
} : void 0,
|
|
26378
|
+
onAutoFitFillContainer: params.onAutoFitFillContainer ? () => {
|
|
26379
|
+
params.hideMenu();
|
|
26380
|
+
params.onAutoFitFillContainer?.();
|
|
26381
|
+
} : void 0,
|
|
26311
26382
|
onToggleGroupingBar: params.onToggleGroupingBar ? () => {
|
|
26312
26383
|
params.hideMenu();
|
|
26313
26384
|
params.onToggleGroupingBar?.();
|
|
@@ -26537,6 +26608,7 @@ function buildListTableContextMenuConfig(params) {
|
|
|
26537
26608
|
onResetDataFormat: enableReset && isTableSettingsArea ? actions.onResetDataFormat : void 0,
|
|
26538
26609
|
onAutoFitCurrentColumn: enableColumnWidth && isHeaderArea && !isSelectionColumn && actions.onAutoFitCurrentColumn ? () => actions.onAutoFitCurrentColumn?.(columnKey) : void 0,
|
|
26539
26610
|
onAutoFitAllColumns: enableColumnWidth && isTableSettingsArea && !isSelectionColumn && actions.onAutoFitAllColumns ? actions.onAutoFitAllColumns : void 0,
|
|
26611
|
+
onAutoFitFillContainer: enableColumnWidth && isTableSettingsArea && !isSelectionColumn && actions.onAutoFitFillContainer ? actions.onAutoFitFillContainer : void 0,
|
|
26540
26612
|
groupingBarVisible,
|
|
26541
26613
|
onToggleGroupingBar: enableGrouping && (isTableSettingsArea || groupingBarArea) ? actions.onToggleGroupingBar : void 0,
|
|
26542
26614
|
onChangeDensity: enableDensity ? actions.onChangeDensity : void 0,
|
|
@@ -26745,6 +26817,7 @@ function showHeaderContextMenu(params) {
|
|
|
26745
26817
|
onResetDataFormat,
|
|
26746
26818
|
onAutoFitCurrentColumn,
|
|
26747
26819
|
onAutoFitAllColumns,
|
|
26820
|
+
onAutoFitFillContainer,
|
|
26748
26821
|
groupingBarVisible,
|
|
26749
26822
|
groupingBarArea,
|
|
26750
26823
|
onToggleGroupingBar,
|
|
@@ -26858,6 +26931,7 @@ function showHeaderContextMenu(params) {
|
|
|
26858
26931
|
onResetDataFormat,
|
|
26859
26932
|
onAutoFitCurrentColumn,
|
|
26860
26933
|
onAutoFitAllColumns,
|
|
26934
|
+
onAutoFitFillContainer,
|
|
26861
26935
|
onToggleGroupingBar,
|
|
26862
26936
|
onChangeDensity,
|
|
26863
26937
|
onChangeZoom,
|
|
@@ -26941,9 +27015,9 @@ function updateHeaderActionTooltip(params) {
|
|
|
26941
27015
|
tooltip.show(tooltipPoint.x, tooltipPoint.y, text);
|
|
26942
27016
|
}
|
|
26943
27017
|
function showDragTooltip(params) {
|
|
26944
|
-
const { tooltip, toViewportPoint, x, y, text } = params;
|
|
27018
|
+
const { tooltip, toViewportPoint, x, y, text, variant } = params;
|
|
26945
27019
|
const point = toViewportPoint(x, y + 16);
|
|
26946
|
-
tooltip.show(point.x, point.y, text);
|
|
27020
|
+
tooltip.show(point.x, point.y, text, variant);
|
|
26947
27021
|
}
|
|
26948
27022
|
|
|
26949
27023
|
// src/shared/utils/hit-result.ts
|
|
@@ -28635,6 +28709,9 @@ var ListTableEventController = class {
|
|
|
28635
28709
|
onAutoFitAllColumns: () => {
|
|
28636
28710
|
this.autoFitColumnWidths();
|
|
28637
28711
|
},
|
|
28712
|
+
onAutoFitFillContainer: () => {
|
|
28713
|
+
this.autoFitColumnWidths(void 0, true);
|
|
28714
|
+
},
|
|
28638
28715
|
groupingBarVisible: this.host.groupBarVisible,
|
|
28639
28716
|
groupingBarArea,
|
|
28640
28717
|
onToggleGroupingBar: () => {
|
|
@@ -29138,7 +29215,8 @@ var ListTableEventController = class {
|
|
|
29138
29215
|
toViewportPoint: (x, y) => this.host.toViewportPoint(x, y),
|
|
29139
29216
|
x: dragPos.x,
|
|
29140
29217
|
y: dragPos.y,
|
|
29141
|
-
text: `${resizeResult.column.title}: ${resizeResult.nextWidth}px
|
|
29218
|
+
text: `${resizeResult.column.title}: ${resizeResult.nextWidth}px`,
|
|
29219
|
+
variant: "resize"
|
|
29142
29220
|
});
|
|
29143
29221
|
}
|
|
29144
29222
|
this.host.scheduleRender();
|
|
@@ -29854,7 +29932,7 @@ var ListTableEventController = class {
|
|
|
29854
29932
|
} catch {
|
|
29855
29933
|
}
|
|
29856
29934
|
}
|
|
29857
|
-
async autoFitColumnWidths(columnKey) {
|
|
29935
|
+
async autoFitColumnWidths(columnKey, fillContainer = false) {
|
|
29858
29936
|
const ctx = this.host.canvasElement?.getContext("2d");
|
|
29859
29937
|
if (!ctx) {
|
|
29860
29938
|
return;
|
|
@@ -29893,7 +29971,9 @@ var ListTableEventController = class {
|
|
|
29893
29971
|
columnKeys,
|
|
29894
29972
|
rowStartIndex: startIndex,
|
|
29895
29973
|
rowEndIndex: endIndex,
|
|
29896
|
-
summaryValues
|
|
29974
|
+
summaryValues,
|
|
29975
|
+
fillContainerWidth: fillContainer ? snapshot?.viewport.width ?? this.host.canvasElement?.clientWidth : void 0,
|
|
29976
|
+
hostWidth: fillContainer ? this.host.canvasElement?.clientWidth || snapshot?.viewport.width : void 0
|
|
29897
29977
|
});
|
|
29898
29978
|
if (!changed) {
|
|
29899
29979
|
return;
|