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' ;
@@ -130,22 +130,27 @@ export interface BaseSelectPrivateProps {
130130export type BaseSelectPropsWithoutPrivate = Omit < BaseSelectProps , keyof BaseSelectPrivateProps > ;
131131
132132export interface BaseSelectProps extends BaseSelectPrivateProps , React . AriaAttributes {
133+ // Style
133134 className ?: string ;
134135 style ?: React . CSSProperties ;
135136 classNames ?: Partial < Record < BaseSelectSemanticName , string > > ;
136137 styles ?: Partial < Record < BaseSelectSemanticName , React . CSSProperties > > ;
137- title ?: string ;
138+
139+ // Selector
138140 showSearch ?: boolean ;
139141 tagRender ?: ( props : CustomTagProps ) => React . ReactElement ;
140142 direction ?: 'ltr' | 'rtl' ;
141- maxLength ?: number ;
142- showScrollBar ?: boolean | 'optional' ;
143+ autoFocus ?: boolean ;
144+ placeholder ?: React . ReactNode ;
145+ maxCount ?: number ;
146+
143147 // MISC
148+ title ?: string ;
144149 tabIndex ?: number ;
145- autoFocus ?: boolean ;
146150 notFoundContent ?: React . ReactNode ;
147- placeholder ?: React . ReactNode ;
148151 onClear ?: ( ) => void ;
152+ maxLength ?: number ;
153+ showScrollBar ?: boolean | 'optional' ;
149154
150155 choiceTransitionName ?: string ;
151156
@@ -224,6 +229,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
224229 id,
225230 prefixCls,
226231 className,
232+ styles,
233+ classNames,
227234 showSearch,
228235 tagRender,
229236 showScrollBar = 'optional' ,
@@ -236,6 +243,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
236243 emptyOptions,
237244 notFoundContent = 'Not Found' ,
238245 onClear,
246+ maxCount,
239247
240248 // Mode
241249 mode,
@@ -283,8 +291,6 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
283291 placement,
284292 builtinPlacements,
285293 getPopupContainer,
286- styles : baseSelectStyles ,
287- classNames : baseSelectClassNames ,
288294
289295 // Focus
290296 showAction = [ ] ,
@@ -410,18 +416,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
410416 [ tokenSeparators ] ,
411417 ) ;
412418
413- const {
414- maxCount,
415- rawValues,
416- classNames : selectClassNames ,
417- styles : selectStyles ,
418- } = React . useContext < SelectContextProps > ( SelectContext ) || { } ;
419-
420- const contextClassNames = baseSelectClassNames ?? selectClassNames ;
421- const contextStyles = baseSelectStyles ?? selectStyles ;
422-
423419 const onInternalSearch = ( searchText : string , fromTyping : boolean , isCompositing : boolean ) => {
424- if ( multiple && isValidCount ( maxCount ) && rawValues ?. size >= maxCount ) {
420+ if ( multiple && isValidCount ( maxCount ) && displayValues . length >= maxCount ) {
425421 return ;
426422 }
427423 let ret = true ;
@@ -431,7 +427,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
431427 const separatedList = getSeparatedContent (
432428 searchText ,
433429 tokenSeparators ,
434- isValidCount ( maxCount ) ? maxCount - rawValues . size : undefined ,
430+ isValidCount ( maxCount ) ? maxCount - displayValues . length : undefined ,
435431 ) ;
436432
437433 // Check if match the `tokenSeparators`
@@ -708,8 +704,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
708704 multiple,
709705 toggleOpen : onToggleOpen ,
710706 showScrollBar,
711- styles : contextStyles ,
712- classNames : contextClassNames ,
707+ styles,
708+ classNames,
713709 } ) ,
714710 [
715711 props ,
@@ -721,6 +717,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
721717 multiple ,
722718 onToggleOpen ,
723719 showScrollBar ,
720+ styles ,
721+ classNames ,
724722 ] ,
725723 ) ;
726724
@@ -735,10 +733,10 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
735733 if ( showSuffixIcon ) {
736734 arrowNode = (
737735 < TransBtn
738- className = { classNames ( `${ prefixCls } -arrow` , contextClassNames ?. suffix , {
736+ className = { cls ( `${ prefixCls } -arrow` , classNames ?. suffix , {
739737 [ `${ prefixCls } -arrow-loading` ] : loading ,
740738 } ) }
741- style = { contextStyles ?. suffix }
739+ style = { styles ?. suffix }
742740 customizeIcon = { suffixIcon }
743741 customizeIconProps = { {
744742 loading,
@@ -779,7 +777,7 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
779777 const optionList = < OptionList ref = { listRef } /> ;
780778
781779 // ============================= Select =============================
782- const mergedClassName = classNames ( prefixCls , className , {
780+ const mergedClassName = cls ( prefixCls , className , {
783781 [ `${ prefixCls } -focused` ] : mockFocused ,
784782 [ `${ prefixCls } -multiple` ] : multiple ,
785783 [ `${ prefixCls } -single` ] : ! multiple ,
@@ -828,8 +826,8 @@ const BaseSelect = React.forwardRef<BaseSelectRef, BaseSelectProps>((props, ref)
828826 ) : (
829827 < Selector
830828 { ...props }
831- prefixClassName = { contextClassNames ?. prefix }
832- prefixStyle = { contextStyles ?. prefix }
829+ prefixClassName = { classNames ?. prefix }
830+ prefixStyle = { styles ?. prefix }
833831 domRef = { selectorDomRef }
834832 prefixCls = { prefixCls }
835833 inputElement = { customizeInputElement }
0 commit comments