@tiny-codes/react-easy 1.6.0 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,24 @@
2
2
 
3
3
  # Changelog
4
4
 
5
+ ## 1.6.3
6
+
7
+ 2026-1-2
8
+
9
+ ### Bug Fixes
10
+
11
+ - **withEllipsisTypography**
12
+
13
+ - 🐞 Fix Tooltip not accepting custom `ellipsis.tooltip` props issue.
14
+
15
+ ## 1.6.1
16
+
17
+ 2026-1-1
18
+
19
+ ### Features
20
+
21
+ - 🛠️ update EllipsisTypography components for better generic type support.
22
+
5
23
  ## 1.6.0
6
24
 
7
25
  2026-1-1
@@ -15,5 +15,5 @@ export type EllipsisParagraphProps = MakeEllipsisTypographyProps<ParagraphProps>
15
15
  * 2. 设置 `ellipsis.tooltip` 属性为 `true`
16
16
  * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`
17
17
  */
18
- declare const EllipsisParagraph: (props: MakeEllipsisTypographyProps<ParagraphProps | import("antd/es/typography/Text").TextProps | import("antd/es/typography/Title").TitleProps>) => import("react/jsx-runtime").JSX.Element;
18
+ declare const EllipsisParagraph: (props: MakeEllipsisTypographyProps<ParagraphProps>) => import("react/jsx-runtime").JSX.Element;
19
19
  export default EllipsisParagraph;
@@ -1 +1 @@
1
- {"version":3,"names":["Typography","withEllipsisTypography","EllipsisParagraph","Paragraph"],"sources":["../../../src/components/EllipsisTypography/EllipsisParagraph.tsx"],"sourcesContent":["import { Typography } from 'antd';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisParagraphProps = MakeEllipsisTypographyProps<ParagraphProps>;\n\n/**\n * - **EN:** A paragraph component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的段落组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisParagraph = withEllipsisTypography(Typography.Paragraph);\n\nexport default EllipsisParagraph;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,MAAM;AAEjC,OAAOC,sBAAsB;AAI7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,iBAAiB,GAAGD,sBAAsB,CAACD,UAAU,CAACG,SAAS,CAAC;AAEtE,eAAeD,iBAAiB"}
1
+ {"version":3,"names":["Typography","withEllipsisTypography","EllipsisParagraph","Paragraph"],"sources":["../../../src/components/EllipsisTypography/EllipsisParagraph.tsx"],"sourcesContent":["import { Typography } from 'antd';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisParagraphProps = MakeEllipsisTypographyProps<ParagraphProps>;\n\n/**\n * - **EN:** A paragraph component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的段落组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisParagraph = withEllipsisTypography<ParagraphProps>(Typography.Paragraph);\n\nexport default EllipsisParagraph;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,MAAM;AAEjC,OAAOC,sBAAsB;AAI7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,iBAAiB,GAAGD,sBAAsB,CAAiBD,UAAU,CAACG,SAAS,CAAC;AAEtF,eAAeD,iBAAiB"}
@@ -15,5 +15,5 @@ export type EllipsisTextProps = MakeEllipsisTypographyProps<TextProps>;
15
15
  * 2. 设置 `ellipsis.tooltip` 属性为 `true`
16
16
  * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`
17
17
  */
18
- declare const EllipsisText: (props: MakeEllipsisTypographyProps<import("antd/es/typography/Paragraph").ParagraphProps | TextProps | import("antd/es/typography/Title").TitleProps>) => import("react/jsx-runtime").JSX.Element;
18
+ declare const EllipsisText: (props: MakeEllipsisTypographyProps<TextProps>) => import("react/jsx-runtime").JSX.Element;
19
19
  export default EllipsisText;
