ztxkui 4.2.23-630 → 4.2.23-632

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.
Files changed (33) hide show
  1. package/dist/components/CanvasTable/constants.js +1 -1
  2. package/dist/components/CanvasTable/draw/canvas.js +71 -43
  3. package/dist/components/CanvasTable/draw/primitives.d.ts +2 -0
  4. package/dist/components/CanvasTable/draw/primitives.js +28 -0
  5. package/dist/components/CanvasTable/draw/scene.d.ts +30 -2
  6. package/dist/components/CanvasTable/draw/scene.js +76 -16
  7. package/dist/components/CanvasTable/hooks/useColumnWidths.d.ts +1 -0
  8. package/dist/components/CanvasTable/hooks/useColumnWidths.js +1 -1
  9. package/dist/components/CanvasTable/hooks/useCopy.js +16 -0
  10. package/dist/components/CanvasTable/hooks/useInteractions.d.ts +16 -1
  11. package/dist/components/CanvasTable/hooks/useInteractions.js +90 -24
  12. package/dist/components/CanvasTable/index.d.ts +2 -0
  13. package/dist/components/CanvasTable/index.js +190 -66
  14. package/dist/components/CanvasTable/interface.d.ts +104 -5
  15. package/dist/components/CanvasTable/utils/canvasAtom.d.ts +37 -0
  16. package/dist/components/CanvasTable/utils/canvasAtom.js +228 -0
  17. package/dist/components/CanvasTable/utils/canvasCells.d.ts +15 -0
  18. package/dist/components/CanvasTable/utils/canvasCells.js +118 -0
  19. package/dist/components/CanvasTable/utils/hitTest.d.ts +3 -3
  20. package/dist/components/CanvasTable/utils/hitTest.js +28 -9
  21. package/dist/components/CanvasTable/utils/index.d.ts +1 -0
  22. package/dist/components/CanvasTable/utils/index.js +1 -0
  23. package/dist/components/CanvasTable/utils/layout.d.ts +1 -3
  24. package/dist/components/CanvasTable/utils/layout.js +8 -15
  25. package/dist/components/CanvasTable/utils/measureDom.d.ts +11 -0
  26. package/dist/components/CanvasTable/utils/measureDom.js +54 -0
  27. package/dist/components/CanvasTable/utils/rowHeights.d.ts +3 -2
  28. package/dist/components/CanvasTable/utils/rowHeights.js +44 -9
  29. package/dist/components/business/OperationBtnGroup/index.d.ts +16 -0
  30. package/dist/components/business/OperationBtnGroup/index.js +38 -0
  31. package/dist/index.build.d.ts +2 -2
  32. package/dist/index.build.js +1 -1
  33. package/package.json +1 -1
