@@ -12,33 +12,34 @@ import React, {
12
12
} from 'react' ;
13
13
import styled from 'styled-components' ;
14
14
15
+ import { FormInputOption } from '../Form' ;
15
16
import { fontSizeFromTheme } from '../styled-utils' ;
16
17
17
- export type OptionType < TValue = unknown > =
18
- | ValueOptionType < TValue >
19
- | GroupedOptionType < TValue > ;
20
-
21
- export type ValueOptionType < TValue = unknown > = {
22
- label : ReactNode ;
23
- value : TValue ;
24
- disabled ?: boolean ;
25
- } ;
18
+ export type MaybeGroupedInputOption <
19
+ TValue = unknown ,
20
+ TLabel extends ReactNode = ReactNode ,
21
+ > = FormInputOption < TValue , TLabel > | GroupedInputOption < TValue , TLabel > ;
26
22
27
23
/** As described in https://4x.ant.design/components/select/#components-select-demo-optgroup. */
28
- export type GroupedOptionType < TValue = unknown > = {
29
- label : ReactNode ;
30
- options : Array < ValueOptionType < TValue > > ;
24
+ export type GroupedInputOption <
25
+ TValue = unknown ,
26
+ TLabel extends ReactNode = ReactNode ,
27
+ > = {
28
+ label : TLabel ;
29
+ options : Array < FormInputOption < TValue , TLabel > > ;
31
30
disabled ?: boolean ;
32
31
} ;
33
32
34
33
export type FilterOptionFunction <
35
34
TValue = unknown ,
36
- TOption extends OptionType < TValue > = OptionType < TValue > ,
35
+ TOption extends
36
+ MaybeGroupedInputOption < TValue > = MaybeGroupedInputOption < TValue > ,
37
37
> = AntdFilterFunc < TOption > ;
38
38
39
39
export type SelectProps <
40
40
TValue = unknown ,
41
- TOption extends OptionType < TValue > = OptionType < TValue > ,
41
+ TOption extends
42
+ MaybeGroupedInputOption < TValue > = MaybeGroupedInputOption < TValue > ,
42
43
> = Modify <
43
44
AntdSelectProps < TValue , TOption > ,
44
45
{
@@ -73,7 +74,10 @@ const StyledDropdown = styled.div`
73
74
}
74
75
` ;
75
76
76
- function SelectInner < TValue , TOptionType extends OptionType < TValue > > (
77
+ function SelectInner <
78
+ TValue ,
79
+ TOptionType extends MaybeGroupedInputOption < TValue > ,
80
+ > (
77
81
{ children, dropdownRender, ...props } : SelectProps < TValue , TOptionType > ,
78
82
ref : ForwardedRef < BaseSelectRef > ,
79
83
) {
@@ -99,7 +103,8 @@ function SelectInner<TValue, TOptionType extends OptionType<TValue>>(
99
103
100
104
export const Select = forwardRef ( SelectInner ) as unknown as ( <
101
105
TValue = unknown ,
102
- TOptionType extends OptionType < TValue > = OptionType < TValue > ,
106
+ TOptionType extends
107
+ MaybeGroupedInputOption < TValue > = MaybeGroupedInputOption < TValue > ,
103
108
> (
104
109
props : SelectProps < TValue , TOptionType > ,
105
110
) => ReactElement ) & {
0 commit comments