From a21c1a88c1129e61a94a90abb2ddb19000debd0a Mon Sep 17 00:00:00 2001 From: CodingYingYingYing <37829083+bingling0084@users.noreply.github.com> Date: Tue, 23 Mar 2021 13:32:37 +0800 Subject: [PATCH] fix: Typography.Paragraph\Text\Title ts (#29787) * fix: Typography.Paragraph\Text\Title ts * feat: add doc * feat: title ts * feat: cr * chore: revert * chore: ts * feat: doc/sort & drop onChange --- components/typography/Paragraph.tsx | 4 +++- components/typography/Text.tsx | 1 + components/typography/Title.tsx | 8 +++++++- components/typography/index.en-US.md | 6 +++--- components/typography/index.zh-CN.md | 5 +++-- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/components/typography/Paragraph.tsx b/components/typography/Paragraph.tsx index 1096eaa30e..7ed007e2e3 100644 --- a/components/typography/Paragraph.tsx +++ b/components/typography/Paragraph.tsx @@ -1,7 +1,9 @@ import * as React from 'react'; import Base, { BlockProps } from './Base'; -export interface ParagraphProps extends BlockProps {} +export interface ParagraphProps extends BlockProps { + onClick?: (e?: React.MouseEvent) => void; +} const Paragraph: React.FC = props => ; diff --git a/components/typography/Text.tsx b/components/typography/Text.tsx index 8e225bbcd5..f6ba85c03d 100644 --- a/components/typography/Text.tsx +++ b/components/typography/Text.tsx @@ -5,6 +5,7 @@ import Base, { BlockProps, EllipsisConfig } from './Base'; export interface TextProps extends BlockProps { ellipsis?: boolean | Omit; + onClick?: (e?: React.MouseEvent) => void; } const Text: React.FC = ({ ellipsis, ...restProps }) => { diff --git a/components/typography/Title.tsx b/components/typography/Title.tsx index 11bdc4d34c..12d7708ad6 100644 --- a/components/typography/Title.tsx +++ b/components/typography/Title.tsx @@ -5,7 +5,13 @@ import { tupleNum, Omit } from '../_util/type'; const TITLE_ELE_LIST = tupleNum(1, 2, 3, 4, 5); -export type TitleProps = Omit; +export type TitleProps = Omit< + BlockProps & { + level?: typeof TITLE_ELE_LIST[number]; + onClick?: (e?: React.MouseEvent) => void; + }, + 'strong' +>; const Title: React.FC = props => { const { level = 1, ...restProps } = props; diff --git a/components/typography/index.en-US.md b/components/typography/index.en-US.md index 3880b8357a..616e5cbcff 100644 --- a/components/typography/index.en-US.md +++ b/components/typography/index.en-US.md @@ -27,10 +27,10 @@ Basic text writing, including headings, body text, lists, and more. | ellipsis | Display ellipsis when text overflows | boolean | false | | | keyboard | Keyboard style | boolean | false | 4.3.0 | | mark | Marked style | boolean | false | | +| onClick | Set the handler to handle click event | (event) => void | - | | | strong | Bold style | boolean | false | | | type | Content type | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 | | underline | Underlined style | boolean | false | | -| onChange | Trigger when user edits the content | function(string) | - | | ### Typography.Title @@ -44,9 +44,9 @@ Basic text writing, including headings, body text, lists, and more. | ellipsis | Display ellipsis when text overflows, can configure rows and expandable by using object | boolean \| [ellipsis](#ellipsis) | false | [ellipsis](#ellipsis) | | level | Set content importance. Match with `h1`, `h2`, `h3`, `h4`, `h5` | number: 1, 2, 3, 4, 5 | 1 | 5: 4.6.0 | | mark | Marked style | boolean | false | | +| onClick | Set the handler to handle click event | (event) => void | - | | | type | Content type | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 | | underline | Underlined style | boolean | false | | -| onChange | Trigger when user edits the content | function(string) | - | | ### Typography.Paragraph @@ -59,10 +59,10 @@ Basic text writing, including headings, body text, lists, and more. | editable | If editable. Can control edit state when is object | boolean \| [editable](#editable) | false | [editable](#editable) | | ellipsis | Display ellipsis when text overflows, can configure rows and expandable by using object | boolean \| [ellipsis](#ellipsis) | false | [ellipsis](#ellipsis) | | mark | Marked style | boolean | false | | +| onClick | Set the handler to handle click event | (event) => void | - | | | strong | Bold style | boolean | false | | | type | Content type | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 | | underline | Underlined style | boolean | false | | -| onChange | Trigger when user edits the content | function(string) | - | | ### copyable diff --git a/components/typography/index.zh-CN.md b/components/typography/index.zh-CN.md index 5ccc3b0809..a9a796119b 100644 --- a/components/typography/index.zh-CN.md +++ b/components/typography/index.zh-CN.md @@ -28,6 +28,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg | ellipsis | 自动溢出省略 | boolean | false | | | keyboard | 添加键盘样式 | boolean | false | 4.3.0 | | mark | 添加标记样式 | boolean | false | | +| onClick | 点击 Text 时的回调 | (event) => void | - | | | strong | 是否加粗 | boolean | false | | | type | 文本类型 | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 | | underline | 添加下划线样式 | boolean | false | | @@ -44,9 +45,9 @@ cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg | ellipsis | 自动溢出省略,为对象时可设置省略行数、是否可展开、添加后缀等 | boolean \| [ellipsis](#ellipsis) | false | [ellipsis](#ellipsis) | | level | 重要程度,相当于 `h1`、`h2`、`h3`、`h4`、`h5` | number: 1, 2, 3, 4, 5 | 1 | 5: 4.6.0 | | mark | 添加标记样式 | boolean | false | | +| onClick | 点击 Title 时的回调 | (event) => void | - | | | type | 文本类型 | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 | | underline | 添加下划线样式 | boolean | false | | -| onChange | 当用户提交编辑内容时触发 | function(string) | - | | ### Typography.Paragraph @@ -59,10 +60,10 @@ cover: https://gw.alipayobjects.com/zos/alicdn/GOM1KQ24O/Typography.svg | editable | 是否可编辑,为对象时可对编辑进行控制 | boolean \| [editable](#editable) | false | [editable](#editable) | | ellipsis | 自动溢出省略,为对象时可设置省略行数、是否可展开、添加后缀等 | boolean \| [ellipsis](#ellipsis) | false | [ellipsis](#ellipsis) | | mark | 添加标记样式 | boolean | false | | +| onClick | 点击 Paragraph 时的回调 | (event) => void | - | | | strong | 是否加粗 | boolean | false | | | type | 文本类型 | `secondary` \| `success` \| `warning` \| `danger` | - | success: 4.6.0 | | underline | 添加下划线样式 | boolean | false | | -| onChange | 当用户提交编辑内容时触发 | function(string) | - | | ### copyable