File tree Expand file tree Collapse file tree 2 files changed +46
-3
lines changed Expand file tree Collapse file tree 2 files changed +46
-3
lines changed Original file line number Diff line number Diff line change @@ -97,9 +97,10 @@ export interface DefaultOptionType extends BaseOptionType {
97
97
children ?: Omit < DefaultOptionType , 'children' > [ ] ;
98
98
}
99
99
100
- export type SelectHandler < ValueType = any , OptionType extends BaseOptionType = DefaultOptionType > =
101
- | ( ( value : RawValueType | LabelInValueType , option : OptionType ) => void )
102
- | ( ( value : ValueType , option : OptionType ) => void ) ;
100
+ export type SelectHandler < ValueType , OptionType extends BaseOptionType = DefaultOptionType > = (
101
+ value : ValueType ,
102
+ option : OptionType ,
103
+ ) => void ;
103
104
104
105
type ArrayElementType < T > = T extends ( infer E ) [ ] ? E : T ;
105
106
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import Select from '../src' ;
3
+
4
+ describe ( 'Select.typescript' , ( ) => {
5
+ it ( 'Select.items' , ( ) => {
6
+ const select = (
7
+ < Select
8
+ onSelect = { ( value : string ) => {
9
+ console . log ( value ) ;
10
+ } }
11
+ >
12
+ < Select . Option value = "jack" > jack</ Select . Option >
13
+ </ Select >
14
+ ) ;
15
+
16
+ expect ( select ) . toBeTruthy ( ) ;
17
+ } ) ;
18
+
19
+ it ( 'Select.items Customizable ValueType' , ( ) => {
20
+ const select = (
21
+ < Select < string , { value : string ; title : string } >
22
+ defaultValue = "TEAM_1"
23
+ showSearch
24
+ style = { { width : 200 } }
25
+ optionFilterProp = "children"
26
+ onSelect = { ( _ , option ) => {
27
+ console . log ( option ) ;
28
+ } }
29
+ filterOption = { ( input , option ) =>
30
+ ( option && option . title . toLowerCase ( ) . indexOf ( input . toLowerCase ( ) ) >= 0 ) ?? false
31
+ }
32
+ >
33
+ < Select . Option key = "TEAM_1" value = "TEAM_1" title = "Team 1" >
34
+ Team 131
35
+ </ Select . Option >
36
+ ))
37
+ </ Select >
38
+ ) ;
39
+
40
+ expect ( select ) . toBeTruthy ( ) ;
41
+ } ) ;
42
+ } ) ;
You can’t perform that action at this time.
0 commit comments