1
- import { Component , triggerEvent } from '../../src/_util/simply' ;
1
+ import {
2
+ Component ,
3
+ getValueFromProps ,
4
+ triggerEventValues ,
5
+ } from '../../src/_util/simply' ;
2
6
import { ThoughtChainProps } from './props' ;
3
7
4
8
Component (
5
9
ThoughtChainProps ,
6
10
// methods
7
11
{
8
- onContentItemTap ( e ) {
9
- if ( this . props . onContentItemTap ) {
10
- triggerEvent ( this , 'contentItemTap' , e , e ) ;
11
- }
12
+ onContentTap ( e ) {
13
+ triggerEventValues ( this , 'contentTap' , [ e ] , e ) ;
12
14
} ,
13
15
onTitleTap ( e ) {
14
- if ( ! this . props . collapsible ) return ;
16
+ const [ collapsible , onExpand ] = getValueFromProps ( this , [ 'collapsible' , 'onExpand' ] ) ;
17
+ if ( ! collapsible ) return ;
15
18
// 受控模式
16
- if ( this . props . onExpand && this . props . collapsible ?. expandedKeys ) {
17
- const { collapsible } = this . props ;
19
+ if ( onExpand && collapsible ?. expandedKeys ) {
18
20
const { expandedKeys } = collapsible ;
19
21
const { key } = e . currentTarget . dataset ;
20
22
const isExpandNow = expandedKeys . includes ( key ) ;
@@ -24,7 +26,7 @@ Component(
24
26
} else {
25
27
newExpandedKeys . push ( key ) ;
26
28
}
27
- triggerEvent ( this , 'expand' , newExpandedKeys , key ) ;
29
+ triggerEventValues ( this , 'expand' , [ newExpandedKeys , key ] ) ;
28
30
} else {
29
31
const { key } = e . currentTarget . dataset ;
30
32
const foldStatusMap = { ...this . data . foldStatusMap } ;
0 commit comments