ztxkui 4.2.23-629 → 4.2.23-630

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.
@@ -147,7 +147,19 @@ export function drawScene(ctx, scene) {
147
147
  ctx.fillStyle = COLORS.white;
148
148
  ctx.fillRect(0, 0, width, height);
149
149
  applyFont(ctx);
150
- var fixedRightEdge = layouts.reduce(function (max, l) { return (l.fixed ? Math.max(max, l.fixedLeft + l.width) : max); }, 0);
150
+ // 左固定区右缘 / 右固定区左缘
151
+ var fixedLeftRightEdge = layouts.reduce(function (max, l) {
152
+ return l.fixed && l.fixedSide !== 'right'
153
+ ? Math.max(max, l.fixedLeft + l.width)
154
+ : max;
155
+ }, 0);
156
+ var fixedRightZoneLeft = Infinity;
157
+ for (var _i = 0, layouts_1 = layouts; _i < layouts_1.length; _i++) {
158
+ var l = layouts_1[_i];
159
+ if (l.fixed && l.fixedSide === 'right') {
160
+ fixedRightZoneLeft = Math.min(fixedRightZoneLeft, l.fixedLeft);
161
+ }
162
+ }
151
163
  // ---- 数据区 ----
152
164
  var dataBottom = metrics.needH ? height - SCROLLBAR_SIZE : height;
153
165
  var _loop_1 = function (cell) {
@@ -155,10 +167,13 @@ export function drawScene(ctx, scene) {
155
167
  if (!layout)
156
168
  return "continue";
157
169
  var isFixed = layout.fixed;
158
- // 非固定列若被固定列遮挡,clip 掉重叠部分;完全被遮挡则跳过
159
- var clipX = isFixed ? cell.x : Math.max(cell.x, fixedRightEdge);
160
- var clipRight = cell.x + cell.width;
161
- if (!isFixed && clipRight <= fixedRightEdge)
170
+ // 非固定列若被左/右固定列遮挡,clip 掉重叠部分;完全被遮挡则跳过
171
+ var clipX = isFixed ? cell.x : Math.max(cell.x, fixedLeftRightEdge);
172
+ var clipRightLimit = cell.x + cell.width;
173
+ if (!isFixed && fixedRightZoneLeft !== Infinity) {
174
+ clipRightLimit = Math.min(clipRightLimit, fixedRightZoneLeft);
175
+ }
176
+ if (!isFixed && clipRightLimit <= clipX)
162
177
  return "continue";
163
178
  // 垂直 clip:滚动区行限制在固定行之间的区域,防止上下滚动时穿透
164
179
  var inFixedTop = cell.row < scene.fixedTopRows;
@@ -180,7 +195,7 @@ export function drawScene(ctx, scene) {
180
195
  }
181
196
  ctx.save();
182
197
  ctx.beginPath();
183
- ctx.rect(clipX, clipYTop, clipRight - clipX, clipYBottom - clipYTop);
198
+ ctx.rect(clipX, clipYTop, clipRightLimit - clipX, clipYBottom - clipYTop);
184
199
  ctx.clip();
185
200
  // 行背景(合计行白底,对齐 Table 的 summary 样式)
186
201
  var isSummary = scene.summaryStartIndex !== null && cell.row >= scene.summaryStartIndex;
@@ -266,8 +281,8 @@ export function drawScene(ctx, scene) {
266
281
  }
267
282
  ctx.restore();
268
283
  };
269
- for (var _i = 0, _a = scene.dataCells; _i < _a.length; _i++) {
270
- var cell = _a[_i];
284
+ for (var _a = 0, _b = scene.dataCells; _a < _b.length; _a++) {
285
+ var cell = _b[_a];
271
286
  _loop_1(cell);
272
287
  }
273
288
  // ---- 框选高亮(数据区之上、表头之下)----
@@ -307,16 +322,20 @@ export function drawScene(ctx, scene) {
307
322
  var isFixedCell = !!((_a = layouts[cell.col]) === null || _a === void 0 ? void 0 : _a.fixed);
308
323
  if (isFixedCell !== onlyFixed)
309
324
  continue;
310
- // 非固定格被固定列遮挡部分裁掉
325
+ // 非固定格被左/右固定列遮挡部分裁掉
311
326
  var hdrClipX = cell.x;
327
+ var hdrClipRight = cell.x + cell.width;
312
328
  if (!isFixedCell) {
313
- hdrClipX = Math.max(cell.x, fixedRightEdge);
314
- if (cell.x + cell.width <= fixedRightEdge)
329
+ hdrClipX = Math.max(cell.x, fixedLeftRightEdge);
330
+ if (fixedRightZoneLeft !== Infinity) {
331
+ hdrClipRight = Math.min(hdrClipRight, fixedRightZoneLeft);
332
+ }
333
+ if (hdrClipRight <= hdrClipX)
315
334
  continue;
316
335
  }
317
336
  ctx.save();
318
337
  ctx.beginPath();
319
- ctx.rect(hdrClipX, cell.y, cell.x + cell.width - hdrClipX, cell.height);
338
+ ctx.rect(hdrClipX, cell.y, hdrClipRight - hdrClipX, cell.height);
320
339
  ctx.clip();
321
340
  if (cell.kind === 'checkbox') {
322
341
  // 勾选列表头:全选框
@@ -358,8 +377,8 @@ export function drawScene(ctx, scene) {
358
377
  drawHeaderPass(true);
359
378
  // ---- 列宽调整手柄 ----
360
379
  if (scene.resizeHoverIndex !== null || scene.resizeActiveIndex !== null) {
361
- for (var _b = 0, layouts_1 = layouts; _b < layouts_1.length; _b++) {
362
- var layout = layouts_1[_b];
380
+ for (var _c = 0, layouts_2 = layouts; _c < layouts_2.length; _c++) {
381
+ var layout = layouts_2[_c];
363
382
  if (layout.column.key === SPECIAL_KEYS.selection)
364
383
  continue;
365
384
  var isHover = scene.resizeHoverIndex === layout.index;
@@ -383,14 +402,24 @@ export function drawScene(ctx, scene) {
383
402
  }
384
403
  }
385
404
  // ---- 固定列阴影 ----
386
- if (fixedRightEdge > 0 && scrollLeft > 0) {
387
- var gradient = ctx.createLinearGradient(fixedRightEdge, 0, fixedRightEdge + 12, 0);
405
+ if (fixedLeftRightEdge > 0 && scrollLeft > 0) {
406
+ var gradient = ctx.createLinearGradient(fixedLeftRightEdge, 0, fixedLeftRightEdge + 12, 0);
407
+ gradient.addColorStop(0, COLORS.shadow);
408
+ gradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
409
+ ctx.fillStyle = gradient;
410
+ ctx.fillRect(fixedLeftRightEdge, 0, 12, height);
411
+ ctx.fillStyle = COLORS.fixedEdge;
412
+ ctx.fillRect(fixedLeftRightEdge - 1, 0, 1, height);
413
+ }
414
+ // 右固定区左缘阴影(横向滚动中)
415
+ if (fixedRightZoneLeft !== Infinity && scrollLeft > 0) {
416
+ var gradient = ctx.createLinearGradient(fixedRightZoneLeft, 0, fixedRightZoneLeft - 12, 0);
388
417
  gradient.addColorStop(0, COLORS.shadow);
389
418
  gradient.addColorStop(1, 'rgba(0, 0, 0, 0)');
390
419
  ctx.fillStyle = gradient;
391
- ctx.fillRect(fixedRightEdge, 0, 12, height);
420
+ ctx.fillRect(fixedRightZoneLeft - 12, 0, 12, height);
392
421
  ctx.fillStyle = COLORS.fixedEdge;
393
- ctx.fillRect(fixedRightEdge - 1, 0, 1, height);
422
+ ctx.fillRect(fixedRightZoneLeft, 0, 1, height);
394
423
  }
395
424
  // 滚动条由 DOM 层渲染(支持显隐过渡动画),canvas 不再绘制
396
425
  }
@@ -26,6 +26,11 @@ export declare function useInteractions<T = any>(params: {
26
26
  left: number;
27
27
  top: number;
28
28
  }) => void;
29
+ /** 拖拽滚动条用:rAF 合帧提交(高频 mousemove 下每帧最多一次 setState) */
30
+ commitScrollLazy?: (pos: {
31
+ left: number;
32
+ top: number;
33
+ }) => void;
29
34
  setHoverRow: (row: number | null) => void;
30
35
  setTooltip: (tip: {
31
36
  visible: boolean;
@@ -33,7 +33,7 @@ export function nextSortOrder(clickedUp, current) {
33
33
  * mousemove/mouseup 常驻注册一次(读 ref 判定),canvas 事件只做入口分发
34
34
  */
35
35
  export function useInteractions(params) {
36
- var canvasRef = params.canvasRef, sceneRef = params.sceneRef, metricsRef = params.metricsRef, dragRef = params.dragRef, commitScroll = params.commitScroll, setHoverRow = params.setHoverRow, setTooltip = params.setTooltip, setCellSelection = params.setCellSelection, cellSelectionRef = params.cellSelectionRef, onCellSelectionChangeRef = params.onCellSelectionChangeRef, setFilterPopover = params.setFilterPopover, setBadgePopover = params.setBadgePopover, expandRef = params.expandRef, setSort = params.setSort, sortRef = params.sortRef, rowSelectionRef = params.rowSelectionRef, getRowKeyRef = params.getRowKeyRef, dataSourceRef = params.dataSourceRef, setInternalSelectedKeys = params.setInternalSelectedKeys, resizingRef = params.resizingRef, onResizeMove = params.onResizeMove, onResizeEnd = params.onResizeEnd, callbacksRef = params.callbacksRef;
36
+ var canvasRef = params.canvasRef, sceneRef = params.sceneRef, metricsRef = params.metricsRef, dragRef = params.dragRef, commitScroll = params.commitScroll, commitScrollLazy = params.commitScrollLazy, setHoverRow = params.setHoverRow, setTooltip = params.setTooltip, setCellSelection = params.setCellSelection, cellSelectionRef = params.cellSelectionRef, onCellSelectionChangeRef = params.onCellSelectionChangeRef, setFilterPopover = params.setFilterPopover, setBadgePopover = params.setBadgePopover, expandRef = params.expandRef, setSort = params.setSort, sortRef = params.sortRef, rowSelectionRef = params.rowSelectionRef, getRowKeyRef = params.getRowKeyRef, dataSourceRef = params.dataSourceRef, setInternalSelectedKeys = params.setInternalSelectedKeys, resizingRef = params.resizingRef, onResizeMove = params.onResizeMove, onResizeEnd = params.onResizeEnd, callbacksRef = params.callbacksRef;
37
37
  // 本 hook 内部的拖拽模式(select / resize 独立于滚动条拖拽)
38
38
  var modeRef = useRef('none');
39
39
  var selectStartRef = useRef(null);
@@ -442,7 +442,8 @@ export function useInteractions(params) {
442
442
  var _f = dragRef.current, startPos = _f.startPos, startScroll = _f.startScroll;
443
443
  var scale = metrics.maxScrollTop /
444
444
  Math.max(1, metrics.dataAreaHeight - ((_b = (_a = metrics.thumbV) === null || _a === void 0 ? void 0 : _a.height) !== null && _b !== void 0 ? _b : 0));
445
- commitScroll({
445
+ var commit = commitScrollLazy || commitScroll;
446
+ commit({
446
447
  left: scene.scrollLeft,
447
448
  top: startScroll + (y - startPos) * scale,
448
449
  });
@@ -454,7 +455,8 @@ export function useInteractions(params) {
454
455
  (metrics.needV ? SCROLLBAR_SIZE : 0) -
455
456
  ((_d = (_c = metrics.thumbH) === null || _c === void 0 ? void 0 : _c.width) !== null && _d !== void 0 ? _d : 0);
456
457
  var scale = metrics.maxScrollLeft / Math.max(1, trackWidth);
457
- commitScroll({
458
+ var commit = commitScrollLazy || commitScroll;
459
+ commit({
458
460
  left: startScroll + (x - startPos) * scale,
459
461
  top: scene.scrollTop,
460
462
  });
@@ -21,6 +21,7 @@ export declare function useScrollState(params: {
21
21
  scroll: ScrollPosition;
22
22
  scrollRef: import("react").MutableRefObject<ScrollPosition>;
23
23
  commitScroll: (next: ScrollPosition) => void;
24
+ commitScrollLazy: (next: ScrollPosition) => void;
24
25
  scrollTo: (params: {
25
26
  x?: number;
26
27
  y?: number;
@@ -25,6 +25,9 @@ export function useScrollState(params) {
25
25
  // 连续 wheel 合帧:增量先累积,rAF 统一提交,每帧最多一次 setState
26
26
  var pendingWheelRef = useRef({ left: 0, top: 0, scheduled: false });
27
27
  var wheelRafRef = useRef(0);
28
+ // 滚动条拖拽合帧:同帧多次 mousemove 只提交最新位置(绝对定位,非增量)
29
+ var dragPendingRef = useRef(null);
30
+ var dragRafRef = useRef(0);
28
31
  /**
29
32
  * clamp 后提交滚动位置。
30
33
  * wheel 事件本身已按帧合成(~60Hz),React 事件批处理后每事件一次 render,
@@ -46,6 +49,20 @@ export function useScrollState(params) {
46
49
  return clamped;
47
50
  });
48
51
  }, [metricsRef]);
52
+ /** 拖拽滚动条用:rAF 合帧提交,每帧最多一次 setState */
53
+ var commitScrollLazy = useCallback(function (next) {
54
+ dragPendingRef.current = next;
55
+ if (dragRafRef.current)
56
+ return;
57
+ dragRafRef.current = requestAnimationFrame(function () {
58
+ dragRafRef.current = 0;
59
+ var pending = dragPendingRef.current;
60
+ if (pending) {
61
+ dragPendingRef.current = null;
62
+ commitScroll(pending);
63
+ }
64
+ });
65
+ }, [commitScroll]);
49
66
  // wheel 滚动(只绑定一次,读 ref 拿最新值)
50
67
  useEffect(function () {
51
68
  var container = containerRef.current;
@@ -118,5 +135,13 @@ export function useScrollState(params) {
118
135
  var resetScrollTop = useCallback(function () {
119
136
  setScroll(function (prev) { return (prev.top === 0 ? prev : __assign(__assign({}, prev), { top: 0 })); });
120
137
  }, []);
121
- return { scroll: scroll, scrollRef: scrollRef, commitScroll: commitScroll, scrollTo: scrollTo, resetScrollTop: resetScrollTop, dragRef: dragRef };
138
+ return {
139
+ scroll: scroll,
140
+ scrollRef: scrollRef,
141
+ commitScroll: commitScroll,
142
+ commitScrollLazy: commitScrollLazy,
143
+ scrollTo: scrollTo,
144
+ resetScrollTop: resetScrollTop,
145
+ dragRef: dragRef,
146
+ };
122
147
  }
@@ -24,7 +24,7 @@ import { HTML5Backend } from 'react-dnd-html5-backend';
24
24
  import { useContextMenu } from 'react-contexify';
25
25
  import TableDynamic from '../Table/table-dynamic';
26
26
  import { getStorage, setDynamicKey, getTableLayoutFullData, } from '../Table/hooks/useColumns';
27
- import { buildColumnLayouts, applyFilters, applySort, generateAutoFilters, getLeafColumns, flattenHeaders, buildSummaryRow, computeMergeMap, buildRowMetrics, SPECIAL_KEYS, } from './utils';
27
+ import { buildColumnLayouts, applyFilters, applySort, generateAutoFilters, getLeafColumns, flattenHeaders, buildSummaryRow, computeMergeMap, buildRowMetrics, computeScrollbarMetrics, SPECIAL_KEYS, } from './utils';
28
28
  import getSummaryData from '../Table/utils/getSummaryData';
29
29
  import { SUMMARY_KEY } from './utils/summary';
30
30
  import { buildScene } from './draw/scene';
@@ -336,8 +336,35 @@ function CanvasTableInner(props, ref) {
336
336
  if (key)
337
337
  excludeKeys.add(key);
338
338
  }
339
- return buildColumnLayouts(cols, containerWidth, excludeKeys);
340
- }, [leafColumns, containerWidth, manualKeys, resizing]);
339
+ // 纵向滚动条占位:右固定列贴滚动条内侧
340
+ var totalHeightApprox = totalHeaderHeight + displayData.length * rowHeight;
341
+ var metrics0 = computeScrollbarMetrics({
342
+ containerWidth: containerWidth,
343
+ containerHeight: containerHeight,
344
+ totalWidth: totalColWidthPure,
345
+ totalHeight: totalHeightApprox,
346
+ headerHeight: totalHeaderHeight,
347
+ scrollTop: 0,
348
+ scrollLeft: 0,
349
+ rowHeight: rowHeight,
350
+ dataLength: displayData.length,
351
+ fixedTopRows: fixedTopRows,
352
+ fixedBottomRows: fixedBottomRows,
353
+ });
354
+ return buildColumnLayouts(cols, containerWidth, excludeKeys, metrics0.needV ? SCROLLBAR_SIZE : 0);
355
+ }, [
356
+ leafColumns,
357
+ containerWidth,
358
+ containerHeight,
359
+ manualKeys,
360
+ resizing,
361
+ totalColWidthPure,
362
+ totalHeaderHeight,
363
+ displayData,
364
+ rowHeight,
365
+ fixedTopRows,
366
+ fixedBottomRows,
367
+ ]);
341
368
  // 行高表:wrap 列按内容行数撑开行高(行高自适应)。
342
369
  // 必须用实际渲染宽度(自适应平分后)计算换行行数,否则行高虚高
343
370
  var rowMetrics = useMemo(function () {
@@ -397,7 +424,7 @@ function CanvasTableInner(props, ref) {
397
424
  (_a = onScrollRef.current) === null || _a === void 0 ? void 0 : _a.call(onScrollRef, left, top);
398
425
  markScrollbarVisible();
399
426
  },
400
- }), scroll = _13.scroll, scrollRef = _13.scrollRef, commitScroll = _13.commitScroll, scrollTo = _13.scrollTo, resetScrollTop = _13.resetScrollTop, dragRef = _13.dragRef;
427
+ }), scroll = _13.scroll, scrollRef = _13.scrollRef, commitScroll = _13.commitScroll, commitScrollLazy = _13.commitScrollLazy, scrollTo = _13.scrollTo, resetScrollTop = _13.resetScrollTop, dragRef = _13.dragRef;
401
428
  // 拖拽滚动条过程中强制保持显示(拖拽持续触发 onScroll → 渲染时读到最新 dragRef)
402
429
  var scrollbarVisible = scrollbarHover ||
403
430
  scrollbarByScroll ||
@@ -550,6 +577,7 @@ function CanvasTableInner(props, ref) {
550
577
  metricsRef: metricsRef,
551
578
  dragRef: dragRef,
552
579
  commitScroll: commitScroll,
580
+ commitScrollLazy: commitScrollLazy,
553
581
  setHoverRow: setHoverRow,
554
582
  setTooltip: setTooltip,
555
583
  setCellSelection: setCellSelection,
@@ -648,50 +676,62 @@ function CanvasTableInner(props, ref) {
648
676
  // ---- overlay 单元格(裁剪滚动条区域 + 数据区边界,防止 render 内容盖住表头/固定行/滚动条)----
649
677
  // ---- 框选小计:框选结束后在鼠标处显示“小计: X 已选:N项”(数值千分符) ----
650
678
  var subtotalTipRef = useRef({ x: 0, y: 0 });
679
+ var subtotalLastCalcRef = useRef(0);
651
680
  useEffect(function () {
652
681
  var sel = cellSelection;
653
682
  if (!sel) {
654
683
  closeSubtotalTip();
655
684
  return;
656
685
  }
657
- var minRow = Math.min(sel.startRow, sel.endRow);
658
- var maxRow = Math.max(sel.startRow, sel.endRow);
659
- var minCol = Math.min(sel.startCol, sel.endCol);
660
- var maxCol = Math.max(sel.startCol, sel.endCol);
661
- var result = calcSelectionSubtotal({
662
- minRow: minRow,
663
- maxRow: maxRow,
664
- minCol: minCol,
665
- maxCol: maxCol,
666
- dataSource: displayData,
667
- layouts: layouts,
668
- getCellText: function (rowIndex, column) {
669
- var d = displayData[rowIndex];
670
- if (!d)
671
- return '';
672
- var column2 = column;
673
- var dataIndex = column2.dataIndex || column2.key;
674
- var value = d[dataIndex];
675
- if (column2.render) {
676
- var rendered = column2.render({
677
- value: value,
678
- record: d,
679
- index: rowIndex,
680
- });
681
- if (typeof rendered === 'string' || typeof rendered === 'number') {
682
- return String(rendered);
686
+ var run = function () {
687
+ subtotalLastCalcRef.current = Date.now();
688
+ var minRow = Math.min(sel.startRow, sel.endRow);
689
+ var maxRow = Math.max(sel.startRow, sel.endRow);
690
+ var minCol = Math.min(sel.startCol, sel.endCol);
691
+ var maxCol = Math.max(sel.startCol, sel.endCol);
692
+ var result = calcSelectionSubtotal({
693
+ minRow: minRow,
694
+ maxRow: maxRow,
695
+ minCol: minCol,
696
+ maxCol: maxCol,
697
+ dataSource: displayData,
698
+ layouts: layouts,
699
+ getCellText: function (rowIndex, column) {
700
+ var d = displayData[rowIndex];
701
+ if (!d)
702
+ return '';
703
+ var column2 = column;
704
+ var dataIndex = column2.dataIndex || column2.key;
705
+ var value = d[dataIndex];
706
+ if (column2.render) {
707
+ var rendered = column2.render({
708
+ value: value,
709
+ record: d,
710
+ index: rowIndex,
711
+ });
712
+ if (typeof rendered === 'string' || typeof rendered === 'number') {
713
+ return String(rendered);
714
+ }
683
715
  }
684
- }
685
- return formatCellValue(value, column2, true);
686
- },
687
- });
688
- var pos = subtotalTipRef.current;
689
- setSubtotalTipState({
690
- visible: true,
691
- content: '小计: ' + result.sumText + ' 已选:' + result.count + '项',
692
- x: pos.x + 12,
693
- y: pos.y + 14,
694
- });
716
+ return formatCellValue(value, column2, true);
717
+ },
718
+ });
719
+ var pos = subtotalTipRef.current;
720
+ setSubtotalTipState({
721
+ visible: true,
722
+ content: '小计: ' + result.sumText + ' 已选:' + result.count + '项',
723
+ x: pos.x + 12,
724
+ y: pos.y + 14,
725
+ });
726
+ };
727
+ // 拖拽乱拽时选区高频变化:100ms 节流(render 列全量重算较贵),停止后补算最终值
728
+ var elapsed = Date.now() - subtotalLastCalcRef.current;
729
+ if (elapsed >= 100) {
730
+ run();
731
+ return;
732
+ }
733
+ var timer = setTimeout(run, 100 - elapsed);
734
+ return function () { return clearTimeout(timer); };
695
735
  // eslint-disable-next-line react-hooks/exhaustive-deps
696
736
  }, [cellSelection]);
697
737
  var overlayCells = useMemo(function () {
@@ -705,13 +745,26 @@ function CanvasTableInner(props, ref) {
705
745
  var fixedBottom = scene.fixedBottomRows;
706
746
  var topAreaEnd = scene.headerHeight + fixedTop * scene.rowHeight;
707
747
  var bottomAreaTop = bottomLimit - fixedBottom * scene.rowHeight;
708
- var fixedRightEdge = scene.layouts.reduce(function (max, l) { return (l.fixed ? Math.max(max, l.fixedLeft + l.width) : max); }, 0);
748
+ var fixedRightEdge = scene.layouts.reduce(function (max, l) {
749
+ return l.fixed && l.fixedSide !== 'right'
750
+ ? Math.max(max, l.fixedLeft + l.width)
751
+ : max;
752
+ }, 0);
753
+ // 右固定区左缘(非固定 overlay 滚到其下方时裁掉右侧)
754
+ var fixedRightZoneLeft = scene.layouts.reduce(function (min, l) {
755
+ return l.fixed && l.fixedSide === 'right' ? Math.min(min, l.fixedLeft) : min;
756
+ }, Infinity);
709
757
  return cells
710
758
  .map(function (c) {
711
- var _a;
712
759
  // 用 clip-path 裁剪(内容位置不变,超出边界部分裁掉,与 canvas 绘制行为一致)
713
- var isFixedCell = !!((_a = scene.layouts[c.col]) === null || _a === void 0 ? void 0 : _a.fixed);
760
+ var layout = scene.layouts[c.col];
761
+ var isFixedCell = !!(layout === null || layout === void 0 ? void 0 : layout.fixed);
762
+ var isRightFixedCell = (layout === null || layout === void 0 ? void 0 : layout.fixedSide) === 'right';
714
763
  var limitLeft = isFixedCell ? 0 : fixedRightEdge;
764
+ // 非固定列被右固定区从右侧遮挡;固定列不会被遮挡
765
+ var limitRight = !isFixedCell && fixedRightZoneLeft !== Infinity
766
+ ? fixedRightZoneLeft
767
+ : Infinity;
715
768
  var limitTop = c.row < 0 ||
716
769
  inFixedRows(c.row, fixedTop, fixedBottom, scene.dataLength)
717
770
  ? 0
@@ -722,7 +775,7 @@ function CanvasTableInner(props, ref) {
722
775
  : bottomLimit;
723
776
  var clipTop = Math.max(0, limitTop - c.y);
724
777
  var clipLeft = Math.max(0, limitLeft - c.x);
725
- var clipRight = Math.max(0, c.x + c.width - rightLimit);
778
+ var clipRight = Math.max(0, c.x + c.width - Math.min(rightLimit, limitRight));
726
779
  var clipBottom = Math.max(0, c.y + c.height - limitBottom);
727
780
  var fullyClipped = clipTop >= c.height ||
728
781
  clipLeft >= c.width ||
@@ -20,8 +20,8 @@ export interface IColumnType<RecordType = any> {
20
20
  align?: 'left' | 'center' | 'right';
21
21
  /** 表头对齐方式,默认取全局 headerAlign 或 center */
22
22
  headerAlign?: 'left' | 'center' | 'right';
23
- /** 左固定列(仅叶子列生效) */
24
- fixed?: boolean;
23
+ /** 固定列:true/'left' 左固定,'right' 右固定(横向滚动时钉在视口右缘,对齐 antd) */
24
+ fixed?: boolean | 'left' | 'right';
25
25
  /** 是否可排序;传函数为自定义排序 */
26
26
  sorter?: boolean | ((a: RecordType, b: RecordType) => number);
27
27
  /** 默认排序 */
@@ -7,7 +7,9 @@ export interface ColumnLayout<T = any> {
7
7
  x: number;
8
8
  width: number;
9
9
  fixed: boolean;
10
- /** fixed 列的视口 x 坐标 */
10
+ /** 固定侧(fixed 为 true 时必有) */
11
+ fixedSide?: 'left' | 'right';
12
+ /** 固定列的视口 x(左右通用;右列为视口右缘反算) */
11
13
  fixedLeft?: number;
12
14
  }
13
15
  export interface ScrollbarMetrics {
@@ -32,9 +34,13 @@ export declare const SPECIAL_KEYS: {
32
34
  };
33
35
  /**
34
36
  * 构建列布局。总宽小于容器时把剩余宽度平分给普通列
35
- * (手动调整过的列、序号列、勾选列不参与平分)
37
+ * (手动调整过的列、序号列、勾选列不参与平分)。
38
+ * fixed: true/'left' 左固定(从左缘堆叠);'right' 右固定(从视口右缘堆叠,
39
+ * 声明靠后的更靠右,对齐 antd)
36
40
  */
37
- export declare function buildColumnLayouts<T = any>(columns: IColumnType<T>[], containerWidth: number, manuallyResizedKeys?: Set<string>): ColumnLayout<T>[];
41
+ export declare function buildColumnLayouts<T = any>(columns: IColumnType<T>[], containerWidth: number, manuallyResizedKeys?: Set<string>,
42
+ /** 视口右缘 inset(纵向滚动条宽度),右固定列贴 inset 内侧 */
43
+ rightInset?: number): ColumnLayout<T>[];
38
44
  export declare function totalLayoutWidth<T = any>(layouts: ColumnLayout<T>[]): number;
39
45
  /**
40
46
  * 滚动条几何。两轮判定:先按原始容器判断,再考虑滚动条互相挤占。
@@ -5,9 +5,14 @@ export var SPECIAL_KEYS = {
5
5
  };
6
6
  /**
7
7
  * 构建列布局。总宽小于容器时把剩余宽度平分给普通列
8
- * (手动调整过的列、序号列、勾选列不参与平分)
8
+ * (手动调整过的列、序号列、勾选列不参与平分)。
9
+ * fixed: true/'left' 左固定(从左缘堆叠);'right' 右固定(从视口右缘堆叠,
10
+ * 声明靠后的更靠右,对齐 antd)
9
11
  */
10
- export function buildColumnLayouts(columns, containerWidth, manuallyResizedKeys) {
12
+ export function buildColumnLayouts(columns, containerWidth, manuallyResizedKeys,
13
+ /** 视口右缘 inset(纵向滚动条宽度),右固定列贴 inset 内侧 */
14
+ rightInset) {
15
+ if (rightInset === void 0) { rightInset = 0; }
11
16
  var visible = columns.filter(function (c) { return !c.hidden; });
12
17
  var widths = visible.map(function (c) { var _a; return (_a = c.width) !== null && _a !== void 0 ? _a : DEFAULT_COLUMN_WIDTH; });
13
18
  var total = widths.reduce(function (s, w) { return s + w; }, 0);
@@ -28,21 +33,40 @@ export function buildColumnLayouts(columns, containerWidth, manuallyResizedKeys)
28
33
  total = containerWidth;
29
34
  }
30
35
  }
36
+ var sideOf = function (c) {
37
+ return c.fixed === 'right' ? 'right' : c.fixed ? 'left' : undefined;
38
+ };
39
+ // 右固定列堆叠总宽 → 第一个(声明最靠前的)右固定列的视口 x
40
+ var rightStack = 0;
41
+ for (var i = visible.length - 1; i >= 0; i--) {
42
+ if (sideOf(visible[i]) === 'right')
43
+ rightStack += widths[i];
44
+ }
45
+ var rightBase = containerWidth - rightInset - rightStack;
31
46
  var layouts = [];
32
47
  var cursorX = 0;
33
48
  var fixedLeftX = 0;
34
49
  visible.forEach(function (column, index) {
35
- var fixed = !!column.fixed;
50
+ var side = sideOf(column);
51
+ var fixed = !!side;
52
+ var fixedLeft;
53
+ if (side === 'left') {
54
+ fixedLeft = fixedLeftX;
55
+ fixedLeftX += widths[index];
56
+ }
57
+ else if (side === 'right') {
58
+ fixedLeft = rightBase;
59
+ rightBase += widths[index];
60
+ }
36
61
  layouts.push({
37
62
  column: column,
38
63
  index: index,
39
64
  x: cursorX,
40
65
  width: widths[index],
41
66
  fixed: fixed,
42
- fixedLeft: fixed ? fixedLeftX : undefined,
67
+ fixedSide: side,
68
+ fixedLeft: fixedLeft,
43
69
  });
44
- if (fixed)
45
- fixedLeftX += widths[index];
46
70
  cursorX += widths[index];
47
71
  });
48
72
  return layouts;
@@ -29,7 +29,7 @@ export function main(callback) {
29
29
  i18next
30
30
  .init({
31
31
  lng: languageType,
32
- debug: true,
32
+ debug: false,
33
33
  resources: {
34
34
  en_US: {
35
35
  translation: enJson,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ztxkui",
3
- "version": "4.2.23-629",
3
+ "version": "4.2.23-630",
4
4
  "private": false,
5
5
  "description": "React components library",
6
6
  "author": "zt-front-end",