44 * use custom animation Globally at GlobalStyle.ts
55 */
66
7- import { FC , ReactNode , useState , useRef , memo } from 'react'
7+ import { FC , useState , useRef , memo } from 'react'
88import { hideAll } from 'tippy.js'
99
10- import type { TTooltipPlacement } from '@/spec'
11-
1210import css from '@/utils/css'
1311import { buildLog } from '@/utils/logger'
1412import { isString } from '@/utils/validator'
1513import { isDescendant } from '@/utils/dom'
1614
1715import useOutsideClick from '@/hooks/useOutsideClick'
1816
17+ import type { TProps } from './index'
1918import ConfirmFooter from './ConfirmFooter'
2019import { FOOTER_BEHAVIOR } from './constant'
2120
@@ -32,39 +31,6 @@ import {
3231/* eslint-disable-next-line */
3332const log = buildLog ( 'c:Tooltip:index' )
3433
35- type TProps = {
36- children : ReactNode
37- content : string | ReactNode
38- placement ?: TTooltipPlacement
39- // more options see: https://atomiks.github.io/tippyjs/all-options/
40- delay ?: number
41- duration ?: number
42- trigger ?: 'mouseenter focus' | 'click'
43- hideOnClick ?: boolean
44- noPadding ?: boolean
45- showArrow ?: boolean
46- behavior ?: 'default' | 'confirm' | 'delete-confirm' | 'add'
47- // currently only for AvatarsRow, it will collapse the height
48- // for same reason, figure out later
49- contentHeight ?: string
50-
51- /**
52- * z-index is a magic number for IconSwitcher's mask situation,
53- * DO NOT USE unless you know what you are doing
54- * 在类似 IconSwitcher 的场景下(有一个基于 positon: absolute 的滑动遮罩)的场景下,需要将外层
55- * 的 ChildrenWrapper z-index 置为 1, 否则滑动遮罩会在最外面。
56- *
57- * 理论上 zIndex 一直设置为 1,也没问题,但是会导致某些使用了 Tooltip 的地方有严重的粘滞感,比如 “CopyRight” 那里。
58- * 暂时没有精力看 Tippy 的具体实现,小心使用。
59- */
60- forceZIndex ?: boolean
61- interactive ?: boolean
62-
63- onShow ?: ( ) => void
64- onHide ?: ( ) => void
65- onConfirm ?: ( ) => void
66- }
67-
6834const Tooltip : FC < TProps > = ( {
6935 children,
7036 noPadding = false ,
@@ -73,6 +39,7 @@ const Tooltip: FC<TProps> = ({
7339 onShow,
7440 placement = 'top' ,
7541 delay = 0 ,
42+ offset = [ 5 , 5 ] ,
7643 duration = 0 ,
7744 content,
7845 hideOnClick = true ,
@@ -149,7 +116,8 @@ const Tooltip: FC<TProps> = ({
149116 zIndex : css . zIndex . popover ,
150117 active : true ,
151118 delay : [ delay , 0 ] as [ number , number ] ,
152- offset : [ 5 , 5 ] as [ number , number ] ,
119+ offset,
120+ // offset: [0, -8] as [number, number],
153121 duration,
154122 trigger,
155123 // see https://github.com/atomiks/tippyjs/issues/751#issuecomment-611979594 for detail
0 commit comments