@@ -5,10 +5,10 @@ import * as React from 'react';
5
5
import type { Placement , RenderDOMFunc } from './BaseSelect' ;
6
6
7
7
const getBuiltInPlacements = (
8
- dropdownMatchSelectWidth : number | boolean ,
8
+ popupMatchSelectWidth : number | boolean ,
9
9
) : Record < string , AlignType > => {
10
10
// Enable horizontal overflow auto-adjustment when a custom dropdown width is provided
11
- const adjustX = dropdownMatchSelectWidth === true ? 0 : 1 ;
11
+ const adjustX = popupMatchSelectWidth === true ? 0 : 1 ;
12
12
return {
13
13
bottomLeft : {
14
14
points : [ 'tl' , 'bl' ] ,
@@ -64,13 +64,13 @@ export interface SelectTriggerProps {
64
64
transitionName ?: string ;
65
65
placement ?: Placement ;
66
66
builtinPlacements ?: BuildInPlacements ;
67
- dropdownStyle : React . CSSProperties ;
68
- dropdownClassName : string ;
67
+ popupStyle : React . CSSProperties ;
68
+ popupClassName : string ;
69
69
direction : string ;
70
- dropdownMatchSelectWidth ?: boolean | number ;
71
- dropdownRender ?: ( menu : React . ReactElement ) => React . ReactElement ;
70
+ popupMatchSelectWidth ?: boolean | number ;
71
+ popupRender ?: ( menu : React . ReactElement ) => React . ReactElement ;
72
72
getPopupContainer ?: RenderDOMFunc ;
73
- dropdownAlign : AlignType ;
73
+ popupAlign : AlignType ;
74
74
empty : boolean ;
75
75
76
76
getTriggerDOMNode : ( node : HTMLElement ) => HTMLElement ;
@@ -91,14 +91,14 @@ const SelectTrigger: React.ForwardRefRenderFunction<RefTriggerProps, SelectTrigg
91
91
popupElement,
92
92
animation,
93
93
transitionName,
94
- dropdownStyle ,
95
- dropdownClassName ,
94
+ popupStyle ,
95
+ popupClassName ,
96
96
direction = 'ltr' ,
97
97
placement,
98
98
builtinPlacements,
99
- dropdownMatchSelectWidth ,
100
- dropdownRender ,
101
- dropdownAlign ,
99
+ popupMatchSelectWidth ,
100
+ popupRender ,
101
+ popupAlign ,
102
102
getPopupContainer,
103
103
empty,
104
104
getTriggerDOMNode,
@@ -107,38 +107,44 @@ const SelectTrigger: React.ForwardRefRenderFunction<RefTriggerProps, SelectTrigg
107
107
...restProps
108
108
} = props ;
109
109
110
- const dropdownPrefixCls = `${ prefixCls } -dropdown` ;
110
+ // We still use `dropdown` className to keep compatibility
111
+ // This is used for:
112
+ // 1. Styles
113
+ // 2. Animation
114
+ // 3. Theme customization
115
+ // Please do not modify this since it's a breaking change
116
+ const popupPrefixCls = `${ prefixCls } -dropdown` ;
111
117
112
118
let popupNode = popupElement ;
113
- if ( dropdownRender ) {
114
- popupNode = dropdownRender ( popupElement ) ;
119
+ if ( popupRender ) {
120
+ popupNode = popupRender ( popupElement ) ;
115
121
}
116
122
117
123
const mergedBuiltinPlacements = React . useMemo (
118
- ( ) => builtinPlacements || getBuiltInPlacements ( dropdownMatchSelectWidth ) ,
119
- [ builtinPlacements , dropdownMatchSelectWidth ] ,
124
+ ( ) => builtinPlacements || getBuiltInPlacements ( popupMatchSelectWidth ) ,
125
+ [ builtinPlacements , popupMatchSelectWidth ] ,
120
126
) ;
121
127
122
128
// ===================== Motion ======================
123
- const mergedTransitionName = animation ? `${ dropdownPrefixCls } -${ animation } ` : transitionName ;
129
+ const mergedTransitionName = animation ? `${ popupPrefixCls } -${ animation } ` : transitionName ;
124
130
125
131
// =================== Popup Width ===================
126
- const isNumberPopupWidth = typeof dropdownMatchSelectWidth === 'number' ;
132
+ const isNumberPopupWidth = typeof popupMatchSelectWidth === 'number' ;
127
133
128
134
const stretch = React . useMemo ( ( ) => {
129
135
if ( isNumberPopupWidth ) {
130
136
return null ;
131
137
}
132
138
133
- return dropdownMatchSelectWidth === false ? 'minWidth' : 'width' ;
134
- } , [ dropdownMatchSelectWidth , isNumberPopupWidth ] ) ;
139
+ return popupMatchSelectWidth === false ? 'minWidth' : 'width' ;
140
+ } , [ popupMatchSelectWidth , isNumberPopupWidth ] ) ;
135
141
136
- let popupStyle = dropdownStyle ;
142
+ let mergedPopupStyle = popupStyle ;
137
143
138
144
if ( isNumberPopupWidth ) {
139
- popupStyle = {
145
+ mergedPopupStyle = {
140
146
...popupStyle ,
141
- width : dropdownMatchSelectWidth ,
147
+ width : popupMatchSelectWidth ,
142
148
} ;
143
149
}
144
150
@@ -156,18 +162,18 @@ const SelectTrigger: React.ForwardRefRenderFunction<RefTriggerProps, SelectTrigg
156
162
hideAction = { onPopupVisibleChange ? [ 'click' ] : [ ] }
157
163
popupPlacement = { placement || ( direction === 'rtl' ? 'bottomRight' : 'bottomLeft' ) }
158
164
builtinPlacements = { mergedBuiltinPlacements }
159
- prefixCls = { dropdownPrefixCls }
165
+ prefixCls = { popupPrefixCls }
160
166
popupTransitionName = { mergedTransitionName }
161
167
popup = { < div onMouseEnter = { onPopupMouseEnter } > { popupNode } </ div > }
162
168
ref = { triggerPopupRef }
163
169
stretch = { stretch }
164
- popupAlign = { dropdownAlign }
170
+ popupAlign = { popupAlign }
165
171
popupVisible = { visible }
166
172
getPopupContainer = { getPopupContainer }
167
- popupClassName = { classNames ( dropdownClassName , {
168
- [ `${ dropdownPrefixCls } -empty` ] : empty ,
173
+ popupClassName = { classNames ( popupClassName , {
174
+ [ `${ popupPrefixCls } -empty` ] : empty ,
169
175
} ) }
170
- popupStyle = { popupStyle }
176
+ popupStyle = { mergedPopupStyle }
171
177
getTriggerDOMNode = { getTriggerDOMNode }
172
178
onPopupVisibleChange = { onPopupVisibleChange }
173
179
>
0 commit comments