1717import { CHECKBOX_VALUE } from '@Common/Types'
1818import { ComponentSizeType } from '@Shared/constants'
1919import { GroupBase , MultiValue , OptionsOrGroups , StylesConfig } from 'react-select'
20- import { getComponentSizeMagnitude } from '@Shared/Helpers'
2120import { SelectPickerOptionType , SelectPickerProps , SelectPickerVariantType } from './type'
21+ import { SELECT_PICKER_CONTROL_SIZE_MAP , SELECT_PICKER_FONT_SIZE_MAP , SELECT_PICKER_ICON_SIZE_MAP } from './constants'
2222
2323const getMenuWidthFromSize = < OptionValue , IsMulti extends boolean > (
2424 menuSize : SelectPickerProps < OptionValue , IsMulti > [ 'menuSize' ] ,
@@ -78,24 +78,6 @@ const getOptionBgColor = <OptionValue>(
7878 return 'var(--N0)'
7979}
8080
81- const getFontSize = ( size : ComponentSizeType ) : string => {
82- switch ( size ) {
83- case ComponentSizeType . small :
84- return '12px'
85- default :
86- return '13px'
87- }
88- }
89-
90- const getIconSize = ( size : ComponentSizeType ) : { width : string ; height : string } => {
91- switch ( size ) {
92- case ComponentSizeType . small :
93- return { width : '12px' , height : '12px' }
94- default :
95- return { width : '16px' , height : '16px' }
96- }
97- }
98-
9981export const getCommonSelectStyle = < OptionValue , IsMulti extends boolean > ( {
10082 error,
10183 size,
@@ -136,8 +118,7 @@ export const getCommonSelectStyle = <OptionValue, IsMulti extends boolean>({
136118 } ) ,
137119 control : ( base , state ) => ( {
138120 ...base ,
139- minHeight :
140- getComponentSizeMagnitude ( size ) <= getComponentSizeMagnitude ( ComponentSizeType . medium ) ? 'auto' : '36px' ,
121+ minHeight : SELECT_PICKER_CONTROL_SIZE_MAP [ size ] ,
141122 minWidth : '56px' ,
142123 boxShadow : 'none' ,
143124 backgroundColor : 'var(--N50)' ,
@@ -185,7 +166,7 @@ export const getCommonSelectStyle = <OptionValue, IsMulti extends boolean>({
185166 } ) ,
186167 dropdownIndicator : ( base , state ) => ( {
187168 ...base ,
188- ...getIconSize ( size ) ,
169+ ...SELECT_PICKER_ICON_SIZE_MAP [ size ] ,
189170 display : 'flex' ,
190171 alignItems : 'center' ,
191172 flexShrink : '0' ,
@@ -196,8 +177,8 @@ export const getCommonSelectStyle = <OptionValue, IsMulti extends boolean>({
196177 } ) ,
197178 clearIndicator : ( base ) => ( {
198179 ...base ,
180+ ...SELECT_PICKER_ICON_SIZE_MAP [ size ] ,
199181 padding : 0 ,
200- ...getIconSize ( size ) ,
201182 display : 'flex' ,
202183 alignItems : 'center' ,
203184 flexShrink : '0' ,
@@ -302,7 +283,7 @@ export const getCommonSelectStyle = <OptionValue, IsMulti extends boolean>({
302283 margin : 0 ,
303284 padding : 0 ,
304285 color : 'var(--N900)' ,
305- size : getFontSize ( size ) ,
286+ size : '13px' ,
306287 fontWeight : 400 ,
307288 lineHeight : '20px' ,
308289 overflow : 'hidden' ,
@@ -312,7 +293,7 @@ export const getCommonSelectStyle = <OptionValue, IsMulti extends boolean>({
312293 placeholder : ( base ) => ( {
313294 ...base ,
314295 color : 'var(--N500)' ,
315- fontSize : getFontSize ( size ) ,
296+ fontSize : SELECT_PICKER_FONT_SIZE_MAP [ size ] ,
316297 lineHeight : '20px' ,
317298 fontWeight : 400 ,
318299 margin : 0 ,
@@ -329,7 +310,7 @@ export const getCommonSelectStyle = <OptionValue, IsMulti extends boolean>({
329310 ...base ,
330311 margin : 0 ,
331312 color : 'var(--N900)' ,
332- fontSize : getFontSize ( size ) ,
313+ fontSize : SELECT_PICKER_FONT_SIZE_MAP [ size ] ,
333314 fontWeight : 400 ,
334315 lineHeight : '20px' ,
335316 ...( getVariantOverrides ( variant ) ?. singleValue ( base , state ) || { } ) ,
0 commit comments