1
- import * as React from 'react' ;
2
1
import type { CollapseProps } from 'rc-collapse' ;
3
2
import Collapse , { Panel } from 'rc-collapse' ;
4
- import motion from './_util/motionUtil ' ;
3
+ import * as React from 'react ' ;
5
4
import '../../assets/index.less' ;
5
+ import motion from './_util/motionUtil' ;
6
6
7
7
const initLength = 3 ;
8
8
@@ -50,65 +50,44 @@ const App: React.FC = () => {
50
50
51
51
const time = random ( ) ;
52
52
53
- const panelItems = Array
54
- . from < object , React . ReactNode > (
55
- { length : initLength } ,
56
- ( _ , i ) => {
57
- const key = i + 1 ;
58
- return (
59
- < Panel
60
- header = { `This is panel header ${ key } ` }
61
- key = { key }
62
- >
63
- < p > { text . repeat ( time ) } </ p >
64
- </ Panel >
65
- )
66
- } )
67
- . concat (
68
- < Panel
69
- header = { `This is panel header ${ initLength + 1 } ` }
70
- key = { initLength + 1 }
71
- >
72
- < Collapse defaultActiveKey = "1" expandIcon = { expandIcon } >
73
- < Panel
74
- header = "This is panel nest panel"
75
- key = "1"
76
- id = "header-test"
77
- >
78
- < p > { text } </ p >
79
- </ Panel >
80
- </ Collapse >
81
- </ Panel > ,
82
- < Panel
83
- header = { `This is panel header ${ initLength + 2 } ` }
84
- key = { initLength + 2 }
85
- >
86
- < Collapse defaultActiveKey = "1" >
87
- < Panel
88
- header = "This is panel nest panel"
89
- key = "1"
90
- id = "another-test"
91
- >
92
- < form >
93
- < label htmlFor = "test" > Name: </ label >
94
- < input type = "text" id = "test" />
95
- </ form >
96
- </ Panel >
97
- </ Collapse >
98
- </ Panel > ,
99
- < Panel
100
- header = { `This is panel header ${ initLength + 3 } ` }
101
- key = { initLength + 3 }
102
- extra = { < span > Extra Node</ span > }
103
- >
104
- < p > Panel with extra</ p >
53
+ const panelItems = Array . from < object , React . ReactNode > ( { length : initLength } , ( _ , i ) => {
54
+ const key = i + 1 ;
55
+ return (
56
+ < Panel header = { `This is panel header ${ key } ` } key = { key } >
57
+ < p > { text . repeat ( time ) } </ p >
105
58
</ Panel >
106
59
) ;
60
+ } ) . concat (
61
+ < Panel header = { `This is panel header ${ initLength + 1 } ` } key = { initLength + 1 } >
62
+ < Collapse defaultActiveKey = "1" expandIcon = { expandIcon } >
63
+ < Panel header = "This is panel nest panel" key = "1" id = "header-test" >
64
+ < p > { text } </ p >
65
+ </ Panel >
66
+ </ Collapse >
67
+ </ Panel > ,
68
+ < Panel header = { `This is panel header ${ initLength + 2 } ` } key = { initLength + 2 } >
69
+ < Collapse defaultActiveKey = "1" >
70
+ < Panel header = "This is panel nest panel" key = "1" id = "another-test" >
71
+ < form >
72
+ < label htmlFor = "test" > Name: </ label >
73
+ < input type = "text" id = "test" />
74
+ </ form >
75
+ </ Panel >
76
+ </ Collapse >
77
+ </ Panel > ,
78
+ < Panel
79
+ header = { `This is panel header ${ initLength + 3 } ` }
80
+ key = { initLength + 3 }
81
+ extra = { < span > Extra Node</ span > }
82
+ >
83
+ < p > Panel with extra</ p >
84
+ </ Panel > ,
85
+ ) ;
107
86
108
87
const handleCollapsibleChange = ( e : React . ChangeEvent < HTMLSelectElement > ) => {
109
88
const values = [ undefined , 'header' , 'icon' , 'disabled' ] ;
110
- setCollapsible ( values [ e . target . value ] )
111
- }
89
+ setCollapsible ( values [ e . target . value ] ) ;
90
+ } ;
112
91
113
92
const tools = (
114
93
< >
@@ -117,7 +96,7 @@ const App: React.FC = () => {
117
96
</ button >
118
97
< br />
119
98
< br />
120
- < button type = "button" onClick = { ( ) => setAccordion ( prev => ! prev ) } >
99
+ < button type = "button" onClick = { ( ) => setAccordion ( ( prev ) => ! prev ) } >
121
100
{ accordion ? 'Mode: accordion' : 'Mode: collapse' }
122
101
</ button >
123
102
< br />
@@ -138,7 +117,7 @@ const App: React.FC = () => {
138
117
< br />
139
118
< br />
140
119
</ >
141
- )
120
+ ) ;
142
121
143
122
return (
144
123
< >
@@ -154,7 +133,7 @@ const App: React.FC = () => {
154
133
{ panelItems }
155
134
</ Collapse >
156
135
</ >
157
- )
158
- }
136
+ ) ;
137
+ } ;
159
138
160
139
export default App ;
0 commit comments