From ec63d2b48576b33e7b935a514f4405f72b5ac2c6 Mon Sep 17 00:00:00 2001 From: eternalsky Date: Wed, 31 Jan 2024 14:57:43 +0800 Subject: [PATCH] refactor(Timeline): use assignSubComponent --- components/animate/types.ts | 12 +++++++++++- components/timeline/index.tsx | 11 ++++++++--- components/timeline/view/timeline-item.tsx | 1 - components/timeline/view/timeline.tsx | 2 -- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/components/animate/types.ts b/components/animate/types.ts index 7c2d6619ce..3ee20e378b 100644 --- a/components/animate/types.ts +++ b/components/animate/types.ts @@ -110,7 +110,17 @@ export interface AnimateProps extends React.HTMLAttributes, CommonP /** * @api Animate.Expand */ -export interface ExpandProps { +export interface ExpandProps + extends Omit< + AnimateProps, + | 'animation' + | 'beforeEnter' + | 'onEnter' + | 'afterEnter' + | 'beforeLeave' + | 'onLeave' + | 'afterLeave' + > { /** * 动画 className * @en The animation className diff --git a/components/timeline/index.tsx b/components/timeline/index.tsx index 1f7c868859..70b73ac44a 100644 --- a/components/timeline/index.tsx +++ b/components/timeline/index.tsx @@ -1,6 +1,11 @@ +import { assignSubComponent } from '../util/component'; import Timeline from './view/timeline'; -import type { TimelineProps, ItemProps } from './types'; +import TimelineItem from './view/timeline-item'; -export type { TimelineProps, ItemProps }; +const TimelineWithItem = assignSubComponent(Timeline, { + Item: TimelineItem, +}); -export default Timeline; +export type { TimelineProps, ItemProps } from './types'; + +export default TimelineWithItem; diff --git a/components/timeline/view/timeline-item.tsx b/components/timeline/view/timeline-item.tsx index 59c47caaf5..e579472a04 100644 --- a/components/timeline/view/timeline-item.tsx +++ b/components/timeline/view/timeline-item.tsx @@ -8,7 +8,6 @@ import Button, { type ButtonProps } from '../../button'; import { obj } from '../../util'; import type { ItemProps } from '../types'; -//@ts-expect-error Animate 尚未完成 ts 改造 const { Expand } = Animate; /** Timeline.Item */ class TimelineItem extends Component { diff --git a/components/timeline/view/timeline.tsx b/components/timeline/view/timeline.tsx index d05548b32c..c4eb84fae9 100644 --- a/components/timeline/view/timeline.tsx +++ b/components/timeline/view/timeline.tsx @@ -6,13 +6,11 @@ import { polyfill } from 'react-lifecycles-compat'; import { obj } from '../../util'; import ConfigProvider from '../../config-provider'; import nextLocale from '../../locale/zh-cn'; -import Item from './timeline-item'; import { TimelineProps, TimelineState } from '../types'; /** Timeline */ class Timeline extends Component { static displayName = 'Timeline'; - static Item = Item; static propTypes = { ...ConfigProvider.propTypes, prefix: PropTypes.string,