1
+ import { inject , cloneVNode } from 'vue' ;
1
2
import classNames from 'classnames' ;
2
3
import PropTypes from '../_util/vue-types' ;
3
4
import {
4
5
getOptionProps ,
5
6
getPropsData ,
6
7
initDefaultProps ,
7
8
filterEmpty ,
8
- getComponentFromProp ,
9
- getListeners ,
9
+ getComponent ,
10
10
} from '../_util/props-util' ;
11
- import { cloneElement } from '../_util/vnode' ;
12
11
import TimelineItem from './TimelineItem' ;
13
12
import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined' ;
14
13
import { ConfigConsumerProps } from '../config-provider' ;
@@ -28,23 +27,26 @@ export default {
28
27
reverse : false ,
29
28
mode : '' ,
30
29
} ) ,
31
- inject : {
32
- configProvider : { default : ( ) => ConfigConsumerProps } ,
30
+ setup ( ) {
31
+ const configProvider = inject ( 'configProvider' , ConfigConsumerProps ) ;
32
+ return {
33
+ configProvider,
34
+ } ;
33
35
} ,
34
36
render ( ) {
35
37
const { prefixCls : customizePrefixCls , reverse, mode, ...restProps } = getOptionProps ( this ) ;
36
38
const getPrefixCls = this . configProvider . getPrefixCls ;
37
39
const prefixCls = getPrefixCls ( 'timeline' , customizePrefixCls ) ;
38
40
39
- const pendingDot = getComponentFromProp ( this , 'pendingDot' ) ;
40
- const pending = getComponentFromProp ( this , 'pending' ) ;
41
+ const pendingDot = getComponent ( this , 'pendingDot' ) ;
42
+ const pending = getComponent ( this , 'pending' ) ;
41
43
const pendingNode = typeof pending === 'boolean' ? null : pending ;
42
44
const classString = classNames ( prefixCls , {
43
45
[ `${ prefixCls } -pending` ] : ! ! pending ,
44
46
[ `${ prefixCls } -reverse` ] : ! ! reverse ,
45
47
[ `${ prefixCls } -${ mode } ` ] : ! ! mode ,
46
48
} ) ;
47
- const children = filterEmpty ( this . $slots . default ) ;
49
+ const children = filterEmpty ( this . $slots . default && this . $slots . default ( ) ) ;
48
50
// // Remove falsy items
49
51
// const falsylessItems = filterEmpty(this.$slots.default)
50
52
// const items = falsylessItems.map((item, idx) => {
@@ -85,7 +87,7 @@ export default {
85
87
const items = truthyItems . map ( ( ele , idx ) => {
86
88
const pendingClass = idx === itemsCount - 2 ? lastCls : '' ;
87
89
const readyClass = idx === itemsCount - 1 ? lastCls : '' ;
88
- return cloneElement ( ele , {
90
+ return cloneVNode ( ele , {
89
91
class : classNames ( [
90
92
! reverse && ! ! pending ? pendingClass : readyClass ,
91
93
getPositionCls ( ele , idx ) ,
@@ -98,7 +100,6 @@ export default {
98
100
...restProps ,
99
101
} ,
100
102
class : classString ,
101
- on : getListeners ( this ) ,
102
103
} ;
103
104
return < ul { ...timelineProps } > { items } </ ul > ;
104
105
} ,
0 commit comments