@ai-table/grid 0.5.8 → 0.5.9

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.
@@ -945,7 +945,7 @@ const AI_TABLE_AUTO_SCROLL_RIGHT_THRESHOLD = 40;
945
945
  const AI_TABLE_AUTO_SCROLL_TOP_THRESHOLD = AI_TABLE_FIELD_HEAD_HEIGHT / 2;
946
946
  const AI_TABLE_AUTO_SCROLL_BOTTOM_THRESHOLD = AI_TABLE_FIELD_HEAD_HEIGHT / 2;
947
947
  const AI_TABLE_FIELD_STAT_INNER_HEIGHT = 47; // 字段统计内部高度
948
- const AI_TABLE_TEXT_LINE_HEIGHT = 1.84; // 默认文本行高
948
+ const AI_TABLE_TEXT_LINE_HEIGHT = 1.7; // 默认文本行高
949
949
  const AI_TABLE_FIELD_STAT_CONTAINER_HEIGHT = AI_TABLE_FIELD_STAT_INNER_HEIGHT + AI_TABLE_CELL_LINE_BORDER * 2; // 统计容器高度
950
950
  const AI_TABLE_GROUP_MAX_LEVEL = 3;
951
951
  const AI_TABLE_ROW_GROUP_COLLAPSE_BUTTON = 'AI_TABLE_ROW_GROUP_COLLAPSE_BUTTON';
@@ -3814,7 +3814,7 @@ function getPlaceHolderCellsConfigs(options) {
3814
3814
  fill: Colors.transparent,
3815
3815
  strokeEnabled: false,
3816
3816
  hitStrokeWidth: 0,
3817
- transformsEnabled: 'position',
3817
+ transformsEnabled: DEFAULT_TEXT_TRANSFORMS_ENABLED,
3818
3818
  perfectDrawEnabled: false,
3819
3819
  shadowEnabled: false
3820
3820
  });
@@ -4518,7 +4518,7 @@ class Drawer {
4518
4518
  return res;
4519
4519
  }
