Browse Source

add/fix tooltip align interface (#12354)

* expose align interface

* typescript fix: tooltip 的 align 部分值支持传百分数参数;更新文档
pull/12384/head
Magn Mah 6 years ago
committed by zombieJ
parent
commit
292a18bef0
  1. 1
      components/tooltip/index.en-US.md
  2. 14
      components/tooltip/index.tsx
  3. 1
      components/tooltip/index.zh-CN.md

1
components/tooltip/index.en-US.md

@ -35,6 +35,7 @@ The following APIs are shared by Tooltip, Popconfirm, Popover.
| trigger | Tooltip trigger mode | `hover` \| `focus` \| `click` \| `contextMenu` | `hover` |
| visible | Whether the floating tooltip card is visible or not | boolean | `false` |
| onVisibleChange | Callback executed when visibility of the tooltip card is changed | (visible) => void | - |
| align | this value will be merged into placement's config, please refer to the settings [rc-tooltip](https://github.com/react-component/tooltip) | Object | - |
## Note

14
components/tooltip/index.tsx

@ -15,6 +15,18 @@ export type TooltipPlacement =
export type TooltipTrigger = 'hover' | 'focus' | 'click' | 'contextMenu';
// https://github.com/react-component/tooltip
// https://github.com/yiminghe/dom-align
export interface TooltipAlignConfig {
points?: [string, string],
offset?: [number | string, number | string],
targetOffset?: [number | string, number | string],
overflow?: { adjustX: boolean, adjustY: boolean },
useCssRight?: boolean,
useCssBottom?: boolean,
useCssTransform?: boolean
}
export interface AbstractTooltipProps {
prefixCls?: string;
overlayClassName?: string;
@ -36,6 +48,8 @@ export interface AbstractTooltipProps {
getTooltipContainer?: (triggerNode: Element) => HTMLElement;
getPopupContainer?: (triggerNode: Element) => HTMLElement;
children?: React.ReactNode;
// align is a more higher api
align?: TooltipAlignConfig;
}
export type RenderFunction = () => React.ReactNode;

1
components/tooltip/index.zh-CN.md

@ -37,6 +37,7 @@ title: Tooltip
| trigger | 触发行为,可选 `hover/focus/click/contextMenu` | string | hover |
| visible | 用于手动控制浮层显隐 | boolean | false |
| onVisibleChange | 显示隐藏的回调 | (visible) => void | 无 |
| align | 该值将合并到 placement 的配置中,设置参考 [rc-tooltip](https://github.com/react-component/tooltip) | Object | 无 |
## 注意

Loading…
Cancel
Save