File tree Expand file tree Collapse file tree
packages/autocomplete-core/src/utils Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,40 +6,33 @@ import {
66 InternalAutocompleteSource ,
77} from '../types' ;
88
9- import { createConcurrentSafePromise } from './createConcurrentSafePromise' ;
109import { noop } from './noop' ;
1110
12- const runConcurrentSafePromiseForGetSources = createConcurrentSafePromise <
13- Array < AutocompleteSource < any > >
14- > ( ) ;
15-
1611export function getNormalizedSources < TItem > (
1712 getSources : (
1813 params : GetSourcesParams < TItem >
1914 ) => MaybePromise < Array < AutocompleteSource < TItem > > > ,
2015 options : GetSourcesParams < TItem >
2116) : Promise < Array < InternalAutocompleteSource < TItem > > > {
22- return runConcurrentSafePromiseForGetSources ( getSources ( options ) ) . then (
23- ( sources ) => {
24- return Promise . all (
25- sources . filter ( Boolean ) . map ( ( source ) => {
26- const normalizedSource : InternalAutocompleteSource < TItem > = {
27- getItemInputValue ( { state } ) {
28- return state . query ;
29- } ,
30- getItemUrl ( ) {
31- return undefined ;
32- } ,
33- onSelect ( { setIsOpen } ) {
34- setIsOpen ( false ) ;
35- } ,
36- onHighlight : noop ,
37- ...source ,
38- } ;
17+ return Promise . resolve ( getSources ( options ) ) . then ( ( sources ) => {
18+ return Promise . all (
19+ sources . filter ( Boolean ) . map ( ( source ) => {
20+ const normalizedSource : InternalAutocompleteSource < TItem > = {
21+ getItemInputValue ( { state } ) {
22+ return state . query ;
23+ } ,
24+ getItemUrl ( ) {
25+ return undefined ;
26+ } ,
27+ onSelect ( { setIsOpen } ) {
28+ setIsOpen ( false ) ;
29+ } ,
30+ onHighlight : noop ,
31+ ...source ,
32+ } ;
3933
40- return Promise . resolve ( normalizedSource ) ;
41- } )
42- ) ;
43- }
44- ) ;
34+ return Promise . resolve ( normalizedSource ) ;
35+ } )
36+ ) ;
37+ } ) ;
4538}
You can’t perform that action at this time.
0 commit comments