WebUI module split; docs
This commit is contained in:
@@ -670,7 +670,7 @@ export default function DataGrid<T>({
|
||||
startX: event.clientX,
|
||||
startWidth: currentWidth,
|
||||
minWidth: effectiveColumnMinWidth(column),
|
||||
maxWidth: Math.max(effectiveColumnMinWidth(column), column.maxWidth ?? 2000),
|
||||
maxWidth: effectiveColumnMaxWidth(column),
|
||||
baseWidths,
|
||||
rightResizeTargets,
|
||||
bufferTarget: canUseBuffer ? {
|
||||
@@ -1223,7 +1223,7 @@ function sanitizePersistedColumnState<T>(
|
||||
const column = columnMap.get(columnId);
|
||||
if (!column || !Number.isFinite(width)) return [];
|
||||
const minimum = effectiveColumnMinWidth(column);
|
||||
const maximum = Math.max(minimum, column.maxWidth ?? 2000);
|
||||
const maximum = effectiveColumnMaxWidth(column, minimum);
|
||||
return [[columnId, Math.min(maximum, Math.max(minimum, width))]];
|
||||
})
|
||||
);
|
||||
@@ -1246,7 +1246,7 @@ function sanitizePersistedColumnState<T>(
|
||||
|
||||
function widthForColumn<T>(column: DataGridColumn<T>, savedWidth?: number): string {
|
||||
const minimum = effectiveColumnMinWidth(column);
|
||||
const maximum = Math.max(minimum, column.maxWidth ?? 2000);
|
||||
const maximum = effectiveColumnMaxWidth(column, minimum);
|
||||
if (savedWidth !== undefined) return `${Math.min(maximum, Math.max(minimum, savedWidth))}px`;
|
||||
if (typeof column.width === "number") return `${Math.min(maximum, Math.max(minimum, column.width))}px`;
|
||||
if (column.width) return columnTrackWithMinimum(column.width, minimum);
|
||||
@@ -1291,7 +1291,7 @@ function resizeTargetForColumn<T>(column: DataGridColumn<T>, baseWidths: Record<
|
||||
columnId: column.id,
|
||||
startWidth: baseWidths[column.id] ?? columnPixelWidth(column),
|
||||
minWidth: minimum,
|
||||
maxWidth: Math.max(minimum, column.maxWidth ?? 2000)
|
||||
maxWidth: effectiveColumnMaxWidth(column, minimum)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1303,6 +1303,11 @@ function effectiveColumnMinWidth<T>(column: DataGridColumn<T>): number {
|
||||
return Math.max(column.minWidth ?? 0, affordanceWidth);
|
||||
}
|
||||
|
||||
function effectiveColumnMaxWidth<T>(column: DataGridColumn<T>, minimum = effectiveColumnMinWidth(column)): number {
|
||||
if (column.maxWidth !== undefined) return Math.max(minimum, column.maxWidth);
|
||||
return Math.max(minimum, isFlexibleWidth(column.width) ? BUFFER_MAX_WIDTH : 2000);
|
||||
}
|
||||
|
||||
function totalColumnWidth<T>(columns: DataGridColumn<T>[], widths: Record<string, number>): number {
|
||||
return columns.reduce((total, column) => total + (widths[column.id] ?? columnPixelWidth(column)), 0);
|
||||
}
|
||||
@@ -1450,7 +1455,7 @@ function isFlexibleWidth(width?: string | number): boolean {
|
||||
|
||||
function columnPixelWidth<T>(column: DataGridColumn<T>, savedWidth?: number, measuredWidth?: number): number {
|
||||
const minimum = effectiveColumnMinWidth(column);
|
||||
const maximum = Math.max(minimum, column.maxWidth ?? 2000);
|
||||
const maximum = effectiveColumnMaxWidth(column, minimum);
|
||||
const configured = measuredWidth
|
||||
?? savedWidth
|
||||
?? (typeof column.width === "number" ? column.width : parsePixelWidth(column.width))
|
||||
|
||||
Reference in New Issue
Block a user