File tree Expand file tree Collapse file tree 4 files changed +48
-10
lines changed Expand file tree Collapse file tree 4 files changed +48
-10
lines changed Original file line number Diff line number Diff line change @@ -67,6 +67,10 @@ export default () => {
6767 console . log ( 'Change:' , value ) ;
6868 } }
6969 />
70+
71+ < Cascader . Panel options = { addressOptions } direction = "rtl" />
72+
73+ < Cascader . Panel notFoundContent = "Empty!!!" />
7074 </ >
7175 ) ;
7276} ;
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ const addressOptions = [
6969class Demo extends React . Component {
7070 render ( ) {
7171 return (
72- < Cascader options = { addressOptions } showSearch style = { { width : 300 } } animation = "slide-up" />
72+ < Cascader options = { addressOptions } showSearch style = { { width : 300 } } animation = "slide-up" notFoundContent = "Empty Content!" />
7373 ) ;
7474 }
7575}
Original file line number Diff line number Diff line change @@ -26,7 +26,9 @@ export type PickType =
2626 | 'expandIcon'
2727 | 'loadingIcon'
2828 | 'className'
29- | 'style' ;
29+ | 'style'
30+ | 'direction'
31+ | 'notFoundContent' ;
3032
3133export type PanelProps = Pick < CascaderProps , PickType > ;
3234
@@ -49,6 +51,8 @@ export default function Panel(props: PanelProps) {
4951 expandTrigger,
5052 expandIcon = '>' ,
5153 loadingIcon,
54+ direction,
55+ notFoundContent = 'Not Found' ,
5256 } = props as Pick < InternalCascaderProps , PickType > ;
5357
5458 // ======================== Multiple ========================
@@ -155,16 +159,34 @@ export default function Panel(props: PanelProps) {
155159 ) ;
156160
157161 // ========================= Render =========================
162+ const panelPrefixCls = `${ prefixCls } -panel` ;
163+ const isEmpty = ! mergedOptions . length ;
164+
158165 return (
159166 < CascaderContext . Provider value = { cascaderContext } >
160- < div className = { classNames ( `${ prefixCls } -panel` , className ) } style = { style } >
161- < RawOptionList
162- prefixCls = { prefixCls }
163- searchValue = { null }
164- multiple = { multiple }
165- toggleOpen = { noop }
166- open
167- />
167+ < div
168+ className = { classNames (
169+ panelPrefixCls ,
170+ {
171+ [ `${ panelPrefixCls } -rtl` ] : direction === 'rtl' ,
172+ [ `${ panelPrefixCls } -empty` ] : isEmpty ,
173+ } ,
174+ className ,
175+ ) }
176+ style = { style }
177+ >
178+ { isEmpty ? (
179+ notFoundContent
180+ ) : (
181+ < RawOptionList
182+ prefixCls = { prefixCls }
183+ searchValue = { null }
184+ multiple = { multiple }
185+ toggleOpen = { noop }
186+ open
187+ direction = { direction }
188+ />
189+ ) }
168190 </ div >
169191 </ CascaderContext . Provider >
170192 ) ;
Original file line number Diff line number Diff line change @@ -80,4 +80,16 @@ describe('Cascader.Panel', () => {
8080 fireEvent . click ( container . querySelectorAll ( '.rc-cascader-checkbox' ) [ 1 ] ) ;
8181 expect ( onChange ) . toHaveBeenCalledWith ( [ [ 'bamboo' , 'little' ] ] , expect . anything ( ) ) ;
8282 } ) ;
83+
84+ it ( 'rtl' , ( ) => {
85+ const { container } = render ( < Cascader . Panel options = { options } direction = "rtl" /> ) ;
86+
87+ expect ( container . querySelector ( '.rc-cascader-panel-rtl' ) ) . toBeTruthy ( ) ;
88+ } ) ;
89+
90+ it ( 'notFoundContent' , ( ) => {
91+ const { container } = render ( < Cascader . Panel notFoundContent = "Hello World" /> ) ;
92+
93+ expect ( container . querySelector ( '.rc-cascader-panel-empty' ) . textContent ) . toEqual ( 'Hello World' ) ;
94+ } ) ;
8395} ) ;
You can’t perform that action at this time.
0 commit comments