feat: isShowOverflowTextTooltip support function

This commit is contained in:
Rui-Sun 2024-11-18 21:52:18 +08:00
parent 72422d2317
commit ed5d72cd66
3 changed files with 18 additions and 3 deletions

View File

@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@visactor/vtable",
"comment": "feat: isShowOverflowTextTooltip support function",
"type": "none"
}
],
"packageName": "@visactor/vtable"
}

View File

@ -8,6 +8,7 @@ import { isMobile } from '../../tools/util';
import type { TooltipOptions } from '../../ts-types/tooltip';
import { TABLE_EVENT_TYPE } from '../../core/TABLE_EVENT_TYPE';
import type { BaseTableAPI } from '../../ts-types/base-table';
import { isFunction } from '@visactor/vutils';
const TOOLTIP_INSTANCE_FACTORY = {
// tooltip(table: BaseTableAPI): BaseTooltip {
// return new Tooltip(table);
@ -201,7 +202,11 @@ export class TooltipHandler {
disappearDelay: table.internalProps.tooltip.overflowTextTooltipDisappearDelay ?? 0,
style: table.theme.tooltipStyle
};
} else if (table.internalProps.tooltip?.isShowOverflowTextTooltip) {
} else if (
(isFunction(table.internalProps.tooltip?.isShowOverflowTextTooltip) &&
table.internalProps.tooltip.isShowOverflowTextTooltip(col, row, table)) ||
table.internalProps.tooltip.isShowOverflowTextTooltip
) {
const overflowText = table.getCellOverflowText(col, row);
const rect = table.getCellRangeRelativeRect({ col, row });
if (overflowText) {

View File

@ -206,7 +206,7 @@ export interface IBaseTableProtected {
parentElement: HTMLElement;
renderMode: 'html' | 'canvas';
/** 代替原来hover:isShowTooltip配置 */
isShowOverflowTextTooltip: boolean;
isShowOverflowTextTooltip: boolean | ((col: number, row: number, table: BaseTableAPI) => boolean);
/** 缩略文字提示框 延迟消失时间 */
overflowTextTooltipDisappearDelay?: number;
/** 弹框是否需要限定在表格区域内 */
@ -397,7 +397,7 @@ export interface BaseTableConstructorOptions {
/** html目前实现较完整 先默认html渲染方式 */
renderMode?: 'html'; // 目前暂不支持canvas方案
/** 是否显示缩略文字提示框。 代替原来hover:isShowTooltip配置 暂时需要将renderMode配置为html才能显示canvas的还未开发*/
isShowOverflowTextTooltip?: boolean;
isShowOverflowTextTooltip?: boolean | ((col: number, row: number, table: BaseTableAPI) => boolean);
/** 缩略文字提示框 延迟消失时间 */
overflowTextTooltipDisappearDelay?: number;
/** 是否将 tooltip 框限制在画布区域内默认开启。针对renderMode:"html"有效 */