Skip to content

Commit

Permalink
fix: normalize getCellStyle return object (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Jun 15, 2023
1 parent f2c225e commit 57b117a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
9 changes: 5 additions & 4 deletions packages/vtable/__tests__/listTable-autoRowHeight.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,11 @@ describe('listTable init test', () => {
fontStyle: undefined,
fontVariant: undefined,
fontWeight: null,
lineThrough: undefined,
lineThroughDash: undefined,
underline: undefined,
underlineDash: undefined
lineThrough: false,
// lineThroughDash: undefined,
underline: false,
// underlineDash: undefined
padding: [10, 0, 10, 60]
});
});

Expand Down
18 changes: 10 additions & 8 deletions packages/vtable/__tests__/pivotTable.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,11 @@ describe('pivotTable init test', () => {
fontStyle: undefined,
fontVariant: undefined,
fontWeight: 'bold',
lineThrough: undefined,
lineThroughDash: undefined,
underline: undefined,
underlineDash: undefined
lineThrough: false,
// lineThroughDash: undefined,
underline: false,
// underlineDash: undefined
padding: [10, 16, 10, 16]
});
});
test('pivotTable API getCellStyle', () => {
Expand All @@ -508,10 +509,11 @@ describe('pivotTable init test', () => {
fontStyle: undefined,
fontVariant: undefined,
fontWeight: null,
lineThrough: undefined,
lineThroughDash: undefined,
underline: undefined,
underlineDash: undefined
lineThrough: false,
// lineThroughDash: undefined,
underline: false,
// underlineDash: undefined
padding: [10, 16, 10, 16]
});
});
test('pivotTable getCellRange', () => {
Expand Down
27 changes: 16 additions & 11 deletions packages/vtable/src/core/BaseTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import type { PivotHeaderLayoutMap } from '../layout/pivot-header-layout';
import { TooltipHandler } from '../tooltip/TooltipHandler';
import type { CachedDataSource, DataSource } from '../data';
import type { IWrapTextGraphicAttribute } from '@visactor/vrender';
import type { ITextSize } from '@visactor/vutils';
import { isBoolean, type ITextSize } from '@visactor/vutils';
import { WrapText } from '../scenegraph/graphic/text';
import { textMeasure } from '../scenegraph/utils/measure-text';
import { getProp } from '../scenegraph/utils/get-prop';
Expand Down Expand Up @@ -2647,8 +2647,10 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
return {
textAlign: theme.text.textAlign,
textBaseline: theme.text.textBaseline,
bgColor: theme.group.fill,
color: theme.text.fill,
bgColor: isBoolean(theme.group.fill)
? getProp('bgColor', actStyle, col, row, this)
: (theme.group.fill as string),
color: isBoolean(theme.text.fill) ? getProp('color', actStyle, col, row, this) : (theme.text.fill as string),
fontFamily: theme.text.fontFamily,
fontSize: theme.text.fontSize,
fontWeight: theme.text.fontWeight,
Expand All @@ -2658,18 +2660,21 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI {
autoWrapText: autoWrapText ?? false,
lineClamp: lineClamp ?? 'auto',
textOverflow,
borderColor: theme.group.stroke,
borderColor: isBoolean(theme.group.stroke)
? getProp('borderColor', actStyle, col, row, this)
: (theme.group.stroke as string | string[]),
borderLineWidth: theme.group.lineWidth,
borderLineDash: theme.group.lineDash,
underline: theme.text.underline,
underline: !!theme.text.underline,
// underlineColor: theme.text.underlineColor,
underlineDash: (theme.text as any).underlineDash,
// underlineWidth: (theme.text as any).underlineWidth,
lineThrough: theme.text.lineThrough,
// underlineDash: theme.text.underlineDash,
lineThrough: !!theme.text.lineThrough,
// lineThroughColor: theme.text.lineThroughColor,
lineThroughDash: (theme.text as any).lineThroughDash
// lineThroughLineWidth: textDecorationLineWidth,
} as any;
// lineThroughDash: (theme.text as any).lineThroughDash
padding: theme._vtable.padding,
underlineWidth: theme.text.underline,
lineThroughLineWidth: theme.text.lineThrough
};
}
/**
* 获取所有body单元格数据信息
Expand Down
8 changes: 4 additions & 4 deletions packages/vtable/src/ts-types/style-define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,11 @@ export type CellStyle = {
borderLineWidth: LineWidthsDef;
borderLineDash: LineDashsDef;
underline: boolean;
underlineColor: CanvasRenderingContext2D['strokeStyle'];
// underlineColor: CanvasRenderingContext2D['strokeStyle'];
underlineWidth: number;
underlineDash: number[];
// underlineDash: number[];
lineThrough: boolean;
lineThroughColor: CanvasRenderingContext2D['strokeStyle'];
lineThroughDash: number[];
// lineThroughColor: CanvasRenderingContext2D['strokeStyle'];
// lineThroughDash: number[];
lineThroughLineWidth: number;
};

0 comments on commit 57b117a

Please sign in to comment.