@ai-table/grid 0.0.58 → 0.0.60
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/esm2022/grid.component.mjs +8 -3
- package/esm2022/renderer/components/cells/rate.component.mjs +5 -2
- package/esm2022/renderer/creations/create-cells.mjs +3 -3
- package/esm2022/renderer/drawers/cell-drawer.mjs +9 -26
- package/esm2022/utils/visible-range.mjs +7 -3
- package/fesm2022/ai-table-grid.mjs +25 -30
- package/fesm2022/ai-table-grid.mjs.map +1 -1
- package/grid.component.d.ts.map +1 -1
- package/package.json +1 -1
- package/renderer/components/cells/rate.component.d.ts.map +1 -1
- package/renderer/drawers/cell-drawer.d.ts +1 -1
- package/renderer/drawers/cell-drawer.d.ts.map +1 -1
- package/utils/visible-range.d.ts.map +1 -1
@@ -4187,7 +4187,11 @@ const getVisibleRangeInfo = (coordinate, scrollState) => {
|
|
4187
4187
|
};
|
4188
4188
|
};
|
4189
4189
|
const scrollMax = (aiTable, coordinate, visibleColumns) => {
|
4190
|
-
const
|
4190
|
+
const visibleColumnIndexMap = aiTable.context.visibleColumnsIndexMap();
|
4191
|
+
const scrollMaxWidth = visibleColumns.reduce((pre, cur) => {
|
4192
|
+
const index = visibleColumnIndexMap.get(cur._id);
|
4193
|
+
return pre + (isNumber(index) ? coordinate.getColumnWidth(index) : 0);
|
4194
|
+
}, AI_TABLE_ROW_HEAD_WIDTH);
|
4191
4195
|
const scrollMaxHeight = coordinate.getRowOffset(coordinate.rowCount - 1) + 32;
|
4192
4196
|
return { scrollMaxWidth, scrollMaxHeight };
|
4193
4197
|
};
|
@@ -6482,7 +6486,7 @@ class CellDrawer extends Drawer {
|
|
6482
6486
|
}
|
6483
6487
|
}
|
6484
6488
|
// 单元格渲染
|
6485
|
-
renderCell(render, ctx) {
|
6489
|
+
renderCell(render, ctx, columnWidth) {
|
6486
6490
|
const { field, cellValue } = render;
|
6487
6491
|
const fieldType = field.type;
|
6488
6492
|
const fieldMethod = FieldModelMap[fieldType];
|
@@ -6502,7 +6506,7 @@ class CellDrawer extends Drawer {
|
|
6502
6506
|
case AITableFieldType.updatedAt:
|
6503
6507
|
return this.renderCellDate(render, ctx);
|
6504
6508
|
case AITableFieldType.rate:
|
6505
|
-
return this.renderCellRate(render, ctx);
|
6509
|
+
return this.renderCellRate(render, ctx, columnWidth);
|
6506
6510
|
case AITableFieldType.progress:
|
6507
6511
|
return this.renderCellProgress(render, ctx);
|
6508
6512
|
case AITableFieldType.member:
|
@@ -6900,11 +6904,14 @@ class CellDrawer extends Drawer {
|
|
6900
6904
|
});
|
6901
6905
|
}
|
6902
6906
|
}
|
6903
|
-
renderCellRate(render, ctx) {
|
6907
|
+
renderCellRate(render, ctx, columnWidth) {
|
6904
6908
|
const { x, y, transformValue } = render;
|
6905
6909
|
const max = AI_TABLE_RATE_MAX;
|
6906
6910
|
const size = AI_TABLE_CELL_EMOJI_SIZE;
|
6907
|
-
|
6911
|
+
const renderWidth = columnWidth - AI_TABLE_CELL_PADDING;
|
6912
|
+
const starWidth = AI_TABLE_CELL_EMOJI_SIZE + AI_TABLE_CELL_EMOJI_PADDING;
|
6913
|
+
const maxStar = Math.min(max, Math.floor(renderWidth / starWidth));
|
6914
|
+
return [...Array(maxStar).keys()].map((item, index) => {
|
6908
6915
|
const value = index + 1;
|
6909
6916
|
const checked = value <= (transformValue || 0);
|
6910
6917
|
const iconX = index * size + AI_TABLE_CELL_PADDING + index * AI_TABLE_CELL_EMOJI_PADDING;
|
@@ -7079,12 +7086,10 @@ class CellDrawer extends Drawer {
|
|
7079
7086
|
let currentX = AI_TABLE_CELL_PADDING;
|
7080
7087
|
let currentY = (AI_TABLE_ROW_BLANK_HEIGHT - itemHeight) / 2;
|
7081
7088
|
const itemOtherWidth = fileIconSize + AI_TABLE_FIELD_ITEM_MARGIN_RIGHT;
|
7082
|
-
const maxHeight = isActive ? 130 - AI_TABLE_CELL_MULTI_PADDING_TOP : rowHeight - AI_TABLE_CELL_MULTI_PADDING_TOP;
|
7083
7089
|
const maxTextWidth = isOperating
|
7084
7090
|
? columnWidth - 2 * AI_TABLE_CELL_PADDING - itemOtherWidth - AI_TABLE_CELL_DELETE_ITEM_BUTTON_SIZE - 12
|
7085
7091
|
: columnWidth - 2 * AI_TABLE_CELL_PADDING - itemOtherWidth;
|
7086
7092
|
const listCount = transformValue.length;
|
7087
|
-
let isOverflow = false;
|
7088
7093
|
for (let index = 0; index < listCount; index++) {
|
7089
7094
|
const attachmentInfo = references?.attachments[transformValue[index]];
|
7090
7095
|
if (!attachmentInfo)
|
@@ -7095,31 +7100,13 @@ class CellDrawer extends Drawer {
|
|
7095
7100
|
let realMaxTextWidth = maxTextWidth < 0 ? 0 : maxTextWidth;
|
7096
7101
|
if (index === 0 && isOperating) {
|
7097
7102
|
const operatingMaxWidth = maxTextWidth - (AI_TABLE_CELL_ADD_ITEM_BUTTON_SIZE + 4);
|
7098
|
-
|
7099
|
-
if (operatingMaxWidth <= 20) {
|
7100
|
-
currentX = AI_TABLE_CELL_PADDING;
|
7101
|
-
currentY += AI_TABLE_OPTION_ITEM_HEIGHT + AI_TABLE_CELL_MULTI_ITEM_MARGIN_TOP;
|
7102
|
-
}
|
7103
|
-
else {
|
7104
|
-
realMaxTextWidth = operatingMaxWidth;
|
7105
|
-
}
|
7103
|
+
realMaxTextWidth = operatingMaxWidth;
|
7106
7104
|
}
|
7107
7105
|
if (columnWidth != null) {
|
7108
7106
|
// 在非活动状态下,当超出列宽时,不会渲染后续内容
|
7109
7107
|
if (currentX >= columnWidth - 2 * AI_TABLE_CELL_PADDING) {
|
7110
7108
|
break;
|
7111
7109
|
}
|
7112
|
-
// 如果不是非活动状态的最后一行,则换行渲染溢出内容
|
7113
|
-
if (currentX > columnWidth - 2 * AI_TABLE_CELL_PADDING) {
|
7114
|
-
currentX = AI_TABLE_CELL_PADDING;
|
7115
|
-
}
|
7116
|
-
if (currentX + itemWidth > columnWidth - AI_TABLE_CELL_PADDING) {
|
7117
|
-
currentX = AI_TABLE_CELL_PADDING;
|
7118
|
-
currentY += itemHeight;
|
7119
|
-
}
|
7120
|
-
if (currentY >= maxHeight) {
|
7121
|
-
isOverflow = true;
|
7122
|
-
}
|
7123
7110
|
}
|
7124
7111
|
const svgString = getFileThumbnailSvgString(addition?.ext);
|
7125
7112
|
const img = new Image();
|
@@ -7367,11 +7354,11 @@ const createCells = (config) => {
|
|
7367
7354
|
ctx.save();
|
7368
7355
|
ctx.rect(realX, realY, width, rowHeight);
|
7369
7356
|
ctx.clip();
|
7370
|
-
cellDrawer.renderCell(render, ctx);
|
7357
|
+
cellDrawer.renderCell(render, ctx, columnWidth);
|
7371
7358
|
ctx.restore();
|
7372
7359
|
}
|
7373
7360
|
else {
|
7374
|
-
cellDrawer.renderCell(render, ctx);
|
7361
|
+
cellDrawer.renderCell(render, ctx, columnWidth);
|
7375
7362
|
}
|
7376
7363
|
}
|
7377
7364
|
}
|
@@ -8638,7 +8625,10 @@ class AITableCellRate {
|
|
8638
8625
|
this.pointerX() <= lastStarRightX &&
|
8639
8626
|
this.pointerY() >= startTopY &&
|
8640
8627
|
this.pointerY() <= startBottomY;
|
8641
|
-
|
8628
|
+
const renderWidth = coordinate.getColumnWidth(columnIndex) - AI_TABLE_CELL_PADDING;
|
8629
|
+
const starWidth = AI_TABLE_CELL_EMOJI_SIZE + AI_TABLE_CELL_EMOJI_PADDING;
|
8630
|
+
const maxStar = Math.min(max, Math.floor(renderWidth / starWidth));
|
8631
|
+
return [...Array(maxStar).keys()].map((item, index) => {
|
8642
8632
|
const value = index + 1;
|
8643
8633
|
const checked = value <= transformValue;
|
8644
8634
|
const starX = x + index * (AI_TABLE_CELL_EMOJI_SIZE + AI_TABLE_CELL_EMOJI_PADDING);
|
@@ -9926,7 +9916,12 @@ class AITableGrid extends AITableGridBase {
|
|
9926
9916
|
const { x, y } = pos;
|
9927
9917
|
const curMousePosition = getMousePosition(this.aiTable, x, y, this.coordinate(), AITable.getVisibleFields(this.aiTable), context, targetName);
|
9928
9918
|
handleMouseStyle(curMousePosition.realTargetName, curMousePosition.areaType, this.containerElement(), this.aiReadonly(), this.aiRowDragDisabled());
|
9929
|
-
|
9919
|
+
if (curMousePosition.areaType !== AITableAreaType.none) {
|
9920
|
+
context.setPointPosition(curMousePosition);
|
9921
|
+
}
|
9922
|
+
else {
|
9923
|
+
context.setPointPosition(DEFAULT_POINT_POSITION);
|
9924
|
+
}
|
9930
9925
|
this.timer = null;
|
9931
9926
|
if (this.isDragSelecting) {
|
9932
9927
|
const { fieldId, recordId } = getDetailByTargetName(curMousePosition.realTargetName);
|