11import type { AlignType , BuildInPlacements } from '@rc-component/trigger/lib/interface' ;
2- import classNames from 'classnames' ;
2+ import cls from 'classnames' ;
33import useLayoutEffect from '@rc-component/util/lib/hooks/useLayoutEffect' ;
44import useMergedState from '@rc-component/util/lib/hooks/useMergedState' ;
55import isMobile from '@rc-component/util/lib/isMobile' ;
@@ -27,8 +27,6 @@ import type { RefTriggerProps } from '../SelectTrigger';
2727import SelectTrigger from '../SelectTrigger' ;
2828import TransBtn from '../TransBtn' ;
2929import { getSeparatedContent , isValidCount } from '../utils/valueUtil' ;
30- import SelectContext from '../SelectContext' ;
31- import type { SelectContextProps } from '../SelectContext' ;
3230import Polite from './Polite' ;
3331export type BaseSelectSemanticName = 'prefix' | 'suffix' | 'input' ;
3432
@@ -130,22 +128,27 @@ export interface BaseSelectPrivateProps {
130128export type BaseSelectPropsWithoutPrivate = Omit < BaseSelectProps , keyof BaseSelectPrivateProps > ;
131129
132130export interface BaseSelectProps extends BaseSelectPrivateProps , React . AriaAttributes {
131+ // Style
133132 className ?: string ;
134133 style ?: React . CSSProperties ;
135134 classNames ?: Partial < Record < BaseSelectSemanticName , string > > ;
136135 styles ?: Partial < Record < BaseSelectSemanticName , React . CSSProperties > > ;
137- title ?: string ;
136+
137+ // Selector
138138 showSearch ?: boolean ;
139139 tagRender ?: ( props : CustomTagProps ) => React . ReactElement ;
140140 direction ?: 'ltr' | 'rtl' ;
141- maxLength ?: number ;
142- showScrollBar ?: boolean | 'optional' ;
141+ autoFocus ?: boolean ;
142+ placeholder ?: React . ReactNode ;
143+ maxCount ?: number ;
144+
143145 // MISC
146+ title ?: string ;
144147 tabIndex ?: number ;
145- autoFocus ?: boolean ;
146148 notFoundContent ?: React . ReactNode ;
147- placeholder ?: React . ReactNode ;
148149 onClear ?: ( ) => void ;
150+ maxLength ?: number ;
151+ showScrollBar ?: boolean | 'optional' ;
149152
150153 choiceTransitionName ?: string ;
151154
@@ -224,6 +227,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
224227 id,
225228 prefixCls,
226229 className,
230+ styles,
231+ classNames,
227232 showSearch,
228233 tagRender,
229234 showScrollBar = 'optional' ,
@@ -236,6 +241,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
236241 emptyOptions,
237242 notFoundContent = 'Not Found' ,
238243 onClear,
244+ maxCount,
239245
240246 // Mode
241247 mode,
@@ -408,15 +414,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
408414 [ tokenSeparators ] ,
409415 ) ;
410416
411- const {
412- maxCount,
413- rawValues,
414- classNames : selectClassNames ,
415- styles,
416- } = React . useContext < SelectContextProps > ( SelectContext ) || { } ;
417-
418417 const onInternalSearch = ( searchText : string , fromTyping : boolean , isCompositing : boolean ) => {
419- if ( multiple && isValidCount ( maxCount ) && rawValues ?. size >= maxCount ) {
418+ if ( multiple && isValidCount ( maxCount ) && displayValues . length >= maxCount ) {
420419 return ;
421420 }
422421 let ret = true ;
@@ -426,7 +425,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
426425 const separatedList = getSeparatedContent (
427426 searchText ,
428427 tokenSeparators ,
429- isValidCount ( maxCount ) ? maxCount - rawValues . size : undefined ,
428+ isValidCount ( maxCount ) ? maxCount - displayValues . length : undefined ,
430429 ) ;
431430
432431 // Check if match the `tokenSeparators`
@@ -703,6 +702,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
703702 multiple,
704703 toggleOpen : onToggleOpen ,
705704 showScrollBar,
705+ styles,
706+ classNames,
706707 } ) ,
707708 [
708709 props ,
@@ -714,6 +715,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
714715 multiple ,
715716 onToggleOpen ,
716717 showScrollBar ,
718+ styles ,
719+ classNames ,
717720 ] ,
718721 ) ;
719722
@@ -728,7 +731,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
728731 if ( showSuffixIcon ) {
729732 arrowNode = (
730733 < TransBtn
731- className = { classNames ( `${ prefixCls } -arrow` , selectClassNames ?. suffix , {
734+ className = { cls ( `${ prefixCls } -arrow` , classNames ?. suffix , {
732735 [ `${ prefixCls } -arrow-loading` ] : loading ,
733736 } ) }
734737 style = { styles ?. suffix }
@@ -772,7 +775,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
772775 const optionList = < OptionList ref = { listRef } /> ;
773776
774777 // ============================= Select =============================
775- const mergedClassName = classNames ( prefixCls , className , {
778+ const mergedClassName = cls ( prefixCls , className , {
776779 [ `${ prefixCls } -focused` ] : mockFocused ,
777780 [ `${ prefixCls } -multiple` ] : multiple ,
778781 [ `${ prefixCls } -single` ] : ! multiple ,
@@ -821,7 +824,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
821824 ) : (
822825 < Selector
823826 { ...props }
824- prefixClassName = { selectClassNames ?. prefix }
827+ prefixClassName = { classNames ?. prefix }
825828 prefixStyle = { styles ?. prefix }
826829 domRef = { selectorDomRef }
827830 prefixCls = { prefixCls }
0 commit comments