@@ -23,6 +23,7 @@ import {
23
23
type AriaOnFilter ,
24
24
type AriaLiveMessages ,
25
25
} from "react-select"
26
+ import ReactSelectAsync from "react-select/async"
26
27
27
28
// usage aria stuff:
28
29
// https://react-select.com/advanced
@@ -312,6 +313,7 @@ type InnerProps<
312
313
IsMulti extends boolean = boolean ,
313
314
> = PickedCreateableProps < ValueType , IsMulti > & {
314
315
isCreateable ?: boolean
316
+ isAsync ?: boolean
315
317
testId ?: string
316
318
innerRef ?: React . Ref < SelectInstance <
317
319
OptionType < ValueType > ,
@@ -328,6 +330,7 @@ type InnerProps<
328
330
329
331
const SelectInner = < ValueType , IsMulti extends boolean = boolean > ( {
330
332
isCreateable,
333
+ isAsync,
331
334
formatCreateLabel,
332
335
testId,
333
336
innerRef,
@@ -525,6 +528,12 @@ const SelectInner = <ValueType, IsMulti extends boolean = boolean>({
525
528
_components ,
526
529
] )
527
530
531
+ if ( isAsync && isCreateable ) {
532
+ throw new Error (
533
+ "Select - isAsync and isCreateable cannot be true at the same time" ,
534
+ )
535
+ }
536
+
528
537
if ( isCreateable ) {
529
538
return (
530
539
< ReactSelectCreatable <
@@ -560,6 +569,31 @@ const SelectInner = <ValueType, IsMulti extends boolean = boolean>({
560
569
)
561
570
}
562
571
572
+ if ( isAsync ) {
573
+ return (
574
+ < ReactSelectAsync <
575
+ OptionType < ValueType > ,
576
+ IsMulti ,
577
+ OptionGroupType < ValueType >
578
+ >
579
+ placeholder = {
580
+ ( props . placeholder ?? locale . startsWith ( "de" ) )
581
+ ? "Auswahl..."
582
+ : "Select..."
583
+ }
584
+ ref = { locRef }
585
+ unstyled
586
+ inputId = { inputId }
587
+ classNames = { classNamesConfig }
588
+ data-testid = { testId }
589
+ data-invalid = { invalid }
590
+ styles = { customStyles }
591
+ components = { components }
592
+ { ...props }
593
+ />
594
+ )
595
+ }
596
+
563
597
return (
564
598
< RSelect < OptionType < ValueType > , IsMulti , OptionGroupType < ValueType > >
565
599
placeholder = {
@@ -613,6 +647,7 @@ type SelectPropsProtoOld<
613
647
usePortal ?: boolean
614
648
disabled ?: boolean
615
649
isCreateable ?: boolean
650
+ isAsync ?: boolean
616
651
dropdownLabel ?: ( isOpen : boolean ) => string
617
652
clearValuesButtonLabel ?: string
618
653
removeValueButtonLabel ?: string
@@ -764,6 +799,7 @@ function SelectInForm<
764
799
const innerProps : InnerProps < ValueType , IsMulti > = {
765
800
...props ,
766
801
isCreateable : props . isCreateable ,
802
+ isAsync : props . isAsync ,
767
803
testId,
768
804
innerRef : ref ,
769
805
invalid,
0 commit comments