From 1c8ff6769e5fe458ad4aab7f1cd84985e0a8b9ae Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Tue, 28 Nov 2023 11:13:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(tag):=20=E5=A2=9E=E5=8A=A0tooltipProps?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20(#2678)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/ui/tag/src/Tag.tsx | 11 +++++++++-- packages/ui/tag/stories/max-width.stories.tsx | 3 ++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/ui/tag/src/Tag.tsx b/packages/ui/tag/src/Tag.tsx index b4c18fcf5..8cac25150 100644 --- a/packages/ui/tag/src/Tag.tsx +++ b/packages/ui/tag/src/Tag.tsx @@ -2,7 +2,7 @@ import React, { forwardRef, useMemo, useState, useEffect, useRef } from 'react' import { cx, getPrefixCls } from '@hi-ui/classname' import { CloseOutlined } from '@hi-ui/icons' import { __DEV__, invariant } from '@hi-ui/env' -import { Tooltip } from '@hi-ui/tooltip' +import { Tooltip, TooltipProps } from '@hi-ui/tooltip' import { HiBaseHTMLProps } from '@hi-ui/core' const _role = 'tag' @@ -36,6 +36,7 @@ export const Tag = forwardRef( autoEditable = false, maxWidth, render = DEFAULT_RENDER, + tooltipProps, ...rest }, ref @@ -116,6 +117,7 @@ export const Tag = forwardRef( ? { component: Tooltip, componentProps: { + ...tooltipProps, title: render(children as React.ReactText), trigger: 'hover', }, @@ -124,7 +126,7 @@ export const Tag = forwardRef( component: React.Fragment, componentProps: {}, }, - [isShowPopover, children, isInEdit, render] + [isShowPopover, isInEdit, tooltipProps, render, children] ) if (__DEV__) { @@ -244,6 +246,11 @@ export interface TagProps extends HiBaseHTMLProps<'div'> { * @default 0 代表不限制宽度 */ maxWidth?: number + /** + * Tooltip 组件参数设置 + * @private + */ + tooltipProps?: Omit } if (__DEV__) { diff --git a/packages/ui/tag/stories/max-width.stories.tsx b/packages/ui/tag/stories/max-width.stories.tsx index 30587fc89..e45efa240 100644 --- a/packages/ui/tag/stories/max-width.stories.tsx +++ b/packages/ui/tag/stories/max-width.stories.tsx @@ -14,7 +14,8 @@ export const MaxWidth = () => {

Tag MaxWidth

max 240px (placeholder1 placeholder2 placeholder3 placeholder4) - + {/* Tooltip 禁用 portal */} + max 240px (placeholder1 placeholder2 placeholder3 placeholder4)