@sia.soul/sia-react-ui 0.1.153 → 0.1.154
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/core.css +13 -4
- package/dist/game.css +13 -4
- package/dist/index.cjs +34 -10
- package/dist/index.css +13 -4
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +34 -10
- package/package.json +1 -1
package/dist/core.css
CHANGED
|
@@ -4214,26 +4214,35 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
4214
4214
|
cursor: pointer;
|
|
4215
4215
|
}
|
|
4216
4216
|
.sia-table__sortable-header {
|
|
4217
|
+
position: relative;
|
|
4217
4218
|
display: flex;
|
|
4218
4219
|
align-items: center;
|
|
4219
|
-
justify-content: space-between;
|
|
4220
4220
|
min-width: 0;
|
|
4221
|
-
gap: 6px;
|
|
4222
4221
|
}
|
|
4223
4222
|
.sia-table__sort-button {
|
|
4223
|
+
position: absolute;
|
|
4224
|
+
z-index: 1;
|
|
4225
|
+
right: 0;
|
|
4226
|
+
top: 50%;
|
|
4227
|
+
transform: translateY(-50%);
|
|
4224
4228
|
display: grid;
|
|
4225
4229
|
align-content: center;
|
|
4226
4230
|
justify-items: center;
|
|
4227
|
-
flex: 0 0 26px;
|
|
4228
4231
|
width: 26px;
|
|
4229
4232
|
height: 28px;
|
|
4230
4233
|
padding: 0;
|
|
4234
|
+
opacity: 0;
|
|
4231
4235
|
color: var(--sia-color-text-secondary);
|
|
4232
4236
|
cursor: pointer;
|
|
4233
|
-
background:
|
|
4237
|
+
background: var(--sia-color-control-hover);
|
|
4234
4238
|
border: 0;
|
|
4235
4239
|
border-radius: var(--sia-radius);
|
|
4236
4240
|
}
|
|
4241
|
+
.sia-table__header-cell:hover .sia-table__sort-button,
|
|
4242
|
+
.sia-table__sortable-header:focus-within .sia-table__sort-button,
|
|
4243
|
+
.sia-table__sort-button:not([data-sort-order=none]) {
|
|
4244
|
+
opacity: 1;
|
|
4245
|
+
}
|
|
4237
4246
|
.sia-table__sort-button[data-sort-order=none] .sia-icon {
|
|
4238
4247
|
margin-block: -2px;
|
|
4239
4248
|
}
|
package/dist/game.css
CHANGED
|
@@ -4265,26 +4265,35 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
4265
4265
|
cursor: pointer;
|
|
4266
4266
|
}
|
|
4267
4267
|
.sia-table__sortable-header {
|
|
4268
|
+
position: relative;
|
|
4268
4269
|
display: flex;
|
|
4269
4270
|
align-items: center;
|
|
4270
|
-
justify-content: space-between;
|
|
4271
4271
|
min-width: 0;
|
|
4272
|
-
gap: 6px;
|
|
4273
4272
|
}
|
|
4274
4273
|
.sia-table__sort-button {
|
|
4274
|
+
position: absolute;
|
|
4275
|
+
z-index: 1;
|
|
4276
|
+
right: 0;
|
|
4277
|
+
top: 50%;
|
|
4278
|
+
transform: translateY(-50%);
|
|
4275
4279
|
display: grid;
|
|
4276
4280
|
align-content: center;
|
|
4277
4281
|
justify-items: center;
|
|
4278
|
-
flex: 0 0 26px;
|
|
4279
4282
|
width: 26px;
|
|
4280
4283
|
height: 28px;
|
|
4281
4284
|
padding: 0;
|
|
4285
|
+
opacity: 0;
|
|
4282
4286
|
color: var(--sia-color-text-secondary);
|
|
4283
4287
|
cursor: pointer;
|
|
4284
|
-
background:
|
|
4288
|
+
background: var(--sia-color-control-hover);
|
|
4285
4289
|
border: 0;
|
|
4286
4290
|
border-radius: var(--sia-radius);
|
|
4287
4291
|
}
|
|
4292
|
+
.sia-table__header-cell:hover .sia-table__sort-button,
|
|
4293
|
+
.sia-table__sortable-header:focus-within .sia-table__sort-button,
|
|
4294
|
+
.sia-table__sort-button:not([data-sort-order=none]) {
|
|
4295
|
+
opacity: 1;
|
|
4296
|
+
}
|
|
4288
4297
|
.sia-table__sort-button[data-sort-order=none] .sia-icon {
|
|
4289
4298
|
margin-block: -2px;
|
|
4290
4299
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -15411,8 +15411,9 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
15411
15411
|
canvas.style.height = `${height}px`;
|
|
15412
15412
|
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
|
|
15413
15413
|
ctx.clearRect(0, 0, width, height);
|
|
15414
|
-
const style = getComputedStyle(scroller);
|
|
15415
|
-
const
|
|
15414
|
+
const style = getComputedStyle(scroller.querySelector("td[data-column-key]") ?? scroller);
|
|
15415
|
+
const padding = Number.parseFloat(style.paddingLeft) || 12;
|
|
15416
|
+
const foreground = getComputedStyle(scroller).color;
|
|
15416
15417
|
const readyCells = /* @__PURE__ */ new Map();
|
|
15417
15418
|
scroller.querySelectorAll("tr[data-canvas-row-index]").forEach((element) => {
|
|
15418
15419
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -15447,10 +15448,11 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
15447
15448
|
for (let index = first; index < last; index++) {
|
|
15448
15449
|
const row = rows[index];
|
|
15449
15450
|
const y = headerHeight + index * rowHeight - scroller.scrollTop + rowHeight / 2;
|
|
15451
|
+
if (readyCells.get(index)?.has(column.key)) continue;
|
|
15450
15452
|
if (!column.canvasRender && column.render) {
|
|
15451
15453
|
if (!readyCells.get(index)?.has(column.key)) {
|
|
15452
|
-
const skeletonWidth = Math.max(0, Math.min(cellWidth -
|
|
15453
|
-
const skeletonX = column.align === "right" ? x + cellWidth - skeletonWidth -
|
|
15454
|
+
const skeletonWidth = Math.max(0, Math.min(cellWidth - padding * 2, 120));
|
|
15455
|
+
const skeletonX = column.align === "right" ? x + cellWidth - skeletonWidth - padding : column.align === "center" ? x + (cellWidth - skeletonWidth) / 2 : x + padding;
|
|
15454
15456
|
ctx.save();
|
|
15455
15457
|
ctx.fillStyle = foreground;
|
|
15456
15458
|
ctx.globalAlpha = 0.12;
|
|
@@ -15464,7 +15466,7 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
15464
15466
|
const value = getTableValue(row.record, column.dataIndex, column.code ?? column.key);
|
|
15465
15467
|
const content2 = column.canvasRender ? column.canvasRender(value, row.record, row.sourceIndex, { row, rowIndex: index, column }) : { text: value == null ? "" : String(value) };
|
|
15466
15468
|
if (!content2?.text) continue;
|
|
15467
|
-
const available = Math.max(0, cellWidth - (content2.background ?
|
|
15469
|
+
const available = Math.max(0, cellWidth - padding * 2 - (content2.background ? 16 : 0));
|
|
15468
15470
|
let text = content2.text;
|
|
15469
15471
|
if (ctx.measureText(text).width > available) {
|
|
15470
15472
|
let lo = 0, hi = text.length;
|
|
@@ -15477,7 +15479,7 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
15477
15479
|
}
|
|
15478
15480
|
const textWidth = ctx.measureText(text).width;
|
|
15479
15481
|
const total = textWidth + (content2.background ? 16 : 0);
|
|
15480
|
-
const tx = column.align === "right" ? x + cellWidth - total -
|
|
15482
|
+
const tx = column.align === "right" ? x + cellWidth - total - padding : column.align === "center" ? x + (cellWidth - total) / 2 : x + padding;
|
|
15481
15483
|
if (content2.background) {
|
|
15482
15484
|
ctx.fillStyle = content2.background;
|
|
15483
15485
|
ctx.beginPath();
|
|
@@ -15498,6 +15500,19 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
15498
15500
|
draw();
|
|
15499
15501
|
};
|
|
15500
15502
|
scroller.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
15503
|
+
const onWheel = (event) => {
|
|
15504
|
+
if (event.ctrlKey || !event.cancelable) return;
|
|
15505
|
+
const dx = event.deltaX || (event.shiftKey ? event.deltaY : 0);
|
|
15506
|
+
if (!dx) return;
|
|
15507
|
+
const scale = event.deltaMode === 1 ? rowHeight : event.deltaMode === 2 ? scroller.clientWidth : 1;
|
|
15508
|
+
const next = Math.max(0, Math.min(scroller.scrollWidth - scroller.clientWidth, scroller.scrollLeft + dx * scale));
|
|
15509
|
+
if (next === scroller.scrollLeft) return;
|
|
15510
|
+
event.preventDefault();
|
|
15511
|
+
scroller.scrollLeft = next;
|
|
15512
|
+
if (event.deltaX && event.deltaY) scroller.scrollTop += event.deltaY * (event.deltaMode === 2 ? scroller.clientHeight : scale);
|
|
15513
|
+
onScroll();
|
|
15514
|
+
};
|
|
15515
|
+
scroller.addEventListener("wheel", onWheel, { passive: false });
|
|
15501
15516
|
const resize = new ResizeObserver(schedule);
|
|
15502
15517
|
resize.observe(scroller);
|
|
15503
15518
|
const content = new MutationObserver(schedule);
|
|
@@ -15512,6 +15527,7 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
15512
15527
|
content.disconnect();
|
|
15513
15528
|
theme.disconnect();
|
|
15514
15529
|
scroller.removeEventListener("scroll", onScroll, true);
|
|
15530
|
+
scroller.removeEventListener("wheel", onWheel);
|
|
15515
15531
|
window.removeEventListener("resize", schedule);
|
|
15516
15532
|
};
|
|
15517
15533
|
}, [viewport, rows, columns, widths, rowHeight, headerHeight]);
|
|
@@ -15673,6 +15689,7 @@ function playCellFocusGlow(cell, isVisible, onFinish, options) {
|
|
|
15673
15689
|
|
|
15674
15690
|
// src/components/Table/Table.tsx
|
|
15675
15691
|
var import_react67 = require("react");
|
|
15692
|
+
var import_react_dom7 = require("react-dom");
|
|
15676
15693
|
|
|
15677
15694
|
// src/components/Table/plugins.tsx
|
|
15678
15695
|
var import_react66 = require("react");
|
|
@@ -18341,6 +18358,7 @@ var TableBodyRow = (0, import_react67.memo)(function TableBodyRow2({
|
|
|
18341
18358
|
onCellPointerDown,
|
|
18342
18359
|
onCellPointerMove
|
|
18343
18360
|
}) {
|
|
18361
|
+
const [textColumn, setTextColumn] = (0, import_react67.useState)();
|
|
18344
18362
|
const resizeColumnKey = resize ? columns.find((column) => !getCellProps(column).hidden)?.key : void 0;
|
|
18345
18363
|
return /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
18346
18364
|
"tr",
|
|
@@ -18374,21 +18392,27 @@ var TableBodyRow = (0, import_react67.memo)(function TableBodyRow2({
|
|
|
18374
18392
|
{
|
|
18375
18393
|
"data-column-key": column.key,
|
|
18376
18394
|
"aria-invalid": invalid || void 0,
|
|
18377
|
-
"data-canvas-dom-ready": canvas && (pluginCellProps.content !== void 0 || !column.canvasRender && column.render) ? "true" : void 0,
|
|
18395
|
+
"data-canvas-dom-ready": canvas && (pluginCellProps.content !== void 0 || !column.canvasRender && (column.render || textColumn === column.key)) ? "true" : void 0,
|
|
18378
18396
|
"aria-label": canvas ? column.canvasRender?.(value, row.record, row.sourceIndex, { row, rowIndex, column })?.text ?? (value == null ? "" : String(value)) : void 0,
|
|
18379
18397
|
rowSpan: pluginCellProps.rowSpan,
|
|
18380
18398
|
colSpan: pluginCellProps.colSpan,
|
|
18381
18399
|
className: `sia-table__cell sia-table__cell--${column.align ?? "left"}${fixed ? ` sia-table__cell--fixed sia-table__cell--fixed-${fixed}` : ""}${fixedEdgeClass}${autoWidthClass}${invalid ? " sia-table__cell--invalid" : ""}${column.ellipsis !== false ? " sia-table__cell--ellipsis" : ""} ${cellClass} ${pluginCellProps.className ?? ""}`.trim(),
|
|
18382
18400
|
style: { ...fixedStyle, ...pluginCellProps.style },
|
|
18383
|
-
onMouseEnter: () =>
|
|
18401
|
+
onMouseEnter: () => {
|
|
18402
|
+
if (canvas && !column.canvasRender && !column.render) setTextColumn(column.key);
|
|
18403
|
+
onCellMouseEnter(column);
|
|
18404
|
+
},
|
|
18384
18405
|
onMouseLeave: () => onCellMouseLeave(column),
|
|
18385
18406
|
onClick: (event) => onCellClick(column, event),
|
|
18386
18407
|
onDoubleClick: (event) => onCellDoubleClick(column, event),
|
|
18387
18408
|
onContextMenu: (event) => onCellContextMenu(column, event),
|
|
18388
|
-
onPointerDown: (event) =>
|
|
18409
|
+
onPointerDown: (event) => {
|
|
18410
|
+
if (canvas && !column.canvasRender && !column.render && textColumn !== column.key) (0, import_react_dom7.flushSync)(() => setTextColumn(column.key));
|
|
18411
|
+
onCellPointerDown(column, event);
|
|
18412
|
+
},
|
|
18389
18413
|
onPointerMove: (event) => onCellPointerMove(column, event),
|
|
18390
18414
|
children: [
|
|
18391
|
-
!canvas || visibleColumns.has(column.key) && (pluginCellProps.content !== void 0 || !column.canvasRender && column.render) ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
18415
|
+
!canvas || visibleColumns.has(column.key) && (pluginCellProps.content !== void 0 || !column.canvasRender && (column.render || textColumn === column.key)) ? /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
|
|
18392
18416
|
TableCellContent,
|
|
18393
18417
|
{
|
|
18394
18418
|
ellipsis: column.ellipsis !== false,
|
package/dist/index.css
CHANGED
|
@@ -4214,26 +4214,35 @@ fieldset:disabled .sia-input-number__floating-placeholder {
|
|
|
4214
4214
|
cursor: pointer;
|
|
4215
4215
|
}
|
|
4216
4216
|
.sia-table__sortable-header {
|
|
4217
|
+
position: relative;
|
|
4217
4218
|
display: flex;
|
|
4218
4219
|
align-items: center;
|
|
4219
|
-
justify-content: space-between;
|
|
4220
4220
|
min-width: 0;
|
|
4221
|
-
gap: 6px;
|
|
4222
4221
|
}
|
|
4223
4222
|
.sia-table__sort-button {
|
|
4223
|
+
position: absolute;
|
|
4224
|
+
z-index: 1;
|
|
4225
|
+
right: 0;
|
|
4226
|
+
top: 50%;
|
|
4227
|
+
transform: translateY(-50%);
|
|
4224
4228
|
display: grid;
|
|
4225
4229
|
align-content: center;
|
|
4226
4230
|
justify-items: center;
|
|
4227
|
-
flex: 0 0 26px;
|
|
4228
4231
|
width: 26px;
|
|
4229
4232
|
height: 28px;
|
|
4230
4233
|
padding: 0;
|
|
4234
|
+
opacity: 0;
|
|
4231
4235
|
color: var(--sia-color-text-secondary);
|
|
4232
4236
|
cursor: pointer;
|
|
4233
|
-
background:
|
|
4237
|
+
background: var(--sia-color-control-hover);
|
|
4234
4238
|
border: 0;
|
|
4235
4239
|
border-radius: var(--sia-radius);
|
|
4236
4240
|
}
|
|
4241
|
+
.sia-table__header-cell:hover .sia-table__sort-button,
|
|
4242
|
+
.sia-table__sortable-header:focus-within .sia-table__sort-button,
|
|
4243
|
+
.sia-table__sort-button:not([data-sort-order=none]) {
|
|
4244
|
+
opacity: 1;
|
|
4245
|
+
}
|
|
4237
4246
|
.sia-table__sort-button[data-sort-order=none] .sia-icon {
|
|
4238
4247
|
margin-block: -2px;
|
|
4239
4248
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -2198,7 +2198,7 @@ interface TableColumn<T = Record<string, unknown>> {
|
|
|
2198
2198
|
ellipsis?: boolean;
|
|
2199
2199
|
/** 数据单元格是否使用 Sia Tooltip 显示完整文本;默认 false,不生成浏览器原生 title。列头仅在文字实际省略时提示完整标题,不受此属性影响。 */
|
|
2200
2200
|
showTitle?: boolean;
|
|
2201
|
-
/**
|
|
2201
|
+
/** 是否允许该列排序;配合排序插件显示浮动按钮,不挤占标题宽度。未排序时在悬停或键盘聚焦后显示,依次切换升序、降序、未排序;当前排序方向始终以高亮单箭头显示。 */
|
|
2202
2202
|
sortable?: boolean;
|
|
2203
2203
|
/** 是否允许该列筛选。 */
|
|
2204
2204
|
filterable?: boolean;
|
|
@@ -2429,7 +2429,7 @@ interface TableProps<T extends Record<string, unknown> = Record<string, unknown>
|
|
|
2429
2429
|
striped?: boolean;
|
|
2430
2430
|
/** 是否启用窗口化渲染;未指定时按 virtualThreshold 判断。筛选、分页及树展开后的实际展示行数超过 100 时强制启用,优先于 false 和插件的 disableVirtual。 */
|
|
2431
2431
|
virtual?: boolean;
|
|
2432
|
-
/** 内容渲染方式,默认 dom;canvas 使用画布绘制文本,并保留可见交互组件及 DOM
|
|
2432
|
+
/** 内容渲染方式,默认 dom;canvas 使用画布绘制文本,并保留可见交互组件及 DOM 单元格语义。普通文本在指针进入或按下时按需提供原生文字选区,横向滚轮与画布同步移动。Canvas 强制固定行高和行虚拟化;不支持虚拟化的插件、rowHeights 或 rowResizable 会自动回退 DOM。 */
|
|
2433
2433
|
renderMode?: "dom" | "canvas";
|
|
2434
2434
|
/** 自动启用虚拟滚动的展示行数阈值(含该值),默认 100;仅在未指定 virtual 时使用,实际展示超过 100 行始终强制启用。 */
|
|
2435
2435
|
virtualThreshold?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -2198,7 +2198,7 @@ interface TableColumn<T = Record<string, unknown>> {
|
|
|
2198
2198
|
ellipsis?: boolean;
|
|
2199
2199
|
/** 数据单元格是否使用 Sia Tooltip 显示完整文本;默认 false,不生成浏览器原生 title。列头仅在文字实际省略时提示完整标题,不受此属性影响。 */
|
|
2200
2200
|
showTitle?: boolean;
|
|
2201
|
-
/**
|
|
2201
|
+
/** 是否允许该列排序;配合排序插件显示浮动按钮,不挤占标题宽度。未排序时在悬停或键盘聚焦后显示,依次切换升序、降序、未排序;当前排序方向始终以高亮单箭头显示。 */
|
|
2202
2202
|
sortable?: boolean;
|
|
2203
2203
|
/** 是否允许该列筛选。 */
|
|
2204
2204
|
filterable?: boolean;
|
|
@@ -2429,7 +2429,7 @@ interface TableProps<T extends Record<string, unknown> = Record<string, unknown>
|
|
|
2429
2429
|
striped?: boolean;
|
|
2430
2430
|
/** 是否启用窗口化渲染;未指定时按 virtualThreshold 判断。筛选、分页及树展开后的实际展示行数超过 100 时强制启用,优先于 false 和插件的 disableVirtual。 */
|
|
2431
2431
|
virtual?: boolean;
|
|
2432
|
-
/** 内容渲染方式,默认 dom;canvas 使用画布绘制文本,并保留可见交互组件及 DOM
|
|
2432
|
+
/** 内容渲染方式,默认 dom;canvas 使用画布绘制文本,并保留可见交互组件及 DOM 单元格语义。普通文本在指针进入或按下时按需提供原生文字选区,横向滚轮与画布同步移动。Canvas 强制固定行高和行虚拟化;不支持虚拟化的插件、rowHeights 或 rowResizable 会自动回退 DOM。 */
|
|
2433
2433
|
renderMode?: "dom" | "canvas";
|
|
2434
2434
|
/** 自动启用虚拟滚动的展示行数阈值(含该值),默认 100;仅在未指定 virtual 时使用,实际展示超过 100 行始终强制启用。 */
|
|
2435
2435
|
virtualThreshold?: number;
|
package/dist/index.js
CHANGED
|
@@ -6462,8 +6462,9 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
6462
6462
|
canvas.style.height = `${height}px`;
|
|
6463
6463
|
ctx.setTransform(ratio, 0, 0, ratio, 0, 0);
|
|
6464
6464
|
ctx.clearRect(0, 0, width, height);
|
|
6465
|
-
const style = getComputedStyle(scroller);
|
|
6466
|
-
const
|
|
6465
|
+
const style = getComputedStyle(scroller.querySelector("td[data-column-key]") ?? scroller);
|
|
6466
|
+
const padding = Number.parseFloat(style.paddingLeft) || 12;
|
|
6467
|
+
const foreground = getComputedStyle(scroller).color;
|
|
6467
6468
|
const readyCells = /* @__PURE__ */ new Map();
|
|
6468
6469
|
scroller.querySelectorAll("tr[data-canvas-row-index]").forEach((element) => {
|
|
6469
6470
|
const keys = /* @__PURE__ */ new Set();
|
|
@@ -6498,10 +6499,11 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
6498
6499
|
for (let index = first; index < last; index++) {
|
|
6499
6500
|
const row = rows[index];
|
|
6500
6501
|
const y = headerHeight + index * rowHeight - scroller.scrollTop + rowHeight / 2;
|
|
6502
|
+
if (readyCells.get(index)?.has(column.key)) continue;
|
|
6501
6503
|
if (!column.canvasRender && column.render) {
|
|
6502
6504
|
if (!readyCells.get(index)?.has(column.key)) {
|
|
6503
|
-
const skeletonWidth = Math.max(0, Math.min(cellWidth -
|
|
6504
|
-
const skeletonX = column.align === "right" ? x + cellWidth - skeletonWidth -
|
|
6505
|
+
const skeletonWidth = Math.max(0, Math.min(cellWidth - padding * 2, 120));
|
|
6506
|
+
const skeletonX = column.align === "right" ? x + cellWidth - skeletonWidth - padding : column.align === "center" ? x + (cellWidth - skeletonWidth) / 2 : x + padding;
|
|
6505
6507
|
ctx.save();
|
|
6506
6508
|
ctx.fillStyle = foreground;
|
|
6507
6509
|
ctx.globalAlpha = 0.12;
|
|
@@ -6515,7 +6517,7 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
6515
6517
|
const value = getTableValue(row.record, column.dataIndex, column.code ?? column.key);
|
|
6516
6518
|
const content2 = column.canvasRender ? column.canvasRender(value, row.record, row.sourceIndex, { row, rowIndex: index, column }) : { text: value == null ? "" : String(value) };
|
|
6517
6519
|
if (!content2?.text) continue;
|
|
6518
|
-
const available = Math.max(0, cellWidth - (content2.background ?
|
|
6520
|
+
const available = Math.max(0, cellWidth - padding * 2 - (content2.background ? 16 : 0));
|
|
6519
6521
|
let text = content2.text;
|
|
6520
6522
|
if (ctx.measureText(text).width > available) {
|
|
6521
6523
|
let lo = 0, hi = text.length;
|
|
@@ -6528,7 +6530,7 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
6528
6530
|
}
|
|
6529
6531
|
const textWidth = ctx.measureText(text).width;
|
|
6530
6532
|
const total = textWidth + (content2.background ? 16 : 0);
|
|
6531
|
-
const tx = column.align === "right" ? x + cellWidth - total -
|
|
6533
|
+
const tx = column.align === "right" ? x + cellWidth - total - padding : column.align === "center" ? x + (cellWidth - total) / 2 : x + padding;
|
|
6532
6534
|
if (content2.background) {
|
|
6533
6535
|
ctx.fillStyle = content2.background;
|
|
6534
6536
|
ctx.beginPath();
|
|
@@ -6549,6 +6551,19 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
6549
6551
|
draw();
|
|
6550
6552
|
};
|
|
6551
6553
|
scroller.addEventListener("scroll", onScroll, { passive: true, capture: true });
|
|
6554
|
+
const onWheel = (event) => {
|
|
6555
|
+
if (event.ctrlKey || !event.cancelable) return;
|
|
6556
|
+
const dx = event.deltaX || (event.shiftKey ? event.deltaY : 0);
|
|
6557
|
+
if (!dx) return;
|
|
6558
|
+
const scale = event.deltaMode === 1 ? rowHeight : event.deltaMode === 2 ? scroller.clientWidth : 1;
|
|
6559
|
+
const next = Math.max(0, Math.min(scroller.scrollWidth - scroller.clientWidth, scroller.scrollLeft + dx * scale));
|
|
6560
|
+
if (next === scroller.scrollLeft) return;
|
|
6561
|
+
event.preventDefault();
|
|
6562
|
+
scroller.scrollLeft = next;
|
|
6563
|
+
if (event.deltaX && event.deltaY) scroller.scrollTop += event.deltaY * (event.deltaMode === 2 ? scroller.clientHeight : scale);
|
|
6564
|
+
onScroll();
|
|
6565
|
+
};
|
|
6566
|
+
scroller.addEventListener("wheel", onWheel, { passive: false });
|
|
6552
6567
|
const resize = new ResizeObserver(schedule);
|
|
6553
6568
|
resize.observe(scroller);
|
|
6554
6569
|
const content = new MutationObserver(schedule);
|
|
@@ -6563,6 +6578,7 @@ function TableCanvasLayer({ viewport, rows, columns, widths, rowHeight, headerHe
|
|
|
6563
6578
|
content.disconnect();
|
|
6564
6579
|
theme.disconnect();
|
|
6565
6580
|
scroller.removeEventListener("scroll", onScroll, true);
|
|
6581
|
+
scroller.removeEventListener("wheel", onWheel);
|
|
6566
6582
|
window.removeEventListener("resize", schedule);
|
|
6567
6583
|
};
|
|
6568
6584
|
}, [viewport, rows, columns, widths, rowHeight, headerHeight]);
|
|
@@ -6724,6 +6740,7 @@ function playCellFocusGlow(cell, isVisible, onFinish, options) {
|
|
|
6724
6740
|
|
|
6725
6741
|
// src/components/Table/Table.tsx
|
|
6726
6742
|
import { Fragment as Fragment9, forwardRef as forwardRef6, isValidElement as isValidElement4, memo, useCallback as useCallback2, useEffect as useEffect17, useImperativeHandle, useMemo as useMemo10, useRef as useRef24, useState as useState24 } from "react";
|
|
6743
|
+
import { flushSync } from "react-dom";
|
|
6727
6744
|
|
|
6728
6745
|
// src/components/Table/plugins.tsx
|
|
6729
6746
|
import { isValidElement as isValidElement3, useEffect as useEffect16, useRef as useRef23, useState as useState23 } from "react";
|
|
@@ -9392,6 +9409,7 @@ var TableBodyRow = memo(function TableBodyRow2({
|
|
|
9392
9409
|
onCellPointerDown,
|
|
9393
9410
|
onCellPointerMove
|
|
9394
9411
|
}) {
|
|
9412
|
+
const [textColumn, setTextColumn] = useState24();
|
|
9395
9413
|
const resizeColumnKey = resize ? columns.find((column) => !getCellProps(column).hidden)?.key : void 0;
|
|
9396
9414
|
return /* @__PURE__ */ jsx29(
|
|
9397
9415
|
"tr",
|
|
@@ -9425,21 +9443,27 @@ var TableBodyRow = memo(function TableBodyRow2({
|
|
|
9425
9443
|
{
|
|
9426
9444
|
"data-column-key": column.key,
|
|
9427
9445
|
"aria-invalid": invalid || void 0,
|
|
9428
|
-
"data-canvas-dom-ready": canvas && (pluginCellProps.content !== void 0 || !column.canvasRender && column.render) ? "true" : void 0,
|
|
9446
|
+
"data-canvas-dom-ready": canvas && (pluginCellProps.content !== void 0 || !column.canvasRender && (column.render || textColumn === column.key)) ? "true" : void 0,
|
|
9429
9447
|
"aria-label": canvas ? column.canvasRender?.(value, row.record, row.sourceIndex, { row, rowIndex, column })?.text ?? (value == null ? "" : String(value)) : void 0,
|
|
9430
9448
|
rowSpan: pluginCellProps.rowSpan,
|
|
9431
9449
|
colSpan: pluginCellProps.colSpan,
|
|
9432
9450
|
className: `sia-table__cell sia-table__cell--${column.align ?? "left"}${fixed ? ` sia-table__cell--fixed sia-table__cell--fixed-${fixed}` : ""}${fixedEdgeClass}${autoWidthClass}${invalid ? " sia-table__cell--invalid" : ""}${column.ellipsis !== false ? " sia-table__cell--ellipsis" : ""} ${cellClass} ${pluginCellProps.className ?? ""}`.trim(),
|
|
9433
9451
|
style: { ...fixedStyle, ...pluginCellProps.style },
|
|
9434
|
-
onMouseEnter: () =>
|
|
9452
|
+
onMouseEnter: () => {
|
|
9453
|
+
if (canvas && !column.canvasRender && !column.render) setTextColumn(column.key);
|
|
9454
|
+
onCellMouseEnter(column);
|
|
9455
|
+
},
|
|
9435
9456
|
onMouseLeave: () => onCellMouseLeave(column),
|
|
9436
9457
|
onClick: (event) => onCellClick(column, event),
|
|
9437
9458
|
onDoubleClick: (event) => onCellDoubleClick(column, event),
|
|
9438
9459
|
onContextMenu: (event) => onCellContextMenu(column, event),
|
|
9439
|
-
onPointerDown: (event) =>
|
|
9460
|
+
onPointerDown: (event) => {
|
|
9461
|
+
if (canvas && !column.canvasRender && !column.render && textColumn !== column.key) flushSync(() => setTextColumn(column.key));
|
|
9462
|
+
onCellPointerDown(column, event);
|
|
9463
|
+
},
|
|
9440
9464
|
onPointerMove: (event) => onCellPointerMove(column, event),
|
|
9441
9465
|
children: [
|
|
9442
|
-
!canvas || visibleColumns.has(column.key) && (pluginCellProps.content !== void 0 || !column.canvasRender && column.render) ? /* @__PURE__ */ jsx29(
|
|
9466
|
+
!canvas || visibleColumns.has(column.key) && (pluginCellProps.content !== void 0 || !column.canvasRender && (column.render || textColumn === column.key)) ? /* @__PURE__ */ jsx29(
|
|
9443
9467
|
TableCellContent,
|
|
9444
9468
|
{
|
|
9445
9469
|
ellipsis: column.ellipsis !== false,
|