From 1c8ff6769e5fe458ad4aab7f1cd84985e0a8b9ae Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Tue, 28 Nov 2023 11:13:56 +0800 Subject: [PATCH 1/2] =?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) From faa5d6e9b28278d0e53ff9c2c00b63909a39c8c0 Mon Sep 17 00:00:00 2001 From: zhouyun1 Date: Tue, 28 Nov 2023 11:18:31 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat(tag):=20=E5=A2=9E=E5=8A=A0=20tooltipPr?= =?UTF-8?q?ops=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/eighty-moons-rest.md | 5 +++++ .changeset/slow-tables-guess.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/eighty-moons-rest.md create mode 100644 .changeset/slow-tables-guess.md diff --git a/.changeset/eighty-moons-rest.md b/.changeset/eighty-moons-rest.md new file mode 100644 index 000000000..b83bae4ee --- /dev/null +++ b/.changeset/eighty-moons-rest.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/hiui": patch +--- + +feat(tag): 增加 tooltipProps 参数 diff --git a/.changeset/slow-tables-guess.md b/.changeset/slow-tables-guess.md new file mode 100644 index 000000000..81c49874f --- /dev/null +++ b/.changeset/slow-tables-guess.md @@ -0,0 +1,5 @@ +--- +"@hi-ui/tag": minor +--- + +feat: 增加 tooltipProps 参数