@@ -21,7 +21,7 @@ export var COLORS = {
21
21
  selectionBg: 'rgba(24, 144, 255, 0.1)',
22
22
  text: '#333333',
23
23
  secondaryText: '#999999',
24
- border: '#f0f0f0',
24
+ border: '#ebebeb',
25
25
  primary: '#1890ff',
26
26
  scrollbarTrack: '#f0f0f0',
27
27
  scrollbarThumb: '#bfbfbf',
@@ -1,7 +1,8 @@
1
1
  import { COLORS, FONT_FAMILY, FONT_SIZE, FONT_WEIGHT, TEXT_PADDING, RESIZE_HANDLE_WIDTH, SCROLLBAR_SIZE, } from '../constants';
2
2
  import { truncateText, wrapText } from '../utils/text';
3
+ import { drawAtomsCell } from '../utils/canvasAtom';
3
4
  import { SPECIAL_KEYS } from '../utils/layout';
4
- import { drawCheckbox, drawSortIcon, drawFilterIcon, drawExpandIcon, drawBadgeTriangle, } from './primitives';
5
+ import { drawCheckbox, drawRadio, drawSortIcon, drawFilterIcon, drawExpandIcon, drawBadgeTriangle, } from './primitives';
5
6
  function applyFont(ctx) {
6
7
  ctx.font = FONT_WEIGHT + " " + FONT_SIZE + "px " + FONT_FAMILY;
7
8
  ctx.textBaseline = 'middle';
@@ -24,7 +25,8 @@ function drawTextCell(ctx, cell, useHeaderAlign) {
24
25
  }
25
26
  ctx.fillStyle = COLORS.text;
26
27
  // 换行绘制(垂直居中多行;超出单元格高度被 clip 裁剪)
27
- if (cell.wrap && cell.text) {
28
+ // 含显式换行符:按换行符分段(表头"复制整列"两行布局),其余同 wrap 逻辑
29
+ if (cell.text && (cell.wrap || cell.text.indexOf('\n') >= 0)) {
28
30
  var lines = wrapText(ctx, cell.text, availWidth);
29
31
  var lineHeight_1 = FONT_SIZE + 5;
30
32
  var totalH = lines.length * lineHeight_1;
@@ -42,18 +44,16 @@ function drawTextCell(ctx, cell, useHeaderAlign) {
42
44
  }
43
45
  function drawHeaderIcons(ctx, cell) {
44
46
  var _a;
45
- if (!cell.canSort && !cell.hasFilter)
47
+ if (!cell.canSort && !cell.hasFilter && !cell.canCopy)
46
48
  return;
47
49
  var centerY = cell.y + cell.height / 2;
48
- // 图标布局与 hitTest.getHeaderIconAt 一致:筛选中心 width-10,排序中心 width-25
50
+ // 图标布局与 hitTest.getHeaderIconAt 一致:
51
+ // filter 中心 width-10;sort 无 copy 时 width-25、有 copy 时 width-29;copy 中心 width-47
49
52
  if (cell.hasFilter) {
50
53
  drawFilterIcon(ctx, cell.x + cell.width - 10, centerY, !!cell.filterActive);
51
54
  }
52
55
  if (cell.canSort) {
53
- var sortCenterX = cell.hasFilter
54
- ? cell.x + cell.width - 25
55
- : cell.x + cell.width - 10;
56
- drawSortIcon(ctx, sortCenterX, centerY, (_a = cell.sortState) !== null && _a !== void 0 ? _a : null);
56
+ drawSortIcon(ctx, cell.x + cell.width - (cell.hasFilter ? 29 : 10), centerY, (_a = cell.sortState) !== null && _a !== void 0 ? _a : null);
57
57
  }
58
58
  }
59
59
  /** 展开图标占位宽度(缩进 + 图标区),用于文本偏移 */
@@ -161,7 +161,7 @@ export function drawScene(ctx, scene) {
161
161
  }
162
162
  }
163
163
  // ---- 数据区 ----
164
- var dataBottom = metrics.needH ? height - SCROLLBAR_SIZE : height;
164
+ var dataBottom = height;
165
165
  var _loop_1 = function (cell) {
166
166
  var layout = layouts[cell.col];
167
167
  if (!layout)
@@ -182,9 +182,7 @@ export function drawScene(ctx, scene) {
182
182
  var clipYBottom = cell.y + cell.height;
183
183
  if (!inFixedTop && !inFixedBottom) {
184
184
  clipYTop = Math.max(clipYTop, headerHeight + scene.fixedTopRows * rowHeight);
185
- clipYBottom = Math.min(clipYBottom, height -
186
- (metrics.needH ? SCROLLBAR_SIZE : 0) -
187
- scene.fixedBottomRows * rowHeight);
185
+ clipYBottom = Math.min(clipYBottom, height - scene.fixedBottomRows * rowHeight);
188
186
  }
189
187
  else if (inFixedBottom) {
190
188
  clipYBottom = Math.min(clipYBottom, dataBottom);
@@ -223,7 +221,12 @@ export function drawScene(ctx, scene) {
223
221
  }
224
222
  // 内容
225
223
  if (cell.kind === 'checkbox') {
226
- drawCheckbox(ctx, cell.x + cell.width / 2, cell.y + cell.height / 2, !!cell.checked, !!cell.disabled);
224
+ if (cell.radio) {
225
+ drawRadio(ctx, cell.x + cell.width / 2, cell.y + cell.height / 2, !!cell.checked, !!cell.disabled);
226
+ }
227
+ else {
228
+ drawCheckbox(ctx, cell.x + cell.width / 2, cell.y + cell.height / 2, !!cell.checked, !!cell.disabled);
229
+ }
227
230
  }
228
231
  else if (cell.kind === 'empty') {
229
232
  // 合计行的勾选/序号等留空单元格
@@ -263,21 +266,34 @@ export function drawScene(ctx, scene) {
263
266
  drawTextCell(ctx, cell, false);
264
267
  }
265
268
  }
269
+ else if (cell.kind === 'atoms' && cell.atoms) {
270
+ // renderToCanvas 协议:canvas 直绘原子(链接/文本/状态点)
271
+ var ha = scene.hoverAtom;
272
+ var isHoverCell = !!ha && ha.row === cell.row && ha.col === cell.col;
273
+ drawAtomsCell(ctx, cell.atoms.layout, cell.x, cell.y, cell.width, cell.height, isHoverCell ? ha.index : -1, isHoverCell);
274
+ }
266
275
  // overlay 单元格不绘制,交给 DOM 覆盖层
267
276
  // 角标
268
277
  if (cell.badge) {
269
278
  drawBadgeTriangle(ctx, cell.x, cell.y, cell.width, cell.height, cell.badge.position, cell.badge.color);
270
279
  }
271
- // 单元格边框
280
+ // 单元格边框(fillRect 1px 精确画法,避免缩放屏抗锯齿发深)
272
281
  if (scene.bordered) {
273
- ctx.strokeStyle = COLORS.border;
274
- ctx.lineWidth = 1;
275
- ctx.beginPath();
276
- ctx.moveTo(cell.x + cell.width, cell.y);
277
- ctx.lineTo(cell.x + cell.width, cell.y + cell.height);
278
- ctx.moveTo(cell.x, cell.y + cell.height);
279
- ctx.lineTo(cell.x + cell.width, cell.y + cell.height);
280
- ctx.stroke();
282
+ // 悬浮横向滚动条覆盖区内不画底边框(避免滚动条上方露出一条边线)
283
+ var cellBottom = cell.y + cell.height;
284
+ var hbarTop = height -
285
+ (metrics.needH ? SCROLLBAR_SIZE : 0) -
286
+ scene.fixedBottomRows * rowHeight;
287
+ var isFixedBottomRow = cell.row >= scene.dataLength - scene.fixedBottomRows;
288
+ var inFloatingStrip = metrics.needH &&
289
+ !isFixedBottomRow &&
290
+ cellBottom > hbarTop &&
291
+ cellBottom <= hbarTop + SCROLLBAR_SIZE + 1;
292
+ ctx.fillStyle = COLORS.border;
293
+ ctx.fillRect(cell.x + cell.width - 1, cell.y, 1, cell.height);
294
+ if (!inFloatingStrip) {
295
+ ctx.fillRect(cell.x, cellBottom - 1, cell.width, 1);
296
+ }
281
297
  }
282
298
  ctx.restore();
283
299
  };
@@ -298,10 +314,8 @@ export function drawScene(ctx, scene) {
298
314
  ctx.stroke();
299
315
  }
300
316
  if (scene.fixedBottomRows > 0) {
301
- var y = height -
302
- (metrics.needH ? SCROLLBAR_SIZE : 0) -
303
- scene.fixedBottomRows * rowHeight +
304
- 0.5;
317
+ // 分界线贴小计/合计行顶部(悬浮滚动条在其上方 12px,不压线)
318
+ var y = height - scene.fixedBottomRows * rowHeight + 0.5;
305
319
  ctx.strokeStyle = COLORS.fixedEdge;
306
320
  ctx.lineWidth = 1;
307
321
  ctx.beginPath();
@@ -343,7 +357,18 @@ export function drawScene(ctx, scene) {
343
357
  drawCheckbox(ctx, cell.x + cell.width / 2, cell.y + cell.height / 2, isAll, false, isIndeterminate);
344
358
  }
345
359
  else if (cell.kind === 'text') {
346
- if (!cell.isDynamicButton) {
360
+ if (cell.canCopy) {
361
+ // 复制整列:两行表头(标题 #333 + “复制整列” link 蓝,点击蓝字触发复制)
362
+ var cxm = cell.x + cell.width / 2;
363
+ ctx.textAlign = 'center';
364
+ ctx.textBaseline = 'middle';
365
+ ctx.fillStyle = COLORS.text;
366
+ ctx.fillText((cell.text || '').split('\n')[0], cxm, cell.y + 10);
367
+ ctx.fillStyle = COLORS.primary;
368
+ ctx.fillText('复制整列', cxm, cell.y + 26);
369
+ drawHeaderIcons(ctx, cell);
370
+ }
371
+ else if (!cell.isDynamicButton) {
347
372
  drawTextCell(ctx, cell, true);
348
373
  drawHeaderIcons(ctx, cell);
349
374
  }
@@ -401,25 +426,28 @@ export function drawScene(ctx, scene) {
401
426
  }
402
427
  }
403
428
  }
404
- // ---- 固定列阴影 ----
405
- if (fixedLeftRightEdge > 0 && scrollLeft > 0) {
406
- var gradient = ctx.createLinearGradient(fixedLeftRightEdge, 0, fixedLeftRightEdge + 12, 0);
407
- gradient.addColorStop(0, COLORS.shadow);
429
+ // ---- 固定列阴影(仅在固定列覆盖到滚动内容时显示,antd 风格 inset 渐变)----
430
+ var drawFixedShadow = function (edgeX, dir) {
431
+ var gradient = ctx.createLinearGradient(edgeX, 0, edgeX + dir * 20, 0);
432
+ gradient.addColorStop(0, 'rgba(0, 0, 0, 0.08)');
408
433
  gradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
409
434
  ctx.fillStyle = gradient;
410
- ctx.fillRect(fixedLeftRightEdge, 0, 12, height);
411
- ctx.fillStyle = COLORS.fixedEdge;
412
- ctx.fillRect(fixedLeftRightEdge - 1, 0, 1, height);
435
+ ctx.fillRect(Math.min(edgeX, edgeX + dir * 20), 0, 20, height);
436
+ };
437
+ // 左固定列:横向已滚动(盖住了左侧滚出的内容)才显示右缘阴影
438
+ if (fixedLeftRightEdge > 0 && scrollLeft > 0) {
439
+ drawFixedShadow(fixedLeftRightEdge, 1);
413
440
  }
414
- // 右固定区左缘阴影(横向滚动中)
415
- if (fixedRightZoneLeft !== Infinity && scrollLeft > 0) {
416
- var gradient = ctx.createLinearGradient(fixedRightZoneLeft, 0, fixedRightZoneLeft - 12, 0);
417
- gradient.addColorStop(0, COLORS.shadow);
418
- gradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
419
- ctx.fillStyle = gradient;
420
- ctx.fillRect(fixedRightZoneLeft - 12, 0, 12, height);
421
- ctx.fillStyle = COLORS.fixedEdge;
422
- ctx.fillRect(fixedRightZoneLeft, 0, 1, height);
441
+ // 右固定列:还能向右滚(右固定列盖住了右侧内容)才显示左缘阴影
442
+ if (fixedRightZoneLeft !== Infinity &&
443
+ scrollLeft < metrics.maxScrollLeft - 1) {
444
+ drawFixedShadow(fixedRightZoneLeft, -1);
445
+ }
446
+ // ---- 最外层边框(bordered)----
447
+ if (scene.bordered) {
448
+ ctx.strokeStyle = COLORS.border;
449
+ ctx.lineWidth = 1;
450
+ ctx.strokeRect(0.5, 0.5, width - 1, height - 1);
423
451
  }
424
452
  // 滚动条由 DOM 层渲染(支持显隐过渡动画),canvas 不再绘制
425
453
  }
@@ -1,4 +1,6 @@
1
1
  import { SortOrder } from '../interface';
2
+ /** radio 单选圈(对齐 antd Radio 视觉:圆圈 + 选中实心圆点) */
3
+ export declare function drawRadio(ctx: CanvasRenderingContext2D, centerX: number, centerY: number, checked: boolean, disabled: boolean): void;
2
4
  export declare function drawCheckbox(ctx: CanvasRenderingContext2D, centerX: number, centerY: number, checked: boolean, disabled: boolean, indeterminate?: boolean): void;
3
5
  export declare function drawSortIcon(ctx: CanvasRenderingContext2D, centerX: number, centerY: number, order: SortOrder, hoverPart?: 'up' | 'down'): void;
4
6
  export declare function drawFilterIcon(ctx: CanvasRenderingContext2D, centerX: number, centerY: number, active: boolean): void;
@@ -1,4 +1,32 @@
1
1
  import { COLORS, CHECKBOX_SIZE, SORT_ICON_SIZE, ICON_SPACING, } from '../constants';
2
+ /** radio 单选圈(对齐 antd Radio 视觉:圆圈 + 选中实心圆点) */
3
+ export function drawRadio(ctx, centerX, centerY, checked, disabled) {
4
+ var size = CHECKBOX_SIZE;
5
+ var r = size / 2;
6
+ if (disabled) {
7
+ ctx.strokeStyle = COLORS.checkboxBorder;
8
+ ctx.fillStyle = checked ? '#f5f5f5' : COLORS.white;
9
+ }
10
+ else if (checked) {
11
+ ctx.strokeStyle = COLORS.primary;
12
+ ctx.fillStyle = COLORS.white;
13
+ }
14
+ else {
15
+ ctx.strokeStyle = COLORS.checkboxBorder;
16
+ ctx.fillStyle = COLORS.white;
17
+ }
18
+ ctx.lineWidth = 1;
19
+ ctx.beginPath();
20
+ ctx.arc(centerX, centerY, r, 0, Math.PI * 2);
21
+ ctx.fill();
22
+ ctx.stroke();
23
+ if (checked) {
24
+ ctx.fillStyle = disabled ? COLORS.checkboxBorder : COLORS.primary;
25
+ ctx.beginPath();
26
+ ctx.arc(centerX, centerY, r / 2, 0, Math.PI * 2);
27
+ ctx.fill();
28
+ }
29
+ }
2
30
  export function drawCheckbox(ctx, centerX, centerY, checked, disabled, indeterminate) {
3
31
  if (indeterminate === void 0) { indeterminate = false; }
4
32
  var size = CHECKBOX_SIZE;
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
- import { IColumnType, ICellSelection, IBadgeProps, SortOrder } from '../interface';
2
+ import { IColumnType, ICellSelection, IBadgeProps, ICanvasAtom, SortOrder } from '../interface';
3
3
  import { ColumnLayout, ScrollbarMetrics } from '../utils/layout';
4
4
  import { HeaderCellInfo } from '../utils/multiHeader';
5
5
  import { MergeCellMap } from '../utils/merge';
6
6
  import { RowMetrics, createRowAccessor } from '../utils/rowHeights';
7
7
  import type { ISummaryData } from '../../Table/table-summary';
8
+ import { AtomsLayout } from '../utils/canvasAtom';
8
9
  import { FlatRowMeta } from '../hooks/useExpandable';
9
10
  export interface RenderCacheEntry {
10
11
  renderFn: IColumnType['render'];
@@ -12,7 +13,7 @@ export interface RenderCacheEntry {
12
13
  index: number;
13
14
  node: React.ReactNode;
14
15
  }
15
- export declare type CellKind = 'text' | 'overlay' | 'checkbox' | 'index' | 'empty';
16
+ export declare type CellKind = 'text' | 'overlay' | 'checkbox' | 'index' | 'atoms' | 'empty';
16
17
  export interface SceneCell {
17
18
  row: number;
18
19
  col: number;
@@ -30,11 +31,15 @@ export interface SceneCell {
30
31
  node?: React.ReactNode;
31
32
  /** checkbox 状态 */
32
33
  checked?: boolean;
34
+ /** radio 单选圈(rowSelection.type = radio 时勾选格绘制为圆圈) */
35
+ radio?: boolean;
33
36
  disabled?: boolean;
34
37
  indeterminate?: boolean;
35
38
  /** 表头功能图标(仅最末级表头) */
36
39
  canSort?: boolean;
37
40
  hasFilter?: boolean;
41
+ /** 表头复制整列图标 */
42
+ canCopy?: boolean;
38
43
  sortState?: SortOrder;
39
44
  filterActive?: boolean;
40
45
  /** 角标 */
@@ -53,6 +58,13 @@ export interface SceneCell {
53
58
  wrap?: boolean;
54
59
  /** 合计行单元格点击回调(summaryConfig.onClickHandle) */
55
60
  summaryOnClick?: () => void;
61
+ /** renderToCanvas 协议内容(布局随列宽在场景构建时计算) */
62
+ atoms?: {
63
+ atoms: ICanvasAtom[];
64
+ layout: AtomsLayout;
65
+ record: any;
66
+ index: number;
67
+ };
56
68
  /** DOM 覆盖层的裁剪路径(overlayCells 计算时填充) */
57
69
  clipPath?: string;
58
70
  }
@@ -96,6 +108,14 @@ export interface Scene<RecordType = any> {
96
108
  summaryStartIndex: number | null;
97
109
  /** summaryConfig 生成的合计行元数据(与 summaryStartIndex 起的行一一对应) */
98
110
  summaryRows: ISummaryData[] | null;
111
+ /** 当前悬停的协议链接(hover 下划线) */
112
+ hoverAtom: {
113
+ row: number;
114
+ col: number;
115
+ index: number;
116
+ } | null;
117
+ /** 行选择模式 */
118
+ selectionType: 'checkbox' | 'radio';
99
119
  /** 数据总行数 */
100
120
  dataLength: number;
101
121
  mergeMap: MergeCellMap;
@@ -146,11 +166,19 @@ export interface BuildSceneParams<RecordType = any> {
146
166
  getCheckboxProps?: (record: RecordType) => {
147
167
  disabled?: boolean;
148
168
  };
169
+ /** 行选择模式 */
170
+ selectionType?: 'checkbox' | 'radio';
149
171
  summaryStartIndex: number | null;
150
172
  /** summaryConfig 生成的合计行元数据(与 summaryStartIndex 起的行一一对应) */
151
173
  summaryRows?: ISummaryData[] | null;
152
174
  /** render 结果缓存(index.tsx 持有,跨滚动帧复用 render 输出引用) */
153
175
  renderCache?: Map<string, RenderCacheEntry>;
176
+ /** 当前悬停的协议链接(hover 下划线用) */
177
+ hoverAtom?: {
178
+ row: number;
179
+ col: number;
180
+ index: number;
181
+ } | null;
154
182
  mergeMap: MergeCellMap;
155
183
  /** rowKey → 树形层级信息(按 key 映射,过滤/排序后依然稳定) */
156
184
  expandMetaByKey: Map<string, FlatRowMeta> | null;
@@ -4,7 +4,9 @@ import { createRowAccessor } from '../utils/rowHeights';
4
4
  import { isSummaryRow } from '../utils/summary';
5
5
  import { formatCellValue, formatSummaryValue } from '../utils/format';
6
6
  import { measureText } from '../utils/text';
7
- import { TEXT_PADDING, SCROLLBAR_SIZE } from '../constants';
7
+ import { layoutAtoms, ATOM_CELL_PADDING, } from '../utils/canvasAtom';
8
+ import { getCanvasCell } from '../utils/canvasCells';
9
+ import { TEXT_PADDING } from '../constants';
8
10
  /**
9
11
  * render 结果缓存:renderFn/record/index 全一致才复用。
10
12
  * 滚动帧拿到稳定引用,React 跳过内容子树 diff;业务更新 columns 或
@@ -47,7 +49,7 @@ function computeLayerHeight(headerHeight, maxDepth) {
47
49
  */
48
50
  export function buildScene(params) {
49
51
  var _a, _b, _c, _d;
50
- var dataSource = params.dataSource, layouts = params.layouts, headerRows = params.headerRows, getRowKey = params.getRowKey, containerWidth = params.containerWidth, containerHeight = params.containerHeight, headerHeight = params.headerHeight, rowHeight = params.rowHeight, scrollTop = params.scrollTop, scrollLeft = params.scrollLeft, hoverRow = params.hoverRow, sortField = params.sortField, sortOrder = params.sortOrder, filters = params.filters, selectedRowKeys = params.selectedRowKeys, striped = params.striped, bordered = params.bordered, cellSelection = params.cellSelection, resizeHoverIndex = params.resizeHoverIndex, resizeActiveIndex = params.resizeActiveIndex, getCheckboxProps = params.getCheckboxProps, summaryStartIndex = params.summaryStartIndex, _e = params.summaryRows, summaryRows = _e === void 0 ? null : _e, renderCache = params.renderCache, mergeMap = params.mergeMap, expandMetaByKey = params.expandMetaByKey, expandColumnLayoutIndex = params.expandColumnLayoutIndex, expandIndentColumnLayoutIndex = params.expandIndentColumnLayoutIndex, indentSize = params.indentSize, fixedTopRowsParam = params.fixedTopRows, fixedBottomRowsParam = params.fixedBottomRows, globalHeaderAlign = params.globalHeaderAlign, dynamicButtonColumnIndex = params.dynamicButtonColumnIndex, scrollbarVisible = params.scrollbarVisible, headerWrapParam = params.headerWrap, rowMetrics = params.rowMetrics;
52
+ var dataSource = params.dataSource, layouts = params.layouts, headerRows = params.headerRows, getRowKey = params.getRowKey, containerWidth = params.containerWidth, containerHeight = params.containerHeight, headerHeight = params.headerHeight, rowHeight = params.rowHeight, scrollTop = params.scrollTop, scrollLeft = params.scrollLeft, hoverRow = params.hoverRow, sortField = params.sortField, sortOrder = params.sortOrder, filters = params.filters, selectedRowKeys = params.selectedRowKeys, striped = params.striped, bordered = params.bordered, cellSelection = params.cellSelection, resizeHoverIndex = params.resizeHoverIndex, resizeActiveIndex = params.resizeActiveIndex, getCheckboxProps = params.getCheckboxProps, _e = params.selectionType, selectionType = _e === void 0 ? 'checkbox' : _e, summaryStartIndex = params.summaryStartIndex, _f = params.summaryRows, summaryRows = _f === void 0 ? null : _f, renderCache = params.renderCache, _g = params.hoverAtom, hoverAtom = _g === void 0 ? null : _g, mergeMap = params.mergeMap, expandMetaByKey = params.expandMetaByKey, expandColumnLayoutIndex = params.expandColumnLayoutIndex, expandIndentColumnLayoutIndex = params.expandIndentColumnLayoutIndex, indentSize = params.indentSize, fixedTopRowsParam = params.fixedTopRows, fixedBottomRowsParam = params.fixedBottomRows, globalHeaderAlign = params.globalHeaderAlign, dynamicButtonColumnIndex = params.dynamicButtonColumnIndex, scrollbarVisible = params.scrollbarVisible, headerWrapParam = params.headerWrap, rowMetrics = params.rowMetrics;
51
53
  var headerWrap = headerWrapParam;
52
54
  var maxDepth = Math.max(1, headerRows.length);
53
55
  var layerHeight = computeLayerHeight(headerHeight, maxDepth);
@@ -75,11 +77,11 @@ export function buildScene(params) {
75
77
  fixedBottomRows: fixedBottomRowsParam,
76
78
  });
77
79
  // 固定行几何:顶区 [header, header+top*rowH),底区 [height - hBar - bottom*rowH, height - hBar)
78
- var hScrollbarHeight = metrics.needH ? SCROLLBAR_SIZE : 0;
79
80
  var fixedTop = Math.min(fixedTopRowsParam, dataSource.length);
80
81
  var fixedBottom = Math.min(fixedBottomRowsParam, dataSource.length - fixedTop);
81
82
  var topAreaEnd = headerHeight + fixedTop * rowHeight;
82
- var bottomAreaTop = containerHeight - hScrollbarHeight - fixedBottom * rowHeight;
83
+ // 小计/合计行贴底,横向滚动条移至其上方
84
+ var bottomAreaTop = containerHeight - fixedBottom * rowHeight;
83
85
  /** 数据行视口 y;不可见(滚动区外)返回 null */
84
86
  var rowViewportY = function (row) {
85
87
  if (row < 0 || row >= dataSource.length)
@@ -127,8 +129,8 @@ export function buildScene(params) {
127
129
  var headerCells = [];
128
130
  for (var _i = 0, headerRows_1 = headerRows; _i < headerRows_1.length; _i++) {
129
131
  var headerRow = headerRows_1[_i];
130
- for (var _f = 0, headerRow_1 = headerRow; _f < headerRow_1.length; _f++) {
131
- var info = headerRow_1[_f];
132
+ for (var _h = 0, headerRow_1 = headerRow; _h < headerRow_1.length; _h++) {
133
+ var info = headerRow_1[_h];
132
134
  var column = info.column, colIndex = info.colIndex, colSpan = info.colSpan, rowSpan = info.rowSpan, depth = info.depth, isLeaf = info.isLeaf;
133
135
  var first = layouts[colIndex];
134
136
  if (!first)
@@ -165,7 +167,11 @@ export function buildScene(params) {
165
167
  y: depth * layerHeight,
166
168
  width: width,
167
169
  height: rowSpan * layerHeight,
168
- kind: isSelection ? 'checkbox' : 'text',
170
+ kind: isSelection && selectionType === 'radio'
171
+ ? 'empty'
172
+ : isSelection
173
+ ? 'checkbox'
174
+ : 'text',
169
175
  align: 'center',
170
176
  headerAlign: headerAlign,
171
177
  checked: false,
@@ -174,16 +180,22 @@ export function buildScene(params) {
174
180
  !isSelection &&
175
181
  !isIndex &&
176
182
  !isDynamicButton &&
177
- !!column.sorter,
183
+ column.sorter !== false,
178
184
  hasFilter: isLeaf && !isSelection && !isIndex && !isDynamicButton,
185
+ canCopy: isLeaf &&
186
+ !isSelection &&
187
+ !isIndex &&
188
+ !isDynamicButton &&
189
+ !!column.showCopy,
179
190
  sortState: column.key === sortField ? sortOrder : null,
180
191
  filterActive: !!(filters[column.key] && filters[column.key].length > 0),
181
192
  isDynamicButton: isDynamicButton,
182
193
  wrap: isLeaf && (!!column.wrap || !!headerWrapParam),
183
194
  };
184
195
  if (titleIsText) {
185
- cell.text =
186
- column.title === undefined ? column.key : String(column.title);
196
+ var baseTitle = column.title === undefined ? column.key : String(column.title);
197
+ // 复制整列:标题下方换行显示文字按钮(绘制端配合两行布局)
198
+ cell.text = column.showCopy ? baseTitle + '\n复制整列' : baseTitle;
187
199
  }
188
200
  else {
189
201
  cell.kind = 'overlay';
@@ -196,8 +208,8 @@ export function buildScene(params) {
196
208
  var dataCells = [];
197
209
  var visibleData = [];
198
210
  var firstRegularLeafIndex = -1;
199
- for (var _g = 0, layouts_1 = layouts; _g < layouts_1.length; _g++) {
200
- var layout = layouts_1[_g];
211
+ for (var _j = 0, layouts_1 = layouts; _j < layouts_1.length; _j++) {
212
+ var layout = layouts_1[_j];
201
213
  if (layout.column.key !== SPECIAL_KEYS.selection &&
202
214
  layout.column.key !== SPECIAL_KEYS.index) {
203
215
  firstRegularLeafIndex = layout.index;
@@ -216,8 +228,8 @@ export function buildScene(params) {
216
228
  to: dataSource.length,
217
229
  });
218
230
  }
219
- for (var _h = 0, rowSegments_1 = rowSegments; _h < rowSegments_1.length; _h++) {
220
- var segment = rowSegments_1[_h];
231
+ for (var _k = 0, rowSegments_1 = rowSegments; _k < rowSegments_1.length; _k++) {
232
+ var segment = rowSegments_1[_k];
221
233
  for (var rowIndex = segment.from; rowIndex < segment.to; rowIndex++) {
222
234
  var record = dataSource[rowIndex];
223
235
  if (!record)
@@ -314,10 +326,56 @@ export function buildScene(params) {
314
326
  else if (isSelection) {
315
327
  cell.checked = selectedKeys.has(key);
316
328
  cell.disabled = !!((_d = getCheckboxProps === null || getCheckboxProps === void 0 ? void 0 : getCheckboxProps(record)) === null || _d === void 0 ? void 0 : _d.disabled);
329
+ cell.radio = selectionType === 'radio';
317
330
  }
318
331
  else if (isIndex) {
319
332
  cell.text = String(rowIndex + 1);
320
333
  }
334
+ else if (column.renderToCanvas) {
335
+ try {
336
+ var atoms = column.renderToCanvas({ value: value, record: record, index: rowIndex }) || [];
337
+ var atomsLayout = layoutAtoms(atoms, layout.width - ATOM_CELL_PADDING * 2);
338
+ cell.kind = 'atoms';
339
+ cell.atoms = {
340
+ atoms: atoms,
341
+ layout: atomsLayout,
342
+ record: record,
343
+ index: rowIndex,
344
+ };
345
+ }
346
+ catch (e) {
347
+ cell.kind = 'empty';
348
+ }
349
+ }
350
+ else if (column.cell) {
351
+ var cellFn = getCanvasCell(column.cell.type);
352
+ if (cellFn) {
353
+ try {
354
+ var atoms = cellFn({
355
+ value: value,
356
+ record: record,
357
+ index: rowIndex,
358
+ column: column,
359
+ cell: column.cell,
360
+ }) || [];
361
+ var atomsLayout = layoutAtoms(atoms, layout.width - ATOM_CELL_PADDING * 2);
362
+ cell.kind = 'atoms';
363
+ cell.atoms = {
364
+ atoms: atoms,
365
+ layout: atomsLayout,
366
+ record: record,
367
+ index: rowIndex,
368
+ };
369
+ }
370
+ catch (e) {
371
+ cell.kind = 'empty';
372
+ }
373
+ }
374
+ else {
375
+ // cell.type 未注册:回退普通文本列
376
+ cell.text = formatCellValue(value, column);
377
+ }
378
+ }
321
379
  else if (column.render) {
322
380
  var rendered = resolveRendered(renderCache, column, value, record, rowIndex, key + '|' + column.key);
323
381
  if (typeof rendered === 'string' || typeof rendered === 'number') {
@@ -375,8 +433,8 @@ export function buildScene(params) {
375
433
  }
376
434
  dataCells.push(cell);
377
435
  };
378
- for (var _j = 0, layouts_2 = layouts; _j < layouts_2.length; _j++) {
379
- var layout = layouts_2[_j];
436
+ for (var _l = 0, layouts_2 = layouts; _l < layouts_2.length; _l++) {
437
+ var layout = layouts_2[_l];
380
438
  _loop_1(layout);
381
439
  }
382
440
  }
@@ -407,6 +465,8 @@ export function buildScene(params) {
407
465
  resizeActiveIndex: resizeActiveIndex,
408
466
  summaryStartIndex: summaryStartIndex,
409
467
  summaryRows: summaryRows,
468
+ hoverAtom: hoverAtom,
469
+ selectionType: selectionType,
410
470
  dataLength: dataSource.length,
411
471
  mergeMap: mergeMap,
412
472
  expandMetaByKey: expandMetaByKey,
@@ -7,5 +7,6 @@ export declare function useColumnWidths<T = any>(params: {
7
7
  }): {
8
8
  applyColumnWidth: (columns: IColumnType<T>[]) => IColumnType<T>[];
9
9
  setColumnWidth: (column: IColumnType<T>, width: number) => void;
10
+ manualWidths: Record<string, number>;
10
11
  manualKeys: Set<string>;
11
12
  };
@@ -46,5 +46,5 @@ export function useColumnWidths(params) {
46
46
  });
47
47
  onColumnResize === null || onColumnResize === void 0 ? void 0 : onColumnResize(column.key, width);
48
48
  }, [onColumnResize]);
49
- return { applyColumnWidth: applyColumnWidth, setColumnWidth: setColumnWidth, manualKeys: manualKeys };
49
+ return { applyColumnWidth: applyColumnWidth, setColumnWidth: setColumnWidth, manualWidths: manualWidths, manualKeys: manualKeys };
50
50
  }
@@ -1,6 +1,22 @@
1
1
  import { useCallback, useEffect } from 'react';
2
2
  import { formatCellValue } from '../utils/format';
3
3
  function extractText(column, record, index) {
4
+ if (column.renderToCanvas) {
5
+ try {
6
+ var atoms = column.renderToCanvas({
7
+ value: record[column.dataIndex || column.key],
8
+ record: record,
9
+ index: index,
10
+ }) || [];
11
+ return atoms
12
+ .map(function (a) { return a.text || ''; })
13
+ .filter(Boolean)
14
+ .join(' ');
15
+ }
16
+ catch (e) {
17
+ return '';
18
+ }
19
+ }
4
20
  if (!record)
5
21
  return '';
6
22
  var dataIndex = column.dataIndex || column.key;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { ICellSelection, IRowSelection, SortOrder } from '../interface';
2
+ import { ICellSelection, IColumnType, IRowSelection, SortOrder } from '../interface';
3
3
  import { Scene } from '../draw/scene';
4
4
  import { ScrollbarMetrics } from '../utils/layout';
5
5
  import { FlatRowMeta } from './useExpandable';
@@ -31,6 +31,21 @@ export declare function useInteractions<T = any>(params: {
31
31
  left: number;
32
32
  top: number;
33
33
  }) => void;
34
+ /** renderToCanvas 链接 hover(下划线重绘) */
35
+ setHoverAtom: (a: {
36
+ row: number;
37
+ col: number;
38
+ index: number;
39
+ } | null) => void;
40
+ hoverAtomRef: React.MutableRefObject<{
41
+ row: number;
42
+ col: number;
43
+ index: number;
44
+ } | null>;
45
+ /** 非受控模式的内部勾选 keys(rowSelection 未传 selectedRowKeys 时以它为准) */
46
+ internalKeysRef: React.MutableRefObject<React.Key[]>;
47
+ /** 点击表头“复制整列”图标回调 */
48
+ onCopyColumn?: (column: IColumnType<any>) => void;
34
49
  setHoverRow: (row: number | null) => void;
35
50
  setTooltip: (tip: {
36
51
  visible: boolean;