@@ -6,15 +6,18 @@ import { filterEmpty } from '../_util/props-util';
66import initDefaultProps from '../_util/props-util/initDefaultProps' ;
77import TimelineItem from './TimelineItem' ;
88import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined' ;
9- import { tuple } from '../_util/type' ;
9+ import { tuple , booleanType } from '../_util/type' ;
1010import useConfigInject from '../config-provider/hooks/useConfigInject' ;
1111
12+ // CSSINJS
13+ import useStyle from './style' ;
14+
1215export const timelineProps = ( ) => ( {
1316 prefixCls : String ,
1417 /** 指定最后一个幽灵节点是否存在或内容 */
1518 pending : PropTypes . any ,
1619 pendingDot : PropTypes . any ,
17- reverse : { type : Boolean , default : undefined } ,
20+ reverse : booleanType ( ) ,
1821 mode : PropTypes . oneOf ( tuple ( 'left' , 'alternate' , 'right' , '' ) ) ,
1922} ) ;
2023
@@ -23,13 +26,18 @@ export type TimelineProps = Partial<ExtractPropTypes<ReturnType<typeof timelineP
2326export default defineComponent ( {
2427 compatConfig : { MODE : 3 } ,
2528 name : 'ATimeline' ,
29+ inheritAttrs : false ,
2630 props : initDefaultProps ( timelineProps ( ) , {
2731 reverse : false ,
2832 mode : '' ,
2933 } ) ,
3034 slots : [ 'pending' , 'pendingDot' ] ,
31- setup ( props , { slots } ) {
35+ setup ( props , { slots, attrs } ) {
3236 const { prefixCls, direction } = useConfigInject ( 'timeline' , props ) ;
37+
38+ // style
39+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
40+
3341 const getPositionCls = ( ele , idx : number ) => {
3442 const eleProps = ele . props || { } ;
3543 if ( props . mode === 'alternate' ) {
@@ -80,14 +88,23 @@ export default defineComponent({
8088 const hasLabelItem = timeLineItems . some (
8189 item => ! ! ( item . props ?. label || item . children ?. label ) ,
8290 ) ;
83- const classString = classNames ( prefixCls . value , {
84- [ `${ prefixCls . value } -pending` ] : ! ! pending ,
85- [ `${ prefixCls . value } -reverse` ] : ! ! reverse ,
86- [ `${ prefixCls . value } -${ mode } ` ] : ! ! mode && ! hasLabelItem ,
87- [ `${ prefixCls . value } -label` ] : hasLabelItem ,
88- [ `${ prefixCls . value } -rtl` ] : direction . value === 'rtl' ,
89- } ) ;
90- return < ul class = { classString } > { items } </ ul > ;
91+ const classString = classNames (
92+ prefixCls . value ,
93+ {
94+ [ `${ prefixCls . value } -pending` ] : ! ! pending ,
95+ [ `${ prefixCls . value } -reverse` ] : ! ! reverse ,
96+ [ `${ prefixCls . value } -${ mode } ` ] : ! ! mode && ! hasLabelItem ,
97+ [ `${ prefixCls . value } -label` ] : hasLabelItem ,
98+ [ `${ prefixCls . value } -rtl` ] : direction . value === 'rtl' ,
99+ } ,
100+ attrs . class ,
101+ hashId . value ,
102+ ) ;
103+ return wrapSSR (
104+ < ul { ...attrs } class = { classString } >
105+ { items }
106+ </ ul > ,
107+ ) ;
91108 } ;
92109 } ,
93110} ) ;
0 commit comments