4520
4520
  wrapTextWithKonva(options) {
4521
- const { x, y, text, maxWidth, maxHeight, lineHeight = AI_TABLE_TEXT_LINE_HEIGHT, maxRow = DEFAULT_WRAP_TEXT_MAX_ROW, fontSize = DEFAULT_FONT_SIZE, fillStyle = this.colors.gray800, textAlign = DEFAULT_TEXT_ALIGN_LEFT, verticalAlign = DEFAULT_TEXT_VERTICAL_ALIGN_TOP, fontWeight = DEFAULT_FONT_WEIGHT, textDecoration = DEFAULT_TEXT_DECORATION, fieldType, needDraw = false } = options;
4521
+ const { x, y, text, maxWidth, maxHeight, lineHeight = AI_TABLE_TEXT_LINE_HEIGHT, maxRow, fontSize = DEFAULT_FONT_SIZE, fillStyle = this.colors.gray800, textAlign = DEFAULT_TEXT_ALIGN_LEFT, verticalAlign = DEFAULT_TEXT_VERTICAL_ALIGN_TOP, fontWeight = DEFAULT_FONT_WEIGHT, textDecoration = DEFAULT_TEXT_DECORATION, fieldType, needDraw = false } = options;
4522
4522
  let offsetX = 0;
4523
4523
  const fontStyle = DEFAULT_FONT_STYLE;
4524
4524
  const baselineOffset = verticalAlign === DEFAULT_TEXT_VERTICAL_ALIGN_TOP ? fontSize / 2 : 0;
@@ -4543,7 +4543,7 @@ class Drawer {
4543
4543
  if (fillStyle)
4544
4544
  this.setStyle({ fillStyle });
4545
4545
  this.ctx.textAlign = textAlign;
4546
- const cacheKey = `${fontStyleKey}-${maxRow}-${maxWidth || 0}-${maxHeight || 0}-${fieldType}-${text}`;
4546
+ const cacheKey = `${fontStyleKey}-${(maxRow || 1)}-${maxWidth || 0}-${maxHeight || 0}-${fieldType}-${text}`;
4547
4547
  const cacheTextData = textDataCache.get(cacheKey);
4548
4548
  if (cacheTextData) {
4549
4549
  if (this.needDraw && needDraw) {
@@ -4552,12 +4552,12 @@ class Drawer {
4552
4552
  return cacheTextData;
4553
4553
  }
4554
4554
  const resultData = [];
4555
- const height = maxHeight ? maxHeight : maxRow * lineHeight * fontSize;
4555
+ const height = maxHeight ? maxHeight : maxRow ? (maxRow) * lineHeight * fontSize : undefined;
4556
4556
  const konvaText = new Konva.Text({
4557
4557
  text,
4558
4558
  fontSize,
4559
4559
  fontFamily: DEFAULT_FONT_FAMILY,
4560
- lineHeight: 1.84,
4560
+ lineHeight: AI_TABLE_TEXT_LINE_HEIGHT,
4561
4561
  wrap: 'char',
4562
4562
  width: maxWidth,
4563
4563
  height: height,
@@ -4565,7 +4565,7 @@ class Drawer {
4565
4565
  verticalAlign: 'top',
4566
4566
  fontStyle: fontStyle,
4567
4567
  ellipsis: true,
4568
- transformsEnabled: true,
4568
+ transformsEnabled: DEFAULT_TEXT_TRANSFORMS_ENABLED,
4569
4569
  listening: false
4570
4570
  });
4571
4571
  konvaText.textArr.forEach((item, index) => {
@@ -5385,7 +5385,7 @@ class AITableActionIcon {
5385
5385
  };
5386
5386
  }, ...(ngDevMode ? [{ debugName: "iconGroupConfig" }] : []));
5387
5387
  this.iconConfig = computed(() => {
5388
- let { type, data, size = DEFAULT_ICON_SIZE, stroke, strokeWidth = 1, scaleX, scaleY, offsetX, offsetY, rotation, fill, hoverFill: hoverFill, transformsEnabled = 'position' } = this.config();
5388
+ let { type, data, size = DEFAULT_ICON_SIZE, stroke, strokeWidth = 1, scaleX, scaleY, offsetX, offsetY, rotation, fill, hoverFill: hoverFill, transformsEnabled = DEFAULT_TEXT_TRANSFORMS_ENABLED } = this.config();
5389
5389
  fill = fill || Colors.gray600;
5390
5390
  let pathData = data;
5391
5391
  switch (type) {
@@ -6499,7 +6499,7 @@ class CellDrawer extends Drawer {
6499
6499
  this.wrapTextWithKonva({
6500
6500
  x: renderX,
6501
6501
  y: renderY,
6502
- maxHeight: rowHeight,
6502
+ maxHeight: rowHeight - AI_TABLE_CELL_PADDING,
6503
6503
  text: renderText,
6504
6504
  maxWidth: textMaxWidth,
6505
6505
  maxRow,
@@ -7337,7 +7337,7 @@ class AITableIcon {
7337
7337
  };
7338
7338
  }, ...(ngDevMode ? [{ debugName: "squareShapeConfig" }] : []));
7339
7339
  this.iconConfig = computed(() => {
7340
- const { type, data, backgroundWidth, backgroundHeight, size = DEFAULT_ICON_SIZE, stroke, strokeWidth = 1, scaleX, scaleY, offsetX, offsetY, rotation, fill = Colors.gray600, transformsEnabled = 'position', disabled } = this.config();
7340
+ const { type, data, backgroundWidth, backgroundHeight, size = DEFAULT_ICON_SIZE, stroke, strokeWidth = 1, scaleX, scaleY, offsetX, offsetY, rotation, fill = Colors.gray600, transformsEnabled = DEFAULT_TEXT_TRANSFORMS_ENABLED, disabled } = this.config();
7341
7341
  let pathData = data;
7342
7342
  switch (type) {
7343
7343
  case AITableCheckType.checked:
@@ -10934,23 +10934,29 @@ class AITableCellText extends CoverCellBase {
10934
10934
  }, ...(ngDevMode ? [{ debugName: "scrollConfig" }] : []));
10935
10935
  this.expandTextBounds = computed(() => {
10936
10936
  const textRender = this.textString();
10937
- const tmpText = new Konva.Text({
10937
+ const render = this.config()?.render;
10938
+ if (!render) {
10939
+ return { height: 0, data: [] };
10940
+ }
10941
+ const { x, y } = render;
10942
+ const text = drawer.wrapTextWithKonva({
10943
+ x,
10944
+ y,
10938
10945
  text: textRender,
10946
+ maxWidth: this.textMaxWidth(),
10939
10947
  fontSize: DEFAULT_FONT_SIZE,
10940
- fontFamily: DEFAULT_FONT_FAMILY,
10941
10948
  lineHeight: AI_TABLE_TEXT_LINE_HEIGHT,
10942
- wrap: 'char',
10943
- width: this.textMaxWidth(),
10944
- align: DEFAULT_TEXT_ALIGN_LEFT,
10945
- verticalAlign: 'top',
10946
- fontStyle: DEFAULT_FONT_STYLE,
10947
- ellipsis: DEFAULT_TEXT_ELLIPSIS,
10948
- transformsEnabled: DEFAULT_TEXT_TRANSFORMS_ENABLED,
10949
- listening: false
10949
+ textAlign: DEFAULT_TEXT_ALIGN_LEFT,
10950
+ verticalAlign: DEFAULT_TEXT_VERTICAL_ALIGN_MIDDLE,
10951
+ fillStyle: Colors.primary,
10952
+ fontWeight: DEFAULT_FONT_WEIGHT,
10953
+ textDecoration: DEFAULT_TEXT_DECORATION,
10954
+ fieldType: AITableFieldType.text,
10955
+ needDraw: false
10950
10956
  });
10951
10957
  return {
10952
- ...tmpText.getClientRect(),
10953
- height: tmpText.getClientRect().height + this.startY() * 2 - AI_TABLE_CELL_LINE_BORDER
10958
+ ...text,
10959
+ height: text.height + AI_TABLE_CELL_PADDING + AI_TABLE_CELL_LINE_BORDER
10954
10960
  };
10955
10961
  }, ...(ngDevMode ? [{ debugName: "expandTextBounds" }] : []));
10956
10962
  this.textMaxWidth = computed(() => {
@@ -10980,24 +10986,25 @@ class AITableCellText extends CoverCellBase {
10980
10986
  const render = this.config()?.render;
10981
10987
  if (render) {
10982
10988
  const { x, y, transformValue, field, columnWidth, rowHeight, style, zIndex, recordId } = render;
10983
- let textRender = this.textString();
10984
- if (isUndefinedOrNull(textRender)) {
10989
+ let text = this.textString();
10990
+ if (isUndefinedOrNull(text)) {
10985
10991
  return;
10986
10992
  }
10987
- const { height } = this.expandTextBounds();
10993
+ const { height, data } = this.expandTextBounds();
10994
+ const textRender = data.map((item) => item.text).join('\n');
10988
10995
  return {
10989
10996
  x,
10990
10997
  y: this.startY(),
10991
10998
  name: this.cellName(),
10992
10999
  text: textRender,
10993
- wrap: 'char',
11000
+ wrap: 'none',
10994
11001
  width: this.textMaxWidth(),
10995
11002
  fillStyle: Colors.primary,
10996
11003
  lineHeight: AI_TABLE_TEXT_LINE_HEIGHT,
10997
11004
  verticalAlign: 'top',
10998
11005
  height,
10999
11006
  listening: true,
11000
- ellipsis: true,
11007
+ ellipsis: false,
11001
11008
  zIndex
11002
11009
  };
11003
11010
  }
@@ -11019,7 +11026,7 @@ class AITableCellText extends CoverCellBase {
11019
11026
  wrap: 'char',
11020
11027
  width: this.textMaxWidth(),
11021
11028
  fillStyle: Colors.primary,
11022
- height: rowHeight + AI_TABLE_CELL_LINE_BORDER * 2,
11029
+ height: rowHeight - AI_TABLE_CELL_PADDING,
11023
11030
  lineHeight: AI_TABLE_TEXT_LINE_HEIGHT,
11024
11031
  listening: false,
11025
11032
  ellipsis: true,