UNPKG

3.79 kBTypeScriptView Raw
1import { SetupContext, RenderFunction, Ref, ComponentPublicInstance } from 'vue'
2import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf, VNodeStyle } from './component'
3
4/* eslint-disable no-use-before-define */
5
6/**
7 * 组件 - 工具提示
8 * @example import { VxeTooltip } from 'vxe-table'
9 */
10export const VxeTooltip: VXEComponent<VxeTooltipProps, VxeTooltipEventProps, VxeTooltipSlots>
11/**
12 * 组件 - 工具提示
13 */
14export const Tooltip: typeof VxeTooltip
15
16export type VxeTooltipInstance = ComponentPublicInstance<VxeTooltipProps, VxeTooltipConstructor>
17
18export interface VxeTooltipConstructor extends VxeComponentBase, VxeTooltipMethods {
19 props: VxeTooltipProps
20 context: SetupContext<VxeTooltipEmits>
21 reactData: TooltipReactData
22 getRefMaps(): TooltipPrivateRef
23 renderVN: RenderFunction
24}
25
26export interface TooltipPrivateRef {
27 refElem: Ref<HTMLDivElement>
28}
29export interface VxeTooltipPrivateRef extends TooltipPrivateRef { }
30
31export interface TooltipReactData {
32 target: HTMLElement | null
33 isUpdate: boolean
34 visible: boolean
35 tipContent: string | number | undefined,
36 tipActive: boolean
37 tipTarget: HTMLElement | null
38 tipZindex: number
39 tipStore: {
40 style: VNodeStyle
41 placement: any
42 arrowStyle: VNodeStyle
43 }
44}
45
46export namespace VxeTooltipPropTypes {
47 export type Size = SizeType
48 export type ModelValue = boolean
49 export type Trigger = 'hover' | 'click' | 'manual' | '' | null
50 export type Theme = string
51 export type Content = string | number
52 export type UseHTML = boolean
53 export type ZIndex = string | number
54 export type PopupClassName = string | ((params: { $tooltip: VxeTooltipConstructor }) => string)
55 export type IsArrow = boolean
56 export type Enterable = boolean
57 export type EnterDelay = number
58 export type LeaveDelay = number
59 export type LeaveMethod = (params: { $event: MouseEvent }) => boolean
60}
61
62export type VxeTooltipProps = {
63 size?: VxeTooltipPropTypes.Size
64 modelValue?: VxeTooltipPropTypes.ModelValue
65 trigger?: VxeTooltipPropTypes.Trigger
66 theme?: VxeTooltipPropTypes.Theme
67 content?: VxeTooltipPropTypes.Content
68 useHTML?: VxeTooltipPropTypes.UseHTML
69 popupClassName?: VxeTooltipPropTypes.PopupClassName
70 zIndex?: VxeTooltipPropTypes.ZIndex
71 isArrow?: VxeTooltipPropTypes.IsArrow
72 enterable?: VxeTooltipPropTypes.Enterable
73 enterDelay?: VxeTooltipPropTypes.EnterDelay
74 leaveDelay?: VxeTooltipPropTypes.LeaveDelay
75 leaveMethod?: VxeTooltipPropTypes.LeaveMethod
76}
77
78export interface TooltipMethods {
79 dispatchEvent(type: ValueOf<VxeTooltipEmits>, params: any, evnt: Event): void
80 /**
81 * 显示
82 * @param target 自定义目标元素
83 * @param content 自定义内容
84 */
85 open(target?: any, content?: VxeTooltipPropTypes.Content): Promise<void>
86 toVisible(target?: HTMLElement, content?: VxeTooltipPropTypes.Content): Promise<void>
87 /**
88 * 隐藏
89 */
90 close(): Promise<any>
91 updatePlacement(): Promise<any>
92 isActived(): boolean
93 setActived(actived: boolean): void
94}
95export interface VxeTooltipMethods extends TooltipMethods { }
96
97export interface TooltipPrivateMethods { }
98export interface VxeTooltipPrivateMethods extends TooltipPrivateMethods { }
99
100export type VxeTooltipEmits = [
101 'update:modelValue'
102]
103
104export namespace VxeTooltipDefines {
105 export interface TooltipEventParams extends VxeEvent {
106 $tooltip: VxeTooltipConstructor
107 }
108}
109
110export type VxeTooltipEventProps = {
111 [key: string]: any
112}
113
114export interface VxeTooltipListeners { }
115
116export namespace VxeTooltipEvents { }
117
118export interface VxeTooltipSlots {
119 /**
120 * 自定义插槽模板
121 */
122 [key: string]: ((params: {
123 [key: string]: any
124 }) => any) | undefined
125}