@canvas-components/list-table 0.3.13 → 0.3.14
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 +296 -272
- package/dist/index.cjs +55 -37
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +56 -38
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { CanvasScrollbarOptions, XlsxExportOptions } from '@canvas-components/utils';
|
|
2
|
+
export { CanvasScrollbarAxisOptions as ListTableScrollbarAxisOptions } from '@canvas-components/utils';
|
|
1
3
|
import { CanvasChartSparklineOption } from '@canvas-components/chart';
|
|
2
|
-
import { XlsxExportOptions } from '@canvas-components/utils';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 排序状态。
|
|
@@ -1488,7 +1489,7 @@ interface ListTableContextMenuOptions {
|
|
|
1488
1489
|
/**
|
|
1489
1490
|
* 画布滚动条配置。
|
|
1490
1491
|
*/
|
|
1491
|
-
interface ListTableScrollbarOptions {
|
|
1492
|
+
interface ListTableScrollbarOptions extends CanvasScrollbarOptions {
|
|
1492
1493
|
thickness?: number;
|
|
1493
1494
|
horizontalLeft?: number;
|
|
1494
1495
|
horizontalRight?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { CanvasScrollbarOptions, XlsxExportOptions } from '@canvas-components/utils';
|
|
2
|
+
export { CanvasScrollbarAxisOptions as ListTableScrollbarAxisOptions } from '@canvas-components/utils';
|
|
1
3
|
import { CanvasChartSparklineOption } from '@canvas-components/chart';
|
|
2
|
-
import { XlsxExportOptions } from '@canvas-components/utils';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 排序状态。
|
|
@@ -1488,7 +1489,7 @@ interface ListTableContextMenuOptions {
|
|
|
1488
1489
|
/**
|
|
1489
1490
|
* 画布滚动条配置。
|
|
1490
1491
|
*/
|
|
1491
|
-
interface ListTableScrollbarOptions {
|
|
1492
|
+
interface ListTableScrollbarOptions extends CanvasScrollbarOptions {
|
|
1492
1493
|
thickness?: number;
|
|
1493
1494
|
horizontalLeft?: number;
|
|
1494
1495
|
horizontalRight?: number;
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { stringifyDataIndex, getValueByDataIndex, clamp, copyTextSync, copyText, exportTableToXlsx, formatPreciseNumber, addPreciseNumbers, comparePreciseNumbers, isSameDataIndex, dividePreciseNumber, exportTableToTxt, exportTableToCsv, downloadJsonFile, mapRowsToExportRecords, copyJson, copyRows, parseNumberValue, formatNumberValue, formatPercentValue, formatScientificValue, formatChineseNumber, parseChineseNumber, normalizeDecimalPlaces, roundPreciseNumber, isDateTimeFormatPattern, formatDateTimeValue, formatCustomNumberPattern, isPointInRect as isPointInRect$1 } from '@canvas-components/utils';
|
|
1
|
+
import { stringifyDataIndex, getValueByDataIndex, clamp, copyTextSync, copyText, exportTableToXlsx, resolveCanvasScrollbarAxis, formatPreciseNumber, addPreciseNumbers, comparePreciseNumbers, isSameDataIndex, dividePreciseNumber, exportTableToTxt, exportTableToCsv, downloadJsonFile, mapRowsToExportRecords, copyJson, copyRows, parseNumberValue, formatNumberValue, formatPercentValue, formatScientificValue, formatChineseNumber, parseChineseNumber, normalizeDecimalPlaces, roundPreciseNumber, isDateTimeFormatPattern, formatDateTimeValue, formatCustomNumberPattern, isPointInRect as isPointInRect$1 } from '@canvas-components/utils';
|
|
2
2
|
import { drawBarcodeToCanvas } from '@canvas-components/barcode';
|
|
3
3
|
import { drawCanvasChartToCanvas, getCanvasChartRenderer, resolveCanvasChartTooltipText } from '@canvas-components/chart';
|
|
4
4
|
import { drawQrCodeToCanvas } from '@canvas-components/qrcode';
|
|
@@ -24026,8 +24026,6 @@ function deferQueryUntilLoadingPaint(start) {
|
|
|
24026
24026
|
}, 0);
|
|
24027
24027
|
});
|
|
24028
24028
|
}
|
|
24029
|
-
|
|
24030
|
-
// src/domain/layout/compute-scrollbar-layout.ts
|
|
24031
24029
|
var DEFAULT_HORIZONTAL_LEFT = 0;
|
|
24032
24030
|
var DEFAULT_HORIZONTAL_RIGHT = 0;
|
|
24033
24031
|
var DEFAULT_HORIZONTAL_BOTTOM = 0;
|
|
@@ -24037,10 +24035,8 @@ var DEFAULT_VERTICAL_BOTTOM = 0;
|
|
|
24037
24035
|
var MIN_SCROLLBAR_THUMB_SIZE = 36;
|
|
24038
24036
|
function computeScrollbarLayout(params) {
|
|
24039
24037
|
const layout = {};
|
|
24040
|
-
const
|
|
24041
|
-
|
|
24042
|
-
6
|
|
24043
|
-
);
|
|
24038
|
+
const horizontal = resolveCanvasScrollbarAxis(params.scrollbar, "horizontal");
|
|
24039
|
+
const vertical = resolveCanvasScrollbarAxis(params.scrollbar, "vertical");
|
|
24044
24040
|
const horizontalLeft = Math.max(
|
|
24045
24041
|
params.scrollbar?.horizontalLeft ?? DEFAULT_HORIZONTAL_LEFT,
|
|
24046
24042
|
0
|
|
@@ -24066,11 +24062,12 @@ function computeScrollbarLayout(params) {
|
|
|
24066
24062
|
0
|
|
24067
24063
|
);
|
|
24068
24064
|
const horizontalTrackWidth = Math.max(
|
|
24069
|
-
params.width - horizontalLeft - horizontalRight - (params.maxScrollTop > 0 ? thickness : 0),
|
|
24065
|
+
params.width - horizontalLeft - horizontalRight - (params.maxScrollTop > 0 && vertical.visible ? vertical.thickness : 0),
|
|
24070
24066
|
0
|
|
24071
24067
|
);
|
|
24072
|
-
const horizontalTrackY = params.height - thickness - horizontalBottom;
|
|
24073
|
-
if (params.maxScrollLeft > 0 && horizontalTrackWidth > 0) {
|
|
24068
|
+
const horizontalTrackY = params.height - horizontal.thickness - horizontalBottom;
|
|
24069
|
+
if (horizontal.visible && params.maxScrollLeft > 0 && horizontalTrackWidth > 0) {
|
|
24070
|
+
const thickness = horizontal.thickness;
|
|
24074
24071
|
const buttonSize = Math.min(thickness, horizontalTrackWidth / 3);
|
|
24075
24072
|
const trackX = horizontalLeft + buttonSize;
|
|
24076
24073
|
const trackWidth = Math.max(horizontalTrackWidth - buttonSize * 2, 0);
|
|
@@ -24113,9 +24110,10 @@ function computeScrollbarLayout(params) {
|
|
|
24113
24110
|
params.bodyHeight - verticalTop - verticalBottom,
|
|
24114
24111
|
0
|
|
24115
24112
|
);
|
|
24116
|
-
const verticalTrackX = params.width - thickness - verticalRight;
|
|
24113
|
+
const verticalTrackX = params.width - vertical.thickness - verticalRight;
|
|
24117
24114
|
const verticalTrackY = params.bodyTop + verticalTop;
|
|
24118
|
-
if (params.maxScrollTop > 0 && verticalTrackHeight > 0) {
|
|
24115
|
+
if (vertical.visible && params.maxScrollTop > 0 && verticalTrackHeight > 0) {
|
|
24116
|
+
const thickness = vertical.thickness;
|
|
24119
24117
|
const buttonSize = Math.min(thickness, verticalTrackHeight / 3);
|
|
24120
24118
|
const trackY = verticalTrackY + buttonSize;
|
|
24121
24119
|
const trackHeight = Math.max(verticalTrackHeight - buttonSize * 2, 0);
|
|
@@ -26030,10 +26028,15 @@ function buildListTableRenderSnapshot(params) {
|
|
|
26030
26028
|
baseRowsOverride,
|
|
26031
26029
|
displayRowsOverride
|
|
26032
26030
|
} = params;
|
|
26033
|
-
const
|
|
26034
|
-
options.scrollbar
|
|
26035
|
-
|
|
26031
|
+
const verticalScrollbar = resolveCanvasScrollbarAxis(
|
|
26032
|
+
options.scrollbar,
|
|
26033
|
+
"vertical"
|
|
26034
|
+
);
|
|
26035
|
+
const horizontalScrollbar = resolveCanvasScrollbarAxis(
|
|
26036
|
+
options.scrollbar,
|
|
26037
|
+
"horizontal"
|
|
26036
26038
|
);
|
|
26039
|
+
const scrollbarThickness = verticalScrollbar.visible ? verticalScrollbar.thickness : 0;
|
|
26037
26040
|
let width = Math.max(hostWidth - scrollbarThickness, 0);
|
|
26038
26041
|
let height = hostHeight;
|
|
26039
26042
|
const sourceNormalizedColumns = normalizeColumns(
|
|
@@ -26101,8 +26104,8 @@ function buildListTableRenderSnapshot(params) {
|
|
|
26101
26104
|
(col) => col.summary != null && col.summary !== false || col.summaryTitle != null
|
|
26102
26105
|
);
|
|
26103
26106
|
const hasSummary = queryRows.displayRows.length > 0 && options.summaryRowHeight !== 0 && (options.summaryRowHeight != null || hasConfiguredSummary);
|
|
26104
|
-
const hasHorizontalScrollbar =
|
|
26105
|
-
const horizontalScrollbarReserve = hasHorizontalScrollbar ?
|
|
26107
|
+
const hasHorizontalScrollbar = horizontalScrollbar.visible && columnMetrics.centerContentWidth - columnMetrics.availableCenterWidth > 1;
|
|
26108
|
+
const horizontalScrollbarReserve = hasHorizontalScrollbar ? horizontalScrollbar.thickness + Math.max(options.scrollbar?.horizontalBottom ?? 0, 0) : 0;
|
|
26106
26109
|
const contentHeight = Math.max(height - horizontalScrollbarReserve, 0);
|
|
26107
26110
|
const initialBodyLayout = resolveBodyLayout({
|
|
26108
26111
|
height: contentHeight,
|
|
@@ -27022,9 +27025,7 @@ function resolveListTableRenderHostSize(params) {
|
|
|
27022
27025
|
height: canvasHostElement && canvasHostElement.clientHeight > 0 ? canvasHostElement.clientHeight : fallbackHeight
|
|
27023
27026
|
};
|
|
27024
27027
|
}
|
|
27025
|
-
|
|
27026
|
-
// src/rendering/primitives/draw-scrollbars.ts
|
|
27027
|
-
function drawScrollbars(ctx, layout, descriptors, borderColor, opacity = 1, interactive = true, verticalFrame) {
|
|
27028
|
+
function drawScrollbars(ctx, layout, descriptors, borderColor, opacity = 1, interactive = true, verticalFrame, options) {
|
|
27028
27029
|
const alpha = Number.isFinite(opacity) ? Math.min(Math.max(opacity, 0), 1) : 1;
|
|
27029
27030
|
if (alpha <= 1e-3) {
|
|
27030
27031
|
return;
|
|
@@ -27048,7 +27049,8 @@ function drawScrollbars(ctx, layout, descriptors, borderColor, opacity = 1, inte
|
|
|
27048
27049
|
"horizontal",
|
|
27049
27050
|
descriptors,
|
|
27050
27051
|
borderColor,
|
|
27051
|
-
interactive
|
|
27052
|
+
interactive,
|
|
27053
|
+
resolveCanvasScrollbarAxis(options, "horizontal")
|
|
27052
27054
|
);
|
|
27053
27055
|
}
|
|
27054
27056
|
if (layout.vertical) {
|
|
@@ -27058,7 +27060,8 @@ function drawScrollbars(ctx, layout, descriptors, borderColor, opacity = 1, inte
|
|
|
27058
27060
|
"vertical",
|
|
27059
27061
|
descriptors,
|
|
27060
27062
|
borderColor,
|
|
27061
|
-
interactive
|
|
27063
|
+
interactive,
|
|
27064
|
+
resolveCanvasScrollbarAxis(options, "vertical")
|
|
27062
27065
|
);
|
|
27063
27066
|
}
|
|
27064
27067
|
if (layout.horizontal) {
|
|
@@ -27102,7 +27105,7 @@ function drawHorizontalScrollbarTopBorder(ctx, horizontal, vertical, borderColor
|
|
|
27102
27105
|
ctx.stroke();
|
|
27103
27106
|
ctx.restore();
|
|
27104
27107
|
}
|
|
27105
|
-
function drawAxisScrollbar(ctx, layout, axis, descriptors, borderColor, interactive) {
|
|
27108
|
+
function drawAxisScrollbar(ctx, layout, axis, descriptors, borderColor, interactive, style) {
|
|
27106
27109
|
const kind = axis === "horizontal" ? "horizontal-scrollbar" : "vertical-scrollbar";
|
|
27107
27110
|
if (interactive) {
|
|
27108
27111
|
descriptors.push({
|
|
@@ -27130,9 +27133,21 @@ function drawAxisScrollbar(ctx, layout, axis, descriptors, borderColor, interact
|
|
|
27130
27133
|
scrollbarRole: "increase-button"
|
|
27131
27134
|
});
|
|
27132
27135
|
}
|
|
27133
|
-
|
|
27134
|
-
|
|
27135
|
-
|
|
27136
|
+
if (style.trackColor != null) {
|
|
27137
|
+
ctx.save();
|
|
27138
|
+
ctx.fillStyle = style.trackColor;
|
|
27139
|
+
for (const rect of [
|
|
27140
|
+
layout.track,
|
|
27141
|
+
layout.decreaseButton,
|
|
27142
|
+
layout.increaseButton
|
|
27143
|
+
]) {
|
|
27144
|
+
ctx.fillRect(rect.x, rect.y, rect.width, rect.height);
|
|
27145
|
+
}
|
|
27146
|
+
ctx.restore();
|
|
27147
|
+
}
|
|
27148
|
+
drawButton(ctx, layout.decreaseButton, axis, "decrease", style.buttonColor);
|
|
27149
|
+
drawButton(ctx, layout.increaseButton, axis, "increase", style.buttonColor);
|
|
27150
|
+
drawThumb(ctx, layout.thumb, style);
|
|
27136
27151
|
drawTrackBorder(ctx, layout.track, axis, borderColor);
|
|
27137
27152
|
}
|
|
27138
27153
|
function drawTrackBorder(ctx, rect, axis, borderColor) {
|
|
@@ -27195,16 +27210,23 @@ function drawVerticalScrollbarFrame(ctx, frame, borderColor) {
|
|
|
27195
27210
|
}
|
|
27196
27211
|
ctx.restore();
|
|
27197
27212
|
}
|
|
27198
|
-
function drawThumb(ctx, rect) {
|
|
27213
|
+
function drawThumb(ctx, rect, style) {
|
|
27199
27214
|
ctx.save();
|
|
27200
|
-
ctx.fillStyle =
|
|
27201
|
-
roundRect2(
|
|
27215
|
+
ctx.fillStyle = style.thumbColor;
|
|
27216
|
+
roundRect2(
|
|
27217
|
+
ctx,
|
|
27218
|
+
rect.x,
|
|
27219
|
+
rect.y,
|
|
27220
|
+
rect.width,
|
|
27221
|
+
rect.height,
|
|
27222
|
+
style.thumbRadius ?? rect.height / 2
|
|
27223
|
+
);
|
|
27202
27224
|
ctx.fill();
|
|
27203
27225
|
ctx.restore();
|
|
27204
27226
|
}
|
|
27205
|
-
function drawButton(ctx, rect, axis, direction) {
|
|
27227
|
+
function drawButton(ctx, rect, axis, direction, color) {
|
|
27206
27228
|
ctx.save();
|
|
27207
|
-
ctx.fillStyle =
|
|
27229
|
+
ctx.fillStyle = color;
|
|
27208
27230
|
ctx.beginPath();
|
|
27209
27231
|
const centerX = rect.x + rect.width / 2;
|
|
27210
27232
|
const centerY = rect.y + rect.height / 2;
|
|
@@ -29479,8 +29501,6 @@ function resolveActiveCellSectionClipRect(descriptor, params) {
|
|
|
29479
29501
|
height: isTopFrozen ? params.topFrozenHeight : params.bottomFrozenHeight
|
|
29480
29502
|
};
|
|
29481
29503
|
}
|
|
29482
|
-
|
|
29483
|
-
// src/rendering/pipeline/render-pipeline.ts
|
|
29484
29504
|
function executeListTableRenderPipeline(params) {
|
|
29485
29505
|
const {
|
|
29486
29506
|
renderer,
|
|
@@ -29714,16 +29734,14 @@ function executeListTableRenderPipeline(params) {
|
|
|
29714
29734
|
isScrollbarInteractive,
|
|
29715
29735
|
{
|
|
29716
29736
|
x: width,
|
|
29717
|
-
width: options.scrollbar
|
|
29718
|
-
options.scrollbar?.thickness ?? DEFAULT_SCROLLBAR_THICKNESS,
|
|
29719
|
-
6
|
|
29720
|
-
),
|
|
29737
|
+
width: !resolveCanvasScrollbarAxis(options.scrollbar, "vertical").visible ? 0 : resolveCanvasScrollbarAxis(options.scrollbar, "vertical").thickness,
|
|
29721
29738
|
top: 0,
|
|
29722
29739
|
height,
|
|
29723
29740
|
headerBottom: headerHeight,
|
|
29724
29741
|
headerBackgroundColor: theme.headerBackgroundColor,
|
|
29725
29742
|
bodyBackgroundColor: theme.backgroundColor
|
|
29726
|
-
}
|
|
29743
|
+
},
|
|
29744
|
+
options.scrollbar
|
|
29727
29745
|
);
|
|
29728
29746
|
drawActiveCellOverlay({
|
|
29729
29747
|
ctx,
|