14
14
* limitations under the License.
15
15
*/
16
16
17
- import ReactSelect , {
17
+ import {
18
18
ControlProps ,
19
19
GroupHeadingProps ,
20
20
MultiValueProps ,
21
21
OptionProps ,
22
- SelectInstance ,
23
22
ValueContainerProps ,
24
23
MenuPlacement ,
25
24
} from 'react-select'
26
25
import CreatableSelect from 'react-select/creatable'
27
- import { MutableRefObject , ReactElement , useCallback , useMemo } from 'react'
26
+ import { ReactElement , useCallback , useMemo } from 'react'
28
27
29
28
import { ReactComponent as ErrorIcon } from '@Icons/ic-warning.svg'
30
29
import { ReactComponent as ICInfoFilledOverride } from '@Icons/ic-info-filled-override.svg'
@@ -209,11 +208,11 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
209
208
fullWidth = false ,
210
209
customSelectedOptionsCount = null ,
211
210
renderMenuListFooter,
212
- isCreatableSingleSelect = false ,
213
211
inputValue,
214
212
onInputChange,
215
213
isCreatable = false ,
216
214
onCreateOption,
215
+ closeMenuOnSelect = false ,
217
216
...props
218
217
} : SelectPickerProps < OptionValue , IsMulti > ) => {
219
218
const { inputId, required, isDisabled, controlShouldRenderValue = true , value, options } = props
@@ -309,9 +308,9 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
309
308
)
310
309
311
310
const handleCreateOption : SelectPickerProps < OptionValue , boolean > [ 'onCreateOption' ] = (
312
- inputValue : string ,
311
+ _inputValue : string ,
313
312
) : void => {
314
- const trimmedInputValue = inputValue ?. trim ( )
313
+ const trimmedInputValue = _inputValue ?. trim ( )
315
314
if ( trimmedInputValue ) {
316
315
onCreateOption ( trimmedInputValue )
317
316
}
@@ -350,50 +349,6 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
350
349
] ,
351
350
)
352
351
353
- const renderSingleSelectPicker = ( ) =>
354
- isCreatableSingleSelect ? (
355
- < CreatableSelect
356
- { ...props }
357
- { ...commonProps }
358
- ref = { selectRef as SelectPickerProps < OptionValue , false > [ 'selectRef' ] }
359
- components = { {
360
- IndicatorSeparator : null ,
361
- LoadingIndicator : SelectPickerLoadingIndicator ,
362
- DropdownIndicator : SelectPickerDropdownIndicator ,
363
- Control : renderControl ,
364
- Option : renderOption ,
365
- MenuList : SelectPickerMenuList ,
366
- ClearIndicator : SelectPickerClearIndicator ,
367
- ValueContainer : renderValueContainer ,
368
- GroupHeading : renderGroupHeading ,
369
- NoOptionsMessage : renderNoOptionsMessage ,
370
- } }
371
- allowCreateWhileLoading = { false }
372
- isValidNewOption = { isValidNewOption }
373
- createOptionPosition = "first"
374
- onCreateOption = { handleCreateOption }
375
- renderMenuListFooter = { ! optionListError && renderMenuListFooter }
376
- />
377
- ) : (
378
- < ReactSelect
379
- { ...props }
380
- { ...commonProps }
381
- ref = { selectRef as MutableRefObject < SelectInstance < SelectPickerOptionType < OptionValue > > > }
382
- components = { {
383
- IndicatorSeparator : null ,
384
- LoadingIndicator : SelectPickerLoadingIndicator ,
385
- DropdownIndicator : SelectPickerDropdownIndicator ,
386
- Control : renderControl ,
387
- Option : renderOption ,
388
- MenuList : SelectPickerMenuList ,
389
- ClearIndicator : SelectPickerClearIndicator ,
390
- ValueContainer : renderValueContainer ,
391
- NoOptionsMessage : renderNoOptionsMessage ,
392
- } }
393
- renderMenuListFooter = { ! optionListError && renderMenuListFooter }
394
- />
395
- )
396
-
397
352
return (
398
353
< div className = { `flex column left top dc__gap-4 ${ fullWidth ? 'w-100' : '' } ` } >
399
354
{ /* Note: Common out for fields */ }
@@ -417,38 +372,34 @@ const SelectPicker = <OptionValue, IsMulti extends boolean>({
417
372
) }
418
373
< ConditionalWrap condition = { isDisabled && ! ! disabledTippyContent } wrap = { renderDisabledTippy } >
419
374
< div className = "w-100" >
420
- { isMulti ? (
421
- < CreatableSelect
422
- { ...props }
423
- { ...commonProps }
424
- isMulti
425
- ref = { selectRef as SelectPickerProps < OptionValue , true > [ 'selectRef' ] }
426
- components = { {
427
- IndicatorSeparator : null ,
428
- LoadingIndicator : SelectPickerLoadingIndicator ,
429
- DropdownIndicator : SelectPickerDropdownIndicator ,
430
- Control : renderControl ,
431
- Option : renderOption ,
432
- MenuList : SelectPickerMenuList ,
433
- ClearIndicator : SelectPickerClearIndicator ,
434
- ValueContainer : renderValueContainer ,
435
- MultiValueLabel : renderMultiValueLabel ,
436
- MultiValueRemove : SelectPickerMultiValueRemove ,
437
- GroupHeading : renderGroupHeading ,
438
- NoOptionsMessage : renderNoOptionsMessage ,
439
- } }
440
- closeMenuOnSelect = { false }
441
- allowCreateWhileLoading = { false }
442
- isValidNewOption = { isValidNewOption }
443
- createOptionPosition = "first"
444
- onCreateOption = { handleCreateOption }
445
- renderMenuListFooter = { ! optionListError && renderMenuListFooter }
446
- inputValue = { inputValue }
447
- onInputChange = { onInputChange }
448
- />
449
- ) : (
450
- renderSingleSelectPicker ( )
451
- ) }
375
+ < CreatableSelect
376
+ { ...props }
377
+ { ...commonProps }
378
+ isMulti = { isMulti }
379
+ ref = { selectRef }
380
+ components = { {
381
+ IndicatorSeparator : null ,
382
+ LoadingIndicator : SelectPickerLoadingIndicator ,
383
+ DropdownIndicator : SelectPickerDropdownIndicator ,
384
+ Control : renderControl ,
385
+ Option : renderOption ,
386
+ MenuList : SelectPickerMenuList ,
387
+ ClearIndicator : SelectPickerClearIndicator ,
388
+ ValueContainer : renderValueContainer ,
389
+ MultiValueLabel : renderMultiValueLabel ,
390
+ MultiValueRemove : SelectPickerMultiValueRemove ,
391
+ GroupHeading : renderGroupHeading ,
392
+ NoOptionsMessage : renderNoOptionsMessage ,
393
+ } }
394
+ closeMenuOnSelect = { closeMenuOnSelect }
395
+ allowCreateWhileLoading = { false }
396
+ isValidNewOption = { isValidNewOption }
397
+ createOptionPosition = "first"
398
+ onCreateOption = { handleCreateOption }
399
+ renderMenuListFooter = { ! optionListError && renderMenuListFooter }
400
+ inputValue = { inputValue }
401
+ onInputChange = { onInputChange }
402
+ />
452
403
</ div >
453
404
</ ConditionalWrap >
454
405
</ div >
0 commit comments