1
1
import React , { useState , useEffect , useMemo } from 'react' ;
2
2
import Input from '@uiw/react-input' ;
3
- import { IProps } from '@uiw/utils' ;
3
+ import { HTMLInputProps , IProps } from '@uiw/utils' ;
4
4
import Dropdown , { DropdownProps } from '@uiw/react-dropdown' ;
5
5
import Menu from '@uiw/react-menu' ;
6
6
import Icon from '@uiw/react-icon' ;
@@ -11,13 +11,15 @@ type OptionType = { value: string | number; label: React.ReactNode; children?: A
11
11
type SearchOptionType = { label : string ; options : Array < OptionType > } ;
12
12
13
13
export interface CascaderProps extends IProps , DropdownProps {
14
+ size ?: 'large' | 'default' | 'small' ;
14
15
option ?: Array < OptionType > ;
15
16
value ?: ValueType ;
16
17
onChange ?: ( isSeleted : boolean , value : ValueType , selectedOptions : Array < OptionType > ) => void ;
17
18
onSearch ?: boolean | ( ( searchText : string ) => void ) ;
18
19
allowClear ?: boolean ;
19
20
placeholder ?: string ;
20
21
disabled ?: boolean ;
22
+ inputProps ?: HTMLInputProps ;
21
23
}
22
24
23
25
function Cascader ( props : CascaderProps ) {
@@ -26,6 +28,7 @@ function Cascader(props: CascaderProps) {
26
28
onChange,
27
29
onSearch,
28
30
31
+ size,
29
32
disabled,
30
33
allowClear,
31
34
placeholder,
@@ -34,6 +37,7 @@ function Cascader(props: CascaderProps) {
34
37
style = { width : 200 } ,
35
38
option = [ ] ,
36
39
others,
40
+ inputProps,
37
41
} = props ;
38
42
39
43
const cls = [ prefixCls , className ] . filter ( Boolean ) . join ( ' ' ) . trim ( ) ;
@@ -178,7 +182,7 @@ function Cascader(props: CascaderProps) {
178
182
< Dropdown
179
183
className = { cls }
180
184
trigger = "click"
181
- style = { { marginTop : 5 , ... style } }
185
+ style = { { marginTop : 5 } }
182
186
overlayStyl = { { width : 100 } }
183
187
disabled = { disabled }
184
188
{ ...others }
@@ -226,11 +230,13 @@ function Cascader(props: CascaderProps) {
226
230
>
227
231
< span onMouseLeave = { ( ) => renderSelectIcon ( 'leave' ) } onMouseOver = { ( ) => renderSelectIcon ( 'enter' ) } >
228
232
< Input
233
+ { ...inputProps }
229
234
value = { searchOn ? searchText : inputValue }
230
235
onChange = { inputChange }
236
+ size = { size }
231
237
disabled = { disabled }
232
238
placeholder = { searchOn ? inputValue : placeholder }
233
- style = { { width : style ?. width } }
239
+ style = { style }
234
240
onFocus = { ( ) => onSearch && setSearchOn ( true ) }
235
241
onBlur = { ( ) => onSearch && setSearchOn ( false ) }
236
242
readOnly = { ! onSearch }
0 commit comments