{"version":3,"file":"SearchSourceResultList.mjs","names":[],"sources":["../../../../../src/components/Search/SearchResults/SearchSourceResultList.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport type { SearchSourceState, SearchSourceType } from 'stream-chat';\n\nimport { DefaultSearchResultItems } from './SearchResultItem';\nimport { SearchSourceResultListFooter as DefaultSearchSourceResultListFooter } from './SearchSourceResultListFooter';\nimport { useSearchSourceResultsContext } from '../SearchSourceResultsContext';\nimport { InfiniteScrollPaginator } from '../../../components/InfiniteScrollPaginator/InfiniteScrollPaginator';\nimport { useComponentContext } from '../../../context';\nimport { useStateStore } from '../../../store';\nimport type { SearchResultItemComponents } from './SearchResultItem';\n\nconst searchSourceStateSelector = (nextValue: SearchSourceState) => ({\n  items: nextValue.items,\n});\n\nexport type SearchSourceResultListProps = {\n  /**\n   * The minimum interval, in milliseconds, between two checks of the scroll position for loading\n   * the next page (`InfiniteScrollPaginator`'s `loadNextDebounceMs`).\n   */\n  loadMoreDebounceMs?: number;\n  loadMoreThresholdPx?: number;\n  SearchResultItems?: SearchResultItemComponents;\n};\n\nexport const SearchSourceResultList = ({\n  loadMoreDebounceMs = 100,\n  loadMoreThresholdPx = 80,\n  SearchResultItems = DefaultSearchResultItems,\n}: SearchSourceResultListProps) => {\n  const { SearchSourceResultListFooter = DefaultSearchSourceResultListFooter } =\n    useComponentContext();\n\n  const { searchSource } = useSearchSourceResultsContext();\n  const { items } = useStateStore(searchSource.state, searchSourceStateSelector);\n\n  const SearchResultItem = SearchResultItems[\n    searchSource.type as SearchSourceType\n  ] as ComponentType<{ item: unknown }>;\n\n  if (!SearchResultItem) return null;\n\n  return (\n    <div\n      className='str-chat__search-source-result-list'\n      data-testid='search-source-result-list'\n    >\n      <InfiniteScrollPaginator\n        loadNextDebounceMs={loadMoreDebounceMs}\n        loadNextOnScrollToBottom={searchSource.search}\n        threshold={loadMoreThresholdPx}\n      >\n        {items?.map((item, i) => (\n          <SearchResultItem\n            item={item}\n            key={`source-search-result-${searchSource.type}-${i}`}\n          />\n        ))}\n        <SearchSourceResultListFooter />\n      </InfiniteScrollPaginator>\n    </div>\n  );\n};\n"],"mappings":";;;;;;;;;AAYA,IAAM,6BAA6B,eAAkC,EACnE,OAAO,UAAU,MACnB;AAYA,IAAa,0BAA0B,EACrC,qBAAqB,KACrB,sBAAsB,IACtB,oBAAoB,+BACa;CACjC,MAAM,EAAE,8BAAA,iCAA+B,iCACrC,oBAAoB;CAEtB,MAAM,EAAE,iBAAiB,8BAA8B;CACvD,MAAM,EAAE,UAAU,cAAc,aAAa,OAAO,yBAAyB;CAE7E,MAAM,mBAAmB,kBACvB,aAAa;CAGf,IAAI,CAAC,kBAAkB,OAAO;CAE9B,OACE,oBAAC,OAAD;EACE,WAAU;EACV,eAAY;YAEZ,qBAAC,yBAAD;GACE,oBAAoB;GACpB,0BAA0B,aAAa;GACvC,WAAW;aAHb,CAKG,OAAO,KAAK,MAAM,MACjB,oBAAC,kBAAD,EACQ,KAEP,GADM,wBAAwB,aAAa,KAAK,GAAG,GACnD,CACF,GACD,oBAAC,gCAAD,CAA+B,CAAA,CACR;;CACtB,CAAA;AAET"}