Skip to content

Commit

Permalink
feat: add enum in textStick config
Browse files Browse the repository at this point in the history
  • Loading branch information
Rui-Sun committed Aug 6, 2024
1 parent 6b517da commit 017cfa3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "feat: add enum in textStick config",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}
14 changes: 9 additions & 5 deletions packages/vtable/src/scenegraph/stick-text/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function handleTextStick(table: BaseTableAPI) {
}
[colStart, colEnd].forEach((col: number) => {
const style = table._getCellStyle(col, row);
if (style?.textStick) {
if (style?.textStick && style?.textStick !== 'vertical') {
const cellGroup = table.scenegraph.getCell(col, row);
// adjust cell Horizontal
adjustCellContentHorizontalLayout(
Expand All @@ -69,7 +69,11 @@ export function handleTextStick(table: BaseTableAPI) {
}
[rowStart, rowEnd].forEach((row: number) => {
const style = table._getCellStyle(col, row);
if (style?.textStick && (table.internalProps.layoutMap as PivotHeaderLayoutMap).rowHierarchyType !== 'tree') {
if (
style?.textStick &&
(table.internalProps.layoutMap as PivotHeaderLayoutMap).rowHierarchyType !== 'tree' &&
style?.textStick !== 'horizontal'
) {
const cellGroup = table.scenegraph.getCell(col, row);
// adjust cell vertical
adjustCellContentVerticalLayout(
Expand All @@ -91,7 +95,7 @@ export function handleTextStick(table: BaseTableAPI) {
}
[rowStart, rowEnd].forEach((row: number) => {
const style = table._getCellStyle(col, row);
if (style?.textStick) {
if (style?.textStick && style?.textStick !== 'horizontal') {
const cellGroup = table.scenegraph.getCell(col, row);
// adjust cell vertical
adjustCellContentVerticalLayout(
Expand All @@ -105,13 +109,13 @@ export function handleTextStick(table: BaseTableAPI) {
}
});
}
for (let row = rowStart; row < rowEnd; row++) {
for (let row = rowStart; row <= rowEnd; row++) {
if (colEnd < colStart) {
break;
}
[colStart, colEnd].forEach((col: number) => {
const style = table._getCellStyle(col, row);
if (table._getCellStyle(col, row)?.textStick) {
if (style?.textStick && style?.textStick !== 'vertical') {
const cellGroup = table.scenegraph.getCell(col, row);
// adjust cell Horizontal
adjustCellContentHorizontalLayout(
Expand Down
4 changes: 2 additions & 2 deletions packages/vtable/src/ts-types/column/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export interface IStyleOption {
// dropDownHoverIcon?: IconPropertyDefine;
cursor?: CursorPropertyDefine;

textStick?: boolean;
textStick?: boolean | 'vertical' | 'horizontal';
textStickBaseOnAlign?: boolean;

marked?: MarkedPropertyDefine;
Expand Down Expand Up @@ -121,7 +121,7 @@ export type ColumnStyleOption =
| ((styleArg: StylePropertyFunctionArg) => IStyleOption | ITextStyleOption | IImageStyleOption);

export type HeaderStyleOption =
| (IStyleOption & { textStick?: boolean }) //表头可以配置吸附
| (IStyleOption & { textStick?: boolean | 'vertical' | 'horizontal' }) //表头可以配置吸附
| ITextStyleOption
| IImageStyleOption
// | ISortHeaderStyleOption
Expand Down

0 comments on commit 017cfa3

Please sign in to comment.