@@ -1 +1 @@
1
- {"version":3,"names":["Typography","withEllipsisTypography","EllipsisText","Text"],"sources":["../../../src/components/EllipsisTypography/EllipsisText.tsx"],"sourcesContent":["import { Typography } from 'antd';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisTextProps = MakeEllipsisTypographyProps<TextProps>;\n\n/**\n * - **EN:** A text component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的文本组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisText = withEllipsisTypography(Typography.Text);\n\nexport default EllipsisText;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,MAAM;AAEjC,OAAOC,sBAAsB;AAI7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,YAAY,GAAGD,sBAAsB,CAACD,UAAU,CAACG,IAAI,CAAC;AAE5D,eAAeD,YAAY"}
1
+ {"version":3,"names":["Typography","withEllipsisTypography","EllipsisText","Text"],"sources":["../../../src/components/EllipsisTypography/EllipsisText.tsx"],"sourcesContent":["import { Typography } from 'antd';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisTextProps = MakeEllipsisTypographyProps<TextProps>;\n\n/**\n * - **EN:** A text component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的文本组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisText = withEllipsisTypography<TextProps>(Typography.Text);\n\nexport default EllipsisText;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,MAAM;AAEjC,OAAOC,sBAAsB;AAI7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,YAAY,GAAGD,sBAAsB,CAAYD,UAAU,CAACG,IAAI,CAAC;AAEvE,eAAeD,YAAY"}
@@ -15,5 +15,5 @@ export type EllipsisTitleProps = MakeEllipsisTypographyProps<TitleProps>;
15
15
  * 2. 设置 `ellipsis.tooltip` 属性为 `true`
16
16
  * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`
17
17
  */
18
- declare const EllipsisTitle: (props: MakeEllipsisTypographyProps<import("antd/es/typography/Paragraph").ParagraphProps | import("antd/es/typography/Text").TextProps | TitleProps>) => import("react/jsx-runtime").JSX.Element;
18
+ declare const EllipsisTitle: (props: MakeEllipsisTypographyProps<TitleProps>) => import("react/jsx-runtime").JSX.Element;
19
19
  export default EllipsisTitle;
@@ -1 +1 @@
1
- {"version":3,"names":["Typography","withEllipsisTypography","EllipsisTitle","Title"],"sources":["../../../src/components/EllipsisTypography/EllipsisTitle.tsx"],"sourcesContent":["import { Typography } from 'antd';\nimport type { TitleProps } from 'antd/es/typography/Title';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisTitleProps = MakeEllipsisTypographyProps<TitleProps>;\n\n/**\n * - **EN:** A title component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的标题组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisTitle = withEllipsisTypography(Typography.Title);\n\nexport default EllipsisTitle;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,MAAM;AAEjC,OAAOC,sBAAsB;AAI7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,aAAa,GAAGD,sBAAsB,CAACD,UAAU,CAACG,KAAK,CAAC;AAE9D,eAAeD,aAAa"}
1
+ {"version":3,"names":["Typography","withEllipsisTypography","EllipsisTitle","Title"],"sources":["../../../src/components/EllipsisTypography/EllipsisTitle.tsx"],"sourcesContent":["import { Typography } from 'antd';\nimport type { TitleProps } from 'antd/es/typography/Title';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisTitleProps = MakeEllipsisTypographyProps<TitleProps>;\n\n/**\n * - **EN:** A title component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的标题组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisTitle = withEllipsisTypography<TitleProps>(Typography.Title);\n\nexport default EllipsisTitle;\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,MAAM;AAEjC,OAAOC,sBAAsB;AAI7B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,IAAMC,aAAa,GAAGD,sBAAsB,CAAaD,UAAU,CAACG,KAAK,CAAC;AAE1E,eAAeD,aAAa"}
@@ -51,7 +51,7 @@ function withEllipsisTypography(Component) {
51
51
  });
52
52
  }
53
53
  }, [text, isAuto, dom]);
54
- return /*#__PURE__*/_jsx(Tooltip, {
54
+ return /*#__PURE__*/_jsx(Tooltip, _objectSpread(_objectSpread({}, ellipsis === null || ellipsis === void 0 ? void 0 : ellipsis.tooltip), {}, {
55
55
  title: tooltipTitle,
56
56
  children: /*#__PURE__*/_jsx(Component, _objectSpread(_objectSpread({
57
57
  ref: setDom
@@ -68,7 +68,7 @@ function withEllipsisTypography(Component) {
68
68
  }) : ellipsis,
69
69
  children: text
70
70
  }))
71
- });
71
+ }));
72
72
  };
73
73
  }
74
74
  export default withEllipsisTypography;
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useMemo","useState","Tooltip","jsx","_jsx","withEllipsisTypography","Component","EllipsisText","props","ellipsis","text","rest","_objectWithoutProperties","_excluded","_useState","_useState2","_slicedToArray","isEllipsis","setIsEllipsis","_useState3","_useState4","dom","setDom","isAutoEllipsis","isAutoTooltip","_typeof","tooltip","isAutoTooltipTitle","title","isAuto","tooltipTitle","undefined","Promise","resolve","then","scrollWidth","clientWidth","scrollHeight","clientHeight","children","_objectSpread","ref"],"sources":["../../../src/components/EllipsisTypography/withEllipsisTypography.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport type { TooltipProps } from 'antd';\nimport { Tooltip } from 'antd';\nimport type { EllipsisConfig } from 'antd/es/typography/Base';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport type { TitleProps } from 'antd/es/typography/Title';\n\nfunction withEllipsisTypography<T extends TextProps | ParagraphProps | TitleProps>(\n Component: ComponentType<MakeEllipsisTypographyProps<T>>\n) {\n return function EllipsisText(props: MakeEllipsisTypographyProps<T>) {\n const { ellipsis, text, ...rest } = props;\n const [isEllipsis, setIsEllipsis] = useState(false);\n const [dom, setDom] = useState<HTMLElement | null>(null);\n const isAutoEllipsis = useMemo(() => ellipsis === true, [ellipsis]);\n const isAutoTooltip = useMemo(() => typeof ellipsis === 'object' && ellipsis.tooltip === true, [ellipsis]);\n const isAutoTooltipTitle = useMemo(\n () =>\n typeof ellipsis === 'object' &&\n ellipsis.tooltip &&\n typeof ellipsis.tooltip === 'object' &&\n 'title' in ellipsis.tooltip &&\n ellipsis.tooltip.title === true,\n [ellipsis]\n );\n const isAuto = useMemo(\n () => isAutoEllipsis || isAutoTooltip || isAutoTooltipTitle,\n [isAutoEllipsis, isAutoTooltip, isAutoTooltipTitle]\n );\n const tooltipTitle = useMemo(() => (isEllipsis ? text : undefined), [isEllipsis, text]);\n\n useEffect(() => {\n if (dom && isAuto) {\n Promise.resolve().then(() => {\n setIsEllipsis(dom.scrollWidth > dom.clientWidth || dom.scrollHeight > dom.clientHeight);\n });\n }\n }, [text, isAuto, dom]);\n\n return (\n <Tooltip title={tooltipTitle}>\n <Component\n ref={setDom}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(rest as any)}\n ellipsis={\n isAutoEllipsis\n ? { tooltip: undefined }\n : isAutoTooltip\n ? {\n ...(ellipsis as EllipsisConfig),\n tooltip: undefined,\n }\n : isAutoTooltipTitle\n ? {\n ...(ellipsis as EllipsisConfig),\n tooltip: {\n ...((ellipsis as EllipsisConfig)?.tooltip as TooltipProps),\n title: undefined,\n },\n }\n : ellipsis\n }\n >\n {text}\n </Component>\n </Tooltip>\n );\n };\n}\n\nexport type MakeEllipsisTypographyProps<T> = Omit<T, 'children'> & {\n text: string | undefined;\n};\n\nexport default withEllipsisTypography;\n"],"mappings":"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"}
1
+ {"version":3,"names":["useEffect","useMemo","useState","Tooltip","jsx","_jsx","withEllipsisTypography","Component","EllipsisText","props","ellipsis","text","rest","_objectWithoutProperties","_excluded","_useState","_useState2","_slicedToArray","isEllipsis","setIsEllipsis","_useState3","_useState4","dom","setDom","isAutoEllipsis","isAutoTooltip","_typeof","tooltip","isAutoTooltipTitle","title","isAuto","tooltipTitle","undefined","Promise","resolve","then","scrollWidth","clientWidth","scrollHeight","clientHeight","_objectSpread","children","ref"],"sources":["../../../src/components/EllipsisTypography/withEllipsisTypography.tsx"],"sourcesContent":["import type { ComponentType } from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport type { TooltipProps } from 'antd';\nimport { Tooltip } from 'antd';\nimport type { EllipsisConfig } from 'antd/es/typography/Base';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport type { TitleProps } from 'antd/es/typography/Title';\n\nfunction withEllipsisTypography<T extends TextProps | ParagraphProps | TitleProps>(\n Component: ComponentType<MakeEllipsisTypographyProps<T>>\n) {\n return function EllipsisText(props: MakeEllipsisTypographyProps<T>) {\n const { ellipsis, text, ...rest } = props;\n const [isEllipsis, setIsEllipsis] = useState(false);\n const [dom, setDom] = useState<HTMLElement | null>(null);\n const isAutoEllipsis = useMemo(() => ellipsis === true, [ellipsis]);\n const isAutoTooltip = useMemo(() => typeof ellipsis === 'object' && ellipsis.tooltip === true, [ellipsis]);\n const isAutoTooltipTitle = useMemo(\n () =>\n typeof ellipsis === 'object' &&\n ellipsis.tooltip &&\n typeof ellipsis.tooltip === 'object' &&\n 'title' in ellipsis.tooltip &&\n ellipsis.tooltip.title === true,\n [ellipsis]\n );\n const isAuto = useMemo(\n () => isAutoEllipsis || isAutoTooltip || isAutoTooltipTitle,\n [isAutoEllipsis, isAutoTooltip, isAutoTooltipTitle]\n );\n const tooltipTitle = useMemo(() => (isEllipsis ? text : undefined), [isEllipsis, text]);\n\n useEffect(() => {\n if (dom && isAuto) {\n Promise.resolve().then(() => {\n setIsEllipsis(dom.scrollWidth > dom.clientWidth || dom.scrollHeight > dom.clientHeight);\n });\n }\n }, [text, isAuto, dom]);\n\n return (\n <Tooltip {...((ellipsis as EllipsisConfig)?.tooltip as TooltipProps)} title={tooltipTitle}>\n <Component\n ref={setDom}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(rest as any)}\n ellipsis={\n isAutoEllipsis\n ? { tooltip: undefined }\n : isAutoTooltip\n ? {\n ...(ellipsis as EllipsisConfig),\n tooltip: undefined,\n }\n : isAutoTooltipTitle\n ? {\n ...(ellipsis as EllipsisConfig),\n tooltip: {\n ...((ellipsis as EllipsisConfig)?.tooltip as TooltipProps),\n title: undefined,\n },\n }\n : ellipsis\n }\n >\n {text}\n </Component>\n </Tooltip>\n );\n };\n}\n\nexport type MakeEllipsisTypographyProps<T> = Omit<T, 'children'> & {\n text: string | undefined;\n};\n\nexport default withEllipsisTypography;\n"],"mappings":"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"}
@@ -15,5 +15,5 @@ export type EllipsisParagraphProps = MakeEllipsisTypographyProps<ParagraphProps>
15
15
  * 2. 设置 `ellipsis.tooltip` 属性为 `true`
16
16
  * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`
17
17
  */
18
- declare const EllipsisParagraph: (props: MakeEllipsisTypographyProps<ParagraphProps | import("antd/es/typography/Text").TextProps | import("antd/es/typography/Title").TitleProps>) => import("react/jsx-runtime").JSX.Element;
18
+ declare const EllipsisParagraph: (props: MakeEllipsisTypographyProps<ParagraphProps>) => import("react/jsx-runtime").JSX.Element;
19
19
  export default EllipsisParagraph;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/EllipsisTypography/EllipsisParagraph.tsx"],
4
- "sourcesContent": ["import { Typography } from 'antd';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisParagraphProps = MakeEllipsisTypographyProps<ParagraphProps>;\n\n/**\n * - **EN:** A paragraph component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的段落组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisParagraph = withEllipsisTypography(Typography.Paragraph);\n\nexport default EllipsisParagraph;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,oCAAyE;AAkBzE,IAAM,wBAAoB,8BAAAA,SAAuB,uBAAW,SAAS;AAErE,IAAO,4BAAQ;",
4
+ "sourcesContent": ["import { Typography } from 'antd';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisParagraphProps = MakeEllipsisTypographyProps<ParagraphProps>;\n\n/**\n * - **EN:** A paragraph component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的段落组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisParagraph = withEllipsisTypography<ParagraphProps>(Typography.Paragraph);\n\nexport default EllipsisParagraph;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,oCAAyE;AAkBzE,IAAM,wBAAoB,8BAAAA,SAAuC,uBAAW,SAAS;AAErF,IAAO,4BAAQ;",
6
6
  "names": ["withEllipsisTypography"]
7
7
  }
@@ -15,5 +15,5 @@ export type EllipsisTextProps = MakeEllipsisTypographyProps<TextProps>;
15
15
  * 2. 设置 `ellipsis.tooltip` 属性为 `true`
16
16
  * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`
17
17
  */
18
- declare const EllipsisText: (props: MakeEllipsisTypographyProps<import("antd/es/typography/Paragraph").ParagraphProps | TextProps | import("antd/es/typography/Title").TitleProps>) => import("react/jsx-runtime").JSX.Element;
18
+ declare const EllipsisText: (props: MakeEllipsisTypographyProps<TextProps>) => import("react/jsx-runtime").JSX.Element;
19
19
  export default EllipsisText;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/EllipsisTypography/EllipsisText.tsx"],
4
- "sourcesContent": ["import { Typography } from 'antd';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisTextProps = MakeEllipsisTypographyProps<TextProps>;\n\n/**\n * - **EN:** A text component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的文本组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisText = withEllipsisTypography(Typography.Text);\n\nexport default EllipsisText;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,oCAAyE;AAkBzE,IAAM,mBAAe,8BAAAA,SAAuB,uBAAW,IAAI;AAE3D,IAAO,uBAAQ;",
4
+ "sourcesContent": ["import { Typography } from 'antd';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisTextProps = MakeEllipsisTypographyProps<TextProps>;\n\n/**\n * - **EN:** A text component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的文本组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisText = withEllipsisTypography<TextProps>(Typography.Text);\n\nexport default EllipsisText;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,oCAAyE;AAkBzE,IAAM,mBAAe,8BAAAA,SAAkC,uBAAW,IAAI;AAEtE,IAAO,uBAAQ;",
6
6
  "names": ["withEllipsisTypography"]
7
7
  }
@@ -15,5 +15,5 @@ export type EllipsisTitleProps = MakeEllipsisTypographyProps<TitleProps>;
15
15
  * 2. 设置 `ellipsis.tooltip` 属性为 `true`
16
16
  * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`
17
17
  */
18
- declare const EllipsisTitle: (props: MakeEllipsisTypographyProps<import("antd/es/typography/Paragraph").ParagraphProps | import("antd/es/typography/Text").TextProps | TitleProps>) => import("react/jsx-runtime").JSX.Element;
18
+ declare const EllipsisTitle: (props: MakeEllipsisTypographyProps<TitleProps>) => import("react/jsx-runtime").JSX.Element;
19
19
  export default EllipsisTitle;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/EllipsisTypography/EllipsisTitle.tsx"],
4
- "sourcesContent": ["import { Typography } from 'antd';\nimport type { TitleProps } from 'antd/es/typography/Title';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisTitleProps = MakeEllipsisTypographyProps<TitleProps>;\n\n/**\n * - **EN:** A title component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的标题组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisTitle = withEllipsisTypography(Typography.Title);\n\nexport default EllipsisTitle;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,oCAAyE;AAkBzE,IAAM,oBAAgB,8BAAAA,SAAuB,uBAAW,KAAK;AAE7D,IAAO,wBAAQ;",
4
+ "sourcesContent": ["import { Typography } from 'antd';\nimport type { TitleProps } from 'antd/es/typography/Title';\nimport withEllipsisTypography, { type MakeEllipsisTypographyProps } from './withEllipsisTypography';\n\nexport type EllipsisTitleProps = MakeEllipsisTypographyProps<TitleProps>;\n\n/**\n * - **EN:** A title component with automatic ellipsis and tooltip functionality that displays a\n * tooltip when the text overflows, and does not display a tooltip when the text does not\n * overflow. The following three methods can enable the automatic tooltip feature:\n *\n * 1. Set the `ellipsis` property to `true`\n * 2. Set the `ellipsis.tooltip` property to `true`\n * 3. Set the `ellipsis.tooltip.title` property to `true`\n * - **CN:** 具有自动省略号和提示功能的标题组件,在文本溢出时显示工具提示,如果文本未溢出,则不显示工具提示。以下三种方式均可开启自动提示功能:\n *\n * 1. 设置 `ellipsis` 属性为 `true`\n * 2. 设置 `ellipsis.tooltip` 属性为 `true`\n * 3. 设置 `ellipsis.tooltip.title` 属性为 `true`\n */\nconst EllipsisTitle = withEllipsisTypography<TitleProps>(Typography.Title);\n\nexport default EllipsisTitle;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA2B;AAE3B,oCAAyE;AAkBzE,IAAM,oBAAgB,8BAAAA,SAAmC,uBAAW,KAAK;AAEzE,IAAO,wBAAQ;",
6
6
  "names": ["withEllipsisTypography"]
7
7
  }
@@ -47,7 +47,7 @@ function withEllipsisTypography(Component) {
47
47
  });
48
48
  }
49
49
  }, [text, isAuto, dom]);
