@@ -8,13 +8,15 @@ import Menus from './Menus';
88import BUILT_IN_PLACEMENTS from './placements' ;
99
1010export interface CascaderFieldNames {
11- value ?: string ;
11+ value ?: string | number ;
1212 label ?: string ;
1313 children ?: string ;
1414}
1515
16+ export type CascaderValueType = ( string | number ) [ ] ;
17+
1618export interface CascaderOption {
17- value ?: string ;
19+ value ?: string | number ;
1820 label ?: React . ReactNode ;
1921 disabled ?: boolean ;
2022 isLeaf ?: boolean ;
@@ -24,10 +26,10 @@ export interface CascaderOption {
2426}
2527
2628export interface CascaderProps extends Pick < TriggerProps , 'getPopupContainer' > {
27- value ?: string [ ] ;
28- defaultValue ?: string [ ] ;
29+ value ?: CascaderValueType ;
30+ defaultValue ?: CascaderValueType ;
2931 options ?: CascaderOption [ ] ;
30- onChange ?: ( value : string [ ] , selectOptions : CascaderOption [ ] ) => void ;
32+ onChange ?: ( value : CascaderValueType , selectOptions : CascaderOption [ ] ) => void ;
3133 onPopupVisibleChange ?: ( popupVisible : boolean ) => void ;
3234 popupVisible ?: boolean ;
3335 disabled ?: boolean ;
@@ -50,8 +52,8 @@ export interface CascaderProps extends Pick<TriggerProps, 'getPopupContainer'> {
5052
5153interface CascaderState {
5254 popupVisible ?: boolean ;
53- activeValue ?: string [ ] ;
54- value ?: string [ ] ;
55+ activeValue ?: CascaderValueType ;
56+ value ?: CascaderValueType ;
5557 prevProps ?: CascaderProps ;
5658}
5759
@@ -158,7 +160,7 @@ class Cascader extends React.Component<CascaderProps, CascaderState> {
158160 return [ ...options ] . filter ( o => ! o . disabled ) ;
159161 }
160162
161- getActiveOptions ( activeValue : string [ ] ) : CascaderOption [ ] {
163+ getActiveOptions ( activeValue : CascaderValueType ) : CascaderOption [ ] {
162164 return arrayTreeFilter (
163165 this . props . options || [ ] ,
164166 ( o , level ) => o [ this . getFieldName ( 'value' ) ] === activeValue [ level ] ,
0 commit comments