@@ -6,15 +6,18 @@ import { filterEmpty } from '../_util/props-util';
6
6
import initDefaultProps from '../_util/props-util/initDefaultProps' ;
7
7
import TimelineItem from './TimelineItem' ;
8
8
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined' ;
9
- import { tuple } from '../_util/type' ;
9
+ import { tuple , booleanType } from '../_util/type' ;
10
10
import useConfigInject from '../config-provider/hooks/useConfigInject' ;
11
11
12
+ // CSSINJS
13
+ import useStyle from './style' ;
14
+
12
15
export const timelineProps = ( ) => ( {
13
16
prefixCls : String ,
14
17
/** 指定最后一个幽灵节点是否存在或内容 */
15
18
pending : PropTypes . any ,
16
19
pendingDot : PropTypes . any ,
17
- reverse : { type : Boolean , default : undefined } ,
20
+ reverse : booleanType ( ) ,
18
21
mode : PropTypes . oneOf ( tuple ( 'left' , 'alternate' , 'right' , '' ) ) ,
19
22
} ) ;
20
23
@@ -23,13 +26,18 @@ export type TimelineProps = Partial<ExtractPropTypes<ReturnType<typeof timelineP
23
26
export default defineComponent ( {
24
27
compatConfig : { MODE : 3 } ,
25
28
name : 'ATimeline' ,
29
+ inheritAttrs : false ,
26
30
props : initDefaultProps ( timelineProps ( ) , {
27
31
reverse : false ,
28
32
mode : '' ,
29
33
} ) ,
30
34
slots : [ 'pending' , 'pendingDot' ] ,
31
- setup ( props , { slots } ) {
35
+ setup ( props , { slots, attrs } ) {
32
36
const { prefixCls, direction } = useConfigInject ( 'timeline' , props ) ;
37
+
38
+ // style
39
+ const [ wrapSSR , hashId ] = useStyle ( prefixCls ) ;
40
+
33
41
const getPositionCls = ( ele , idx : number ) => {
34
42
const eleProps = ele . props || { } ;
35
43
if ( props . mode === 'alternate' ) {
@@ -80,14 +88,23 @@ export default defineComponent({
80
88
const hasLabelItem = timeLineItems . some (
81
89
item => ! ! ( item . props ?. label || item . children ?. label ) ,
82
90
) ;
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
+ ) ;
91
108
} ;
92
109
} ,
93
110
} ) ;
0 commit comments