50
- return /* @__PURE__ */ React.createElement(import_antd.Tooltip, { title: tooltipTitle }, /* @__PURE__ */ React.createElement(
50
+ return /* @__PURE__ */ React.createElement(import_antd.Tooltip, { ...ellipsis == null ? void 0 : ellipsis.tooltip, title: tooltipTitle }, /* @__PURE__ */ React.createElement(
51
51
  Component,
52
52
  {
53
53
  ref: setDom,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/EllipsisTypography/withEllipsisTypography.tsx"],
4
- "sourcesContent": ["import type { ComponentType } from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport type { TooltipProps } from 'antd';\nimport { Tooltip } from 'antd';\nimport type { EllipsisConfig } from 'antd/es/typography/Base';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport type { TitleProps } from 'antd/es/typography/Title';\n\nfunction withEllipsisTypography<T extends TextProps | ParagraphProps | TitleProps>(\n Component: ComponentType<MakeEllipsisTypographyProps<T>>\n) {\n return function EllipsisText(props: MakeEllipsisTypographyProps<T>) {\n const { ellipsis, text, ...rest } = props;\n const [isEllipsis, setIsEllipsis] = useState(false);\n const [dom, setDom] = useState<HTMLElement | null>(null);\n const isAutoEllipsis = useMemo(() => ellipsis === true, [ellipsis]);\n const isAutoTooltip = useMemo(() => typeof ellipsis === 'object' && ellipsis.tooltip === true, [ellipsis]);\n const isAutoTooltipTitle = useMemo(\n () =>\n typeof ellipsis === 'object' &&\n ellipsis.tooltip &&\n typeof ellipsis.tooltip === 'object' &&\n 'title' in ellipsis.tooltip &&\n ellipsis.tooltip.title === true,\n [ellipsis]\n );\n const isAuto = useMemo(\n () => isAutoEllipsis || isAutoTooltip || isAutoTooltipTitle,\n [isAutoEllipsis, isAutoTooltip, isAutoTooltipTitle]\n );\n const tooltipTitle = useMemo(() => (isEllipsis ? text : undefined), [isEllipsis, text]);\n\n useEffect(() => {\n if (dom && isAuto) {\n Promise.resolve().then(() => {\n setIsEllipsis(dom.scrollWidth > dom.clientWidth || dom.scrollHeight > dom.clientHeight);\n });\n }\n }, [text, isAuto, dom]);\n\n return (\n <Tooltip title={tooltipTitle}>\n <Component\n ref={setDom}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(rest as any)}\n ellipsis={\n isAutoEllipsis\n ? { tooltip: undefined }\n : isAutoTooltip\n ? {\n ...(ellipsis as EllipsisConfig),\n tooltip: undefined,\n }\n : isAutoTooltipTitle\n ? {\n ...(ellipsis as EllipsisConfig),\n tooltip: {\n ...((ellipsis as EllipsisConfig)?.tooltip as TooltipProps),\n title: undefined,\n },\n }\n : ellipsis\n }\n >\n {text}\n </Component>\n </Tooltip>\n );\n };\n}\n\nexport type MakeEllipsisTypographyProps<T> = Omit<T, 'children'> & {\n text: string | undefined;\n};\n\nexport default withEllipsisTypography;\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA6C;AAE7C,kBAAwB;AAMxB,SAAS,uBACP,WACA;AACA,SAAO,SAAS,aAAa,OAAuC;AAClE,UAAM,EAAE,UAAU,MAAM,GAAG,KAAK,IAAI;AACpC,UAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAClD,UAAM,CAAC,KAAK,MAAM,QAAI,uBAA6B,IAAI;AACvD,UAAM,qBAAiB,sBAAQ,MAAM,aAAa,MAAM,CAAC,QAAQ,CAAC;AAClE,UAAM,oBAAgB,sBAAQ,MAAM,OAAO,aAAa,YAAY,SAAS,YAAY,MAAM,CAAC,QAAQ,CAAC;AACzG,UAAM,yBAAqB;AAAA,MACzB,MACE,OAAO,aAAa,YACpB,SAAS,WACT,OAAO,SAAS,YAAY,YAC5B,WAAW,SAAS,WACpB,SAAS,QAAQ,UAAU;AAAA,MAC7B,CAAC,QAAQ;AAAA,IACX;AACA,UAAM,aAAS;AAAA,MACb,MAAM,kBAAkB,iBAAiB;AAAA,MACzC,CAAC,gBAAgB,eAAe,kBAAkB;AAAA,IACpD;AACA,UAAM,mBAAe,sBAAQ,MAAO,aAAa,OAAO,QAAY,CAAC,YAAY,IAAI,CAAC;AAEtF,gCAAU,MAAM;AACd,UAAI,OAAO,QAAQ;AACjB,gBAAQ,QAAQ,EAAE,KAAK,MAAM;AAC3B,wBAAc,IAAI,cAAc,IAAI,eAAe,IAAI,eAAe,IAAI,YAAY;AAAA,QACxF,CAAC;AAAA,MACH;AAAA,IACF,GAAG,CAAC,MAAM,QAAQ,GAAG,CAAC;AAEtB,WACE,oCAAC,uBAAQ,OAAO,gBACd;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QAEJ,GAAI;AAAA,QACL,UACE,iBACI,EAAE,SAAS,OAAU,IACrB,gBACE;AAAA,UACE,GAAI;AAAA,UACJ,SAAS;AAAA,QACX,IACA,qBACE;AAAA,UACE,GAAI;AAAA,UACJ,SAAS;AAAA,YACP,GAAK,qCAA6B;AAAA,YAClC,OAAO;AAAA,UACT;AAAA,QACF,IACA;AAAA;AAAA,MAGT;AAAA,IACH,CACF;AAAA,EAEJ;AACF;AAMA,IAAO,iCAAQ;",
4
+ "sourcesContent": ["import type { ComponentType } from 'react';\nimport { useEffect, useMemo, useState } from 'react';\nimport type { TooltipProps } from 'antd';\nimport { Tooltip } from 'antd';\nimport type { EllipsisConfig } from 'antd/es/typography/Base';\nimport type { ParagraphProps } from 'antd/es/typography/Paragraph';\nimport type { TextProps } from 'antd/es/typography/Text';\nimport type { TitleProps } from 'antd/es/typography/Title';\n\nfunction withEllipsisTypography<T extends TextProps | ParagraphProps | TitleProps>(\n Component: ComponentType<MakeEllipsisTypographyProps<T>>\n) {\n return function EllipsisText(props: MakeEllipsisTypographyProps<T>) {\n const { ellipsis, text, ...rest } = props;\n const [isEllipsis, setIsEllipsis] = useState(false);\n const [dom, setDom] = useState<HTMLElement | null>(null);\n const isAutoEllipsis = useMemo(() => ellipsis === true, [ellipsis]);\n const isAutoTooltip = useMemo(() => typeof ellipsis === 'object' && ellipsis.tooltip === true, [ellipsis]);\n const isAutoTooltipTitle = useMemo(\n () =>\n typeof ellipsis === 'object' &&\n ellipsis.tooltip &&\n typeof ellipsis.tooltip === 'object' &&\n 'title' in ellipsis.tooltip &&\n ellipsis.tooltip.title === true,\n [ellipsis]\n );\n const isAuto = useMemo(\n () => isAutoEllipsis || isAutoTooltip || isAutoTooltipTitle,\n [isAutoEllipsis, isAutoTooltip, isAutoTooltipTitle]\n );\n const tooltipTitle = useMemo(() => (isEllipsis ? text : undefined), [isEllipsis, text]);\n\n useEffect(() => {\n if (dom && isAuto) {\n Promise.resolve().then(() => {\n setIsEllipsis(dom.scrollWidth > dom.clientWidth || dom.scrollHeight > dom.clientHeight);\n });\n }\n }, [text, isAuto, dom]);\n\n return (\n <Tooltip {...((ellipsis as EllipsisConfig)?.tooltip as TooltipProps)} title={tooltipTitle}>\n <Component\n ref={setDom}\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n {...(rest as any)}\n ellipsis={\n isAutoEllipsis\n ? { tooltip: undefined }\n : isAutoTooltip\n ? {\n ...(ellipsis as EllipsisConfig),\n tooltip: undefined,\n }\n : isAutoTooltipTitle\n ? {\n ...(ellipsis as EllipsisConfig),\n tooltip: {\n ...((ellipsis as EllipsisConfig)?.tooltip as TooltipProps),\n title: undefined,\n },\n }\n : ellipsis\n }\n >\n {text}\n </Component>\n </Tooltip>\n );\n };\n}\n\nexport type MakeEllipsisTypographyProps<T> = Omit<T, 'children'> & {\n text: string | undefined;\n};\n\nexport default withEllipsisTypography;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,mBAA6C;AAE7C,kBAAwB;AAMxB,SAAS,uBACP,WACA;AACA,SAAO,SAAS,aAAa,OAAuC;AAClE,UAAM,EAAE,UAAU,MAAM,GAAG,KAAK,IAAI;AACpC,UAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,KAAK;AAClD,UAAM,CAAC,KAAK,MAAM,QAAI,uBAA6B,IAAI;AACvD,UAAM,qBAAiB,sBAAQ,MAAM,aAAa,MAAM,CAAC,QAAQ,CAAC;AAClE,UAAM,oBAAgB,sBAAQ,MAAM,OAAO,aAAa,YAAY,SAAS,YAAY,MAAM,CAAC,QAAQ,CAAC;AACzG,UAAM,yBAAqB;AAAA,MACzB,MACE,OAAO,aAAa,YACpB,SAAS,WACT,OAAO,SAAS,YAAY,YAC5B,WAAW,SAAS,WACpB,SAAS,QAAQ,UAAU;AAAA,MAC7B,CAAC,QAAQ;AAAA,IACX;AACA,UAAM,aAAS;AAAA,MACb,MAAM,kBAAkB,iBAAiB;AAAA,MACzC,CAAC,gBAAgB,eAAe,kBAAkB;AAAA,IACpD;AACA,UAAM,mBAAe,sBAAQ,MAAO,aAAa,OAAO,QAAY,CAAC,YAAY,IAAI,CAAC;AAEtF,gCAAU,MAAM;AACd,UAAI,OAAO,QAAQ;AACjB,gBAAQ,QAAQ,EAAE,KAAK,MAAM;AAC3B,wBAAc,IAAI,cAAc,IAAI,eAAe,IAAI,eAAe,IAAI,YAAY;AAAA,QACxF,CAAC;AAAA,MACH;AAAA,IACF,GAAG,CAAC,MAAM,QAAQ,GAAG,CAAC;AAEtB,WACE,oCAAC,uBAAS,GAAK,qCAA6B,SAA0B,OAAO,gBAC3E;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QAEJ,GAAI;AAAA,QACL,UACE,iBACI,EAAE,SAAS,OAAU,IACrB,gBACE;AAAA,UACE,GAAI;AAAA,UACJ,SAAS;AAAA,QACX,IACA,qBACE;AAAA,UACE,GAAI;AAAA,UACJ,SAAS;AAAA,YACP,GAAK,qCAA6B;AAAA,YAClC,OAAO;AAAA,UACT;AAAA,QACF,IACA;AAAA;AAAA,MAGT;AAAA,IACH,CACF;AAAA,EAEJ;AACF;AAMA,IAAO,iCAAQ;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiny-codes/react-easy",
3
- "version": "1.6.0",
3
+ "version": "1.6.2",
4
4
  "description": "Simplify React and AntDesign development with practical components and hooks",
5
5
  "keywords": [
6
6
  "react",