From b77ecaaefe6d5c1351b9368521fb6bbcf781b0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=8F=8E=EF=B8=8F=20Yumo?= Date: Tue, 7 Jan 2025 16:56:51 +0800 Subject: [PATCH] refactor: ts --- components/bubble/Bubble.tsx | 8 ++------ components/bubble/demo/gpt-vis.tsx | 4 +--- components/bubble/demo/markdown.tsx | 2 +- components/bubble/interface.ts | 6 +++--- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/components/bubble/Bubble.tsx b/components/bubble/Bubble.tsx index 337dda44..48285161 100644 --- a/components/bubble/Bubble.tsx +++ b/components/bubble/Bubble.tsx @@ -6,7 +6,7 @@ import useXComponentConfig from '../_util/hooks/use-x-component-config'; import { useXProviderContext } from '../x-provider'; import useTypedEffect from './hooks/useTypedEffect'; import useTypingConfig from './hooks/useTypingConfig'; -import type { BubbleContentType, BubbleProps } from './interface'; +import type { BubbleProps } from './interface'; import Loading from './loading'; import useStyle from './style'; @@ -213,14 +213,10 @@ const Bubble: React.ForwardRefRenderFunction = (props, r ); }; -type ForwardBubbleType = ( - props: BubbleProps & { ref?: React.Ref }, -) => React.ReactElement; - const ForwardBubble = React.forwardRef(Bubble); if (process.env.NODE_ENV !== 'production') { ForwardBubble.displayName = 'Bubble'; } -export default ForwardBubble as ForwardBubbleType; +export default ForwardBubble; diff --git a/components/bubble/demo/gpt-vis.tsx b/components/bubble/demo/gpt-vis.tsx index 694df5ae..3a6c3846 100644 --- a/components/bubble/demo/gpt-vis.tsx +++ b/components/bubble/demo/gpt-vis.tsx @@ -20,9 +20,7 @@ Here’s a visualization of Haidilao's food delivery revenue from 2013 to 2022. \`\`\` `; -const RenderMarkdown: BubbleProps['messageRender'] = (content) => ( - {content} -); +const RenderMarkdown: BubbleProps['messageRender'] = (content) => {content}; const App = () => { const [rerenderKey, setRerenderKey] = React.useState(0); diff --git a/components/bubble/demo/markdown.tsx b/components/bubble/demo/markdown.tsx index f7736dee..4d4e01c7 100644 --- a/components/bubble/demo/markdown.tsx +++ b/components/bubble/demo/markdown.tsx @@ -14,7 +14,7 @@ const text = ` Link: [Ant Design X](https://x.ant.design) `.trim(); -const renderMarkdown: BubbleProps['messageRender'] = (content) => ( +const renderMarkdown: BubbleProps['messageRender'] = (content) => ( {/* biome-ignore lint/security/noDangerouslySetInnerHtml: used in demo */}
diff --git a/components/bubble/interface.ts b/components/bubble/interface.ts index cb9a170c..844b83fa 100644 --- a/components/bubble/interface.ts +++ b/components/bubble/interface.ts @@ -20,7 +20,7 @@ type SemanticType = 'avatar' | 'content' | 'header' | 'footer'; export type BubbleContentType = React.ReactNode | AnyObject; -export interface BubbleProps +export interface BubbleProps extends Omit, 'content'> { prefixCls?: string; rootClassName?: string; @@ -30,8 +30,8 @@ export interface BubbleProps placement?: 'start' | 'end'; loading?: boolean; typing?: boolean | TypingOption; - content?: T; - messageRender?: (content: T) => React.ReactNode; + content?: BubbleContentType; + messageRender?: (content: ContentType) => React.ReactNode; loadingRender?: () => React.ReactNode; variant?: 'filled' | 'borderless' | 'outlined' | 'shadow'; shape?: 'round' | 'corner';