1- import * as React from 'react' ;
21import type { CollapseProps } from 'rc-collapse' ;
32import Collapse , { Panel } from 'rc-collapse' ;
4- import motion from './_util/motionUtil ' ;
3+ import * as React from 'react ' ;
54import '../../assets/index.less' ;
5+ import motion from './_util/motionUtil' ;
66
77const initLength = 3 ;
88
@@ -50,65 +50,44 @@ const App: React.FC = () => {
5050
5151 const time = random ( ) ;
5252
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 >
10558 </ Panel >
10659 ) ;
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+ ) ;
10786
10887 const handleCollapsibleChange = ( e : React . ChangeEvent < HTMLSelectElement > ) => {
10988 const values = [ undefined , 'header' , 'icon' , 'disabled' ] ;
110- setCollapsible ( values [ e . target . value ] )
111- }
89+ setCollapsible ( values [ e . target . value ] ) ;
90+ } ;
11291
11392 const tools = (
11493 < >
@@ -117,7 +96,7 @@ const App: React.FC = () => {
11796 </ button >
11897 < br />
11998 < br />
120- < button type = "button" onClick = { ( ) => setAccordion ( prev => ! prev ) } >
99+ < button type = "button" onClick = { ( ) => setAccordion ( ( prev ) => ! prev ) } >
121100 { accordion ? 'Mode: accordion' : 'Mode: collapse' }
122101 </ button >
123102 < br />
@@ -138,7 +117,7 @@ const App: React.FC = () => {
138117 < br />
139118 < br />
140119 </ >
141- )
120+ ) ;
142121
143122 return (
144123 < >
@@ -154,7 +133,7 @@ const App: React.FC = () => {
154133 { panelItems }
155134 </ Collapse >
156135 </ >
157- )
158- }
136+ ) ;
137+ } ;
159138
160139export default App ;
0 commit comments