From f2b44477e9f020fb6098007474d4f6393c46d339 Mon Sep 17 00:00:00 2001 From: Rui-Sun Date: Fri, 22 Nov 2024 15:53:29 +0800 Subject: [PATCH] feat: add position in tooltip config #2869 --- .../vtable/feat-tooltip-position_2024-11-22-07-21.json | 10 ++++++++++ packages/vtable/examples/interactive/tooltip.ts | 3 ++- .../vtable/src/components/tooltip/TooltipHandler.ts | 6 +++--- packages/vtable/src/core/BaseTable.ts | 9 ++++++--- packages/vtable/src/ts-types/base-table.ts | 5 ++++- 5 files changed, 25 insertions(+), 8 deletions(-) create mode 100644 common/changes/@visactor/vtable/feat-tooltip-position_2024-11-22-07-21.json diff --git a/common/changes/@visactor/vtable/feat-tooltip-position_2024-11-22-07-21.json b/common/changes/@visactor/vtable/feat-tooltip-position_2024-11-22-07-21.json new file mode 100644 index 000000000..507943888 --- /dev/null +++ b/common/changes/@visactor/vtable/feat-tooltip-position_2024-11-22-07-21.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@visactor/vtable", + "comment": "feat: add position in tooltip config #2869", + "type": "none" + } + ], + "packageName": "@visactor/vtable" +} \ No newline at end of file diff --git a/packages/vtable/examples/interactive/tooltip.ts b/packages/vtable/examples/interactive/tooltip.ts index 5c7518d7e..30295137f 100644 --- a/packages/vtable/examples/interactive/tooltip.ts +++ b/packages/vtable/examples/interactive/tooltip.ts @@ -91,7 +91,8 @@ export function createTable() { tooltip: { renderMode: 'html', isShowOverflowTextTooltip: true, - overflowTextTooltipDisappearDelay: 1000 + overflowTextTooltipDisappearDelay: 1000, + position: VTable.TYPES.Placement.top } }; diff --git a/packages/vtable/src/components/tooltip/TooltipHandler.ts b/packages/vtable/src/components/tooltip/TooltipHandler.ts index e3185960a..451eac637 100644 --- a/packages/vtable/src/components/tooltip/TooltipHandler.ts +++ b/packages/vtable/src/components/tooltip/TooltipHandler.ts @@ -1,5 +1,5 @@ import type { CellRange, RectProps } from '../../ts-types'; -import { Placement } from '../../ts-types'; +import type { Placement } from '../../ts-types'; import type { BaseTooltip } from './BaseTooltip'; import { BubbleTooltip } from './Tooltip'; import { cellInRange } from '../../tools/helper'; @@ -196,7 +196,7 @@ export class TooltipHandler { tooltipOption = { content: headerDescription, referencePosition: { - placement: Placement.bottom, + placement: table.internalProps.tooltip.position, rect }, disappearDelay: table.internalProps.tooltip.overflowTextTooltipDisappearDelay ?? 0, @@ -216,7 +216,7 @@ export class TooltipHandler { ${overflowText}` : overflowText, referencePosition: { - placement: Placement.bottom, + placement: table.internalProps.tooltip.position, rect }, disappearDelay: table.internalProps.tooltip.overflowTextTooltipDisappearDelay ?? 0, diff --git a/packages/vtable/src/core/BaseTable.ts b/packages/vtable/src/core/BaseTable.ts index aca3e2799..db4c69450 100644 --- a/packages/vtable/src/core/BaseTable.ts +++ b/packages/vtable/src/core/BaseTable.ts @@ -35,7 +35,8 @@ import { type LayoutObjectId, type HeightModeDef, type ITableThemeDefine, - InteractionState + InteractionState, + Placement } from '../ts-types'; import type { AnyFunction, @@ -461,7 +462,8 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { parentElement: this.getElement(), renderMode: 'html', isShowOverflowTextTooltip: false, - confine: true + confine: true, + position: Placement.bottom }, options.tooltip ); @@ -2375,7 +2377,8 @@ export abstract class BaseTable extends EventTarget implements BaseTableAPI { parentElement: this.getElement(), renderMode: 'html', isShowOverflowTextTooltip: false, - confine: true + confine: true, + position: Placement.bottom }, options.tooltip ); diff --git a/packages/vtable/src/ts-types/base-table.ts b/packages/vtable/src/ts-types/base-table.ts index 7d3fad6b7..02d9c6031 100644 --- a/packages/vtable/src/ts-types/base-table.ts +++ b/packages/vtable/src/ts-types/base-table.ts @@ -71,7 +71,8 @@ import type { HeightAdaptiveModeDef, ColumnInfo, RowInfo, - CellAddressWithBound + CellAddressWithBound, + Placement } from '.'; import type { TooltipOptions } from './tooltip'; import type { IWrapTextGraphicAttribute } from '../scenegraph/graphic/text'; @@ -211,6 +212,7 @@ export interface IBaseTableProtected { overflowTextTooltipDisappearDelay?: number; /** 弹框是否需要限定在表格区域内 */ confine: boolean; + position: Placement; }; dataSourceEventIds?: EventListenerId[]; @@ -402,6 +404,7 @@ export interface BaseTableConstructorOptions { overflowTextTooltipDisappearDelay?: number; /** 是否将 tooltip 框限制在画布区域内,默认开启。针对renderMode:"html"有效 */ confine?: boolean; + position?: Placement; }; /** * Theme