@seekora-ai/ui-sdk-react 0.0.0-stage-20260517092419
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Breadcrumb.d.ts +43 -0
- package/dist/components/Breadcrumb.d.ts.map +1 -0
- package/dist/components/Breadcrumb.js +119 -0
- package/dist/components/ClearRefinements.d.ts +42 -0
- package/dist/components/ClearRefinements.d.ts.map +1 -0
- package/dist/components/ClearRefinements.js +81 -0
- package/dist/components/CurrentRefinements.d.ts +63 -0
- package/dist/components/CurrentRefinements.d.ts.map +1 -0
- package/dist/components/CurrentRefinements.js +302 -0
- package/dist/components/FacetDropdown.d.ts +94 -0
- package/dist/components/FacetDropdown.d.ts.map +1 -0
- package/dist/components/FacetDropdown.js +396 -0
- package/dist/components/Facets.d.ts +118 -0
- package/dist/components/Facets.d.ts.map +1 -0
- package/dist/components/Facets.js +785 -0
- package/dist/components/FederatedDropdown.d.ts +98 -0
- package/dist/components/FederatedDropdown.d.ts.map +1 -0
- package/dist/components/FederatedDropdown.js +526 -0
- package/dist/components/HierarchicalMenu.d.ts +55 -0
- package/dist/components/HierarchicalMenu.d.ts.map +1 -0
- package/dist/components/HierarchicalMenu.js +276 -0
- package/dist/components/Highlight.d.ts +51 -0
- package/dist/components/Highlight.d.ts.map +1 -0
- package/dist/components/Highlight.js +155 -0
- package/dist/components/HitsPerPage.d.ts +41 -0
- package/dist/components/HitsPerPage.d.ts.map +1 -0
- package/dist/components/HitsPerPage.js +82 -0
- package/dist/components/InfiniteHits.d.ts +51 -0
- package/dist/components/InfiniteHits.d.ts.map +1 -0
- package/dist/components/InfiniteHits.js +173 -0
- package/dist/components/MobileFilters.d.ts +71 -0
- package/dist/components/MobileFilters.d.ts.map +1 -0
- package/dist/components/MobileFilters.js +242 -0
- package/dist/components/Pagination.d.ts +90 -0
- package/dist/components/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination.js +298 -0
- package/dist/components/QuerySuggestions.d.ts +36 -0
- package/dist/components/QuerySuggestions.d.ts.map +1 -0
- package/dist/components/QuerySuggestions.js +71 -0
- package/dist/components/QuerySuggestionsDropdown.d.ts +82 -0
- package/dist/components/QuerySuggestionsDropdown.d.ts.map +1 -0
- package/dist/components/QuerySuggestionsDropdown.js +394 -0
- package/dist/components/RangeInput.d.ts +58 -0
- package/dist/components/RangeInput.d.ts.map +1 -0
- package/dist/components/RangeInput.js +203 -0
- package/dist/components/RangeSlider.d.ts +51 -0
- package/dist/components/RangeSlider.d.ts.map +1 -0
- package/dist/components/RangeSlider.js +262 -0
- package/dist/components/Recommendations.d.ts +89 -0
- package/dist/components/Recommendations.d.ts.map +1 -0
- package/dist/components/Recommendations.js +256 -0
- package/dist/components/RichQuerySuggestions.d.ts +88 -0
- package/dist/components/RichQuerySuggestions.d.ts.map +1 -0
- package/dist/components/RichQuerySuggestions.js +498 -0
- package/dist/components/SearchBar.d.ts +57 -0
- package/dist/components/SearchBar.d.ts.map +1 -0
- package/dist/components/SearchBar.js +361 -0
- package/dist/components/SearchBarWithSuggestions.d.ts +105 -0
- package/dist/components/SearchBarWithSuggestions.d.ts.map +1 -0
- package/dist/components/SearchBarWithSuggestions.js +275 -0
- package/dist/components/SearchLayout.d.ts +35 -0
- package/dist/components/SearchLayout.d.ts.map +1 -0
- package/dist/components/SearchLayout.js +61 -0
- package/dist/components/SearchProvider.d.ts +35 -0
- package/dist/components/SearchProvider.d.ts.map +1 -0
- package/dist/components/SearchProvider.js +53 -0
- package/dist/components/SearchResults.d.ts +57 -0
- package/dist/components/SearchResults.d.ts.map +1 -0
- package/dist/components/SearchResults.js +456 -0
- package/dist/components/SortBy.d.ts +84 -0
- package/dist/components/SortBy.d.ts.map +1 -0
- package/dist/components/SortBy.js +183 -0
- package/dist/components/Stats.d.ts +51 -0
- package/dist/components/Stats.d.ts.map +1 -0
- package/dist/components/Stats.js +201 -0
- package/dist/components/primitives/ActionButtons.d.ts +27 -0
- package/dist/components/primitives/ActionButtons.d.ts.map +1 -0
- package/dist/components/primitives/ActionButtons.js +102 -0
- package/dist/components/primitives/AnalyticsProvider.d.ts +22 -0
- package/dist/components/primitives/AnalyticsProvider.d.ts.map +1 -0
- package/dist/components/primitives/AnalyticsProvider.js +87 -0
- package/dist/components/primitives/BadgeList.d.ts +14 -0
- package/dist/components/primitives/BadgeList.d.ts.map +1 -0
- package/dist/components/primitives/BadgeList.js +65 -0
- package/dist/components/primitives/CustomSelect.d.ts +40 -0
- package/dist/components/primitives/CustomSelect.d.ts.map +1 -0
- package/dist/components/primitives/CustomSelect.js +196 -0
- package/dist/components/primitives/ImageDisplay.d.ts +28 -0
- package/dist/components/primitives/ImageDisplay.d.ts.map +1 -0
- package/dist/components/primitives/ImageDisplay.js +127 -0
- package/dist/components/primitives/ImageZoom.d.ts +33 -0
- package/dist/components/primitives/ImageZoom.d.ts.map +1 -0
- package/dist/components/primitives/ImageZoom.js +433 -0
- package/dist/components/primitives/PriceDisplay.d.ts +21 -0
- package/dist/components/primitives/PriceDisplay.d.ts.map +1 -0
- package/dist/components/primitives/PriceDisplay.js +44 -0
- package/dist/components/primitives/RatingDisplay.d.ts +43 -0
- package/dist/components/primitives/RatingDisplay.d.ts.map +1 -0
- package/dist/components/primitives/RatingDisplay.js +114 -0
- package/dist/components/primitives/VariantSelector.d.ts +30 -0
- package/dist/components/primitives/VariantSelector.d.ts.map +1 -0
- package/dist/components/primitives/VariantSelector.js +155 -0
- package/dist/components/primitives/VariantSwatches.d.ts +28 -0
- package/dist/components/primitives/VariantSwatches.d.ts.map +1 -0
- package/dist/components/primitives/VariantSwatches.js +188 -0
- package/dist/components/primitives/index.d.ts +12 -0
- package/dist/components/primitives/index.d.ts.map +1 -0
- package/dist/components/primitives/index.js +11 -0
- package/dist/components/primitives/withAnalytics.d.ts +24 -0
- package/dist/components/primitives/withAnalytics.d.ts.map +1 -0
- package/dist/components/primitives/withAnalytics.js +73 -0
- package/dist/components/product-page/ProductGallery.d.ts +26 -0
- package/dist/components/product-page/ProductGallery.d.ts.map +1 -0
- package/dist/components/product-page/ProductGallery.js +13 -0
- package/dist/components/product-page/ProductInfo.d.ts +44 -0
- package/dist/components/product-page/ProductInfo.d.ts.map +1 -0
- package/dist/components/product-page/ProductInfo.js +34 -0
- package/dist/components/product-page/ProductRecommendations.d.ts +21 -0
- package/dist/components/product-page/ProductRecommendations.d.ts.map +1 -0
- package/dist/components/product-page/ProductRecommendations.js +17 -0
- package/dist/components/product-page/index.d.ts +4 -0
- package/dist/components/product-page/index.d.ts.map +1 -0
- package/dist/components/product-page/index.js +3 -0
- package/dist/components/section-primitives/SectionError.d.ts +11 -0
- package/dist/components/section-primitives/SectionError.d.ts.map +1 -0
- package/dist/components/section-primitives/SectionError.js +13 -0
- package/dist/components/section-primitives/SectionItemGrid.d.ts +18 -0
- package/dist/components/section-primitives/SectionItemGrid.d.ts.map +1 -0
- package/dist/components/section-primitives/SectionItemGrid.js +14 -0
- package/dist/components/section-primitives/SectionLoading.d.ts +11 -0
- package/dist/components/section-primitives/SectionLoading.d.ts.map +1 -0
- package/dist/components/section-primitives/SectionLoading.js +11 -0
- package/dist/components/section-primitives/SectionSearchContext.d.ts +17 -0
- package/dist/components/section-primitives/SectionSearchContext.d.ts.map +1 -0
- package/dist/components/section-primitives/SectionSearchContext.js +17 -0
- package/dist/components/section-primitives/SectionSearchProvider.d.ts +25 -0
- package/dist/components/section-primitives/SectionSearchProvider.d.ts.map +1 -0
- package/dist/components/section-primitives/SectionSearchProvider.js +106 -0
- package/dist/components/section-primitives/index.d.ts +5 -0
- package/dist/components/section-primitives/index.d.ts.map +1 -0
- package/dist/components/section-primitives/index.js +4 -0
- package/dist/components/suggestions/AmazonDropdown.d.ts +30 -0
- package/dist/components/suggestions/AmazonDropdown.d.ts.map +1 -0
- package/dist/components/suggestions/AmazonDropdown.js +509 -0
- package/dist/components/suggestions/GoogleDropdown.d.ts +31 -0
- package/dist/components/suggestions/GoogleDropdown.d.ts.map +1 -0
- package/dist/components/suggestions/GoogleDropdown.js +349 -0
- package/dist/components/suggestions/MinimalDropdown.d.ts +24 -0
- package/dist/components/suggestions/MinimalDropdown.d.ts.map +1 -0
- package/dist/components/suggestions/MinimalDropdown.js +312 -0
- package/dist/components/suggestions/MobileSheetDropdown.d.ts +31 -0
- package/dist/components/suggestions/MobileSheetDropdown.d.ts.map +1 -0
- package/dist/components/suggestions/MobileSheetDropdown.js +483 -0
- package/dist/components/suggestions/PinterestDropdown.d.ts +29 -0
- package/dist/components/suggestions/PinterestDropdown.d.ts.map +1 -0
- package/dist/components/suggestions/PinterestDropdown.js +446 -0
- package/dist/components/suggestions/ShopifyDropdown.d.ts +27 -0
- package/dist/components/suggestions/ShopifyDropdown.d.ts.map +1 -0
- package/dist/components/suggestions/ShopifyDropdown.js +448 -0
- package/dist/components/suggestions/SpotlightDropdown.d.ts +33 -0
- package/dist/components/suggestions/SpotlightDropdown.d.ts.map +1 -0
- package/dist/components/suggestions/SpotlightDropdown.js +544 -0
- package/dist/components/suggestions/SuggestionSearchBar.d.ts +127 -0
- package/dist/components/suggestions/SuggestionSearchBar.d.ts.map +1 -0
- package/dist/components/suggestions/SuggestionSearchBar.js +644 -0
- package/dist/components/suggestions/index.d.ts +37 -0
- package/dist/components/suggestions/index.d.ts.map +1 -0
- package/dist/components/suggestions/index.js +59 -0
- package/dist/components/suggestions/styles/index.d.ts +11 -0
- package/dist/components/suggestions/styles/index.d.ts.map +1 -0
- package/dist/components/suggestions/styles/index.js +289 -0
- package/dist/components/suggestions/styles/responsive.d.ts +107 -0
- package/dist/components/suggestions/styles/responsive.d.ts.map +1 -0
- package/dist/components/suggestions/styles/responsive.js +237 -0
- package/dist/components/suggestions/types.d.ts +511 -0
- package/dist/components/suggestions/types.d.ts.map +1 -0
- package/dist/components/suggestions/types.js +6 -0
- package/dist/components/suggestions/utils.d.ts +259 -0
- package/dist/components/suggestions/utils.d.ts.map +1 -0
- package/dist/components/suggestions/utils.js +668 -0
- package/dist/components/suggestions-primitives/CategoriesTabs.d.ts +13 -0
- package/dist/components/suggestions-primitives/CategoriesTabs.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/CategoriesTabs.js +35 -0
- package/dist/components/suggestions-primitives/DropdownPanel.d.ts +24 -0
- package/dist/components/suggestions-primitives/DropdownPanel.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/DropdownPanel.js +67 -0
- package/dist/components/suggestions-primitives/ItemCard.d.ts +48 -0
- package/dist/components/suggestions-primitives/ItemCard.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/ItemCard.js +103 -0
- package/dist/components/suggestions-primitives/ItemGrid.d.ts +28 -0
- package/dist/components/suggestions-primitives/ItemGrid.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/ItemGrid.js +55 -0
- package/dist/components/suggestions-primitives/ProductCard.d.ts +45 -0
- package/dist/components/suggestions-primitives/ProductCard.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/ProductCard.js +177 -0
- package/dist/components/suggestions-primitives/ProductCardLayouts.d.ts +44 -0
- package/dist/components/suggestions-primitives/ProductCardLayouts.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/ProductCardLayouts.js +137 -0
- package/dist/components/suggestions-primitives/ProductGrid.d.ts +22 -0
- package/dist/components/suggestions-primitives/ProductGrid.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/ProductGrid.js +41 -0
- package/dist/components/suggestions-primitives/RecentSearchesList.d.ts +17 -0
- package/dist/components/suggestions-primitives/RecentSearchesList.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/RecentSearchesList.js +46 -0
- package/dist/components/suggestions-primitives/SearchInput.d.ts +23 -0
- package/dist/components/suggestions-primitives/SearchInput.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/SearchInput.js +114 -0
- package/dist/components/suggestions-primitives/SuggestionItem.d.ts +31 -0
- package/dist/components/suggestions-primitives/SuggestionItem.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/SuggestionItem.js +47 -0
- package/dist/components/suggestions-primitives/SuggestionList.d.ts +26 -0
- package/dist/components/suggestions-primitives/SuggestionList.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/SuggestionList.js +35 -0
- package/dist/components/suggestions-primitives/SuggestionsContext.d.ts +44 -0
- package/dist/components/suggestions-primitives/SuggestionsContext.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/SuggestionsContext.js +18 -0
- package/dist/components/suggestions-primitives/SuggestionsDropdownComposition.d.ts +24 -0
- package/dist/components/suggestions-primitives/SuggestionsDropdownComposition.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/SuggestionsDropdownComposition.js +30 -0
- package/dist/components/suggestions-primitives/SuggestionsError.d.ts +11 -0
- package/dist/components/suggestions-primitives/SuggestionsError.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/SuggestionsError.js +19 -0
- package/dist/components/suggestions-primitives/SuggestionsLoading.d.ts +11 -0
- package/dist/components/suggestions-primitives/SuggestionsLoading.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/SuggestionsLoading.js +17 -0
- package/dist/components/suggestions-primitives/SuggestionsProvider.d.ts +38 -0
- package/dist/components/suggestions-primitives/SuggestionsProvider.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/SuggestionsProvider.js +259 -0
- package/dist/components/suggestions-primitives/TrendingList.d.ts +17 -0
- package/dist/components/suggestions-primitives/TrendingList.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/TrendingList.js +48 -0
- package/dist/components/suggestions-primitives/highlightMarkup.d.ts +31 -0
- package/dist/components/suggestions-primitives/highlightMarkup.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/highlightMarkup.js +70 -0
- package/dist/components/suggestions-primitives/index.d.ts +39 -0
- package/dist/components/suggestions-primitives/index.d.ts.map +1 -0
- package/dist/components/suggestions-primitives/index.js +24 -0
- package/dist/docsearch/components/DocSearch.d.ts +4 -0
- package/dist/docsearch/components/DocSearch.d.ts.map +1 -0
- package/dist/docsearch/components/DocSearch.js +93 -0
- package/dist/docsearch/components/DocSearchButton.d.ts +4 -0
- package/dist/docsearch/components/DocSearchButton.d.ts.map +1 -0
- package/dist/docsearch/components/DocSearchButton.js +12 -0
- package/dist/docsearch/components/Footer.d.ts +8 -0
- package/dist/docsearch/components/Footer.d.ts.map +1 -0
- package/dist/docsearch/components/Footer.js +40 -0
- package/dist/docsearch/components/Highlight.d.ts +9 -0
- package/dist/docsearch/components/Highlight.d.ts.map +1 -0
- package/dist/docsearch/components/Highlight.js +48 -0
- package/dist/docsearch/components/Hit.d.ts +15 -0
- package/dist/docsearch/components/Hit.d.ts.map +1 -0
- package/dist/docsearch/components/Hit.js +96 -0
- package/dist/docsearch/components/Modal.d.ts +10 -0
- package/dist/docsearch/components/Modal.d.ts.map +1 -0
- package/dist/docsearch/components/Modal.js +57 -0
- package/dist/docsearch/components/Results.d.ts +23 -0
- package/dist/docsearch/components/Results.d.ts.map +1 -0
- package/dist/docsearch/components/Results.js +141 -0
- package/dist/docsearch/components/SearchBox.d.ts +11 -0
- package/dist/docsearch/components/SearchBox.d.ts.map +1 -0
- package/dist/docsearch/components/SearchBox.js +16 -0
- package/dist/docsearch/hooks/useDocSearch.d.ts +33 -0
- package/dist/docsearch/hooks/useDocSearch.d.ts.map +1 -0
- package/dist/docsearch/hooks/useDocSearch.js +224 -0
- package/dist/docsearch/hooks/useKeyboard.d.ts +17 -0
- package/dist/docsearch/hooks/useKeyboard.d.ts.map +1 -0
- package/dist/docsearch/hooks/useKeyboard.js +71 -0
- package/dist/docsearch/hooks/useSeekoraSearch.d.ts +27 -0
- package/dist/docsearch/hooks/useSeekoraSearch.d.ts.map +1 -0
- package/dist/docsearch/hooks/useSeekoraSearch.js +213 -0
- package/dist/docsearch/index.d.ts +13 -0
- package/dist/docsearch/index.d.ts.map +1 -0
- package/dist/docsearch/index.js +11 -0
- package/dist/docsearch/types.d.ts +175 -0
- package/dist/docsearch/types.d.ts.map +1 -0
- package/dist/docsearch/types.js +4 -0
- package/dist/docsearch.css +234 -0
- package/dist/hooks/useAnalytics.d.ts +24 -0
- package/dist/hooks/useAnalytics.d.ts.map +1 -0
- package/dist/hooks/useAnalytics.js +67 -0
- package/dist/hooks/useClickTracking.d.ts +36 -0
- package/dist/hooks/useClickTracking.d.ts.map +1 -0
- package/dist/hooks/useClickTracking.js +89 -0
- package/dist/hooks/useExperiment.d.ts +25 -0
- package/dist/hooks/useExperiment.d.ts.map +1 -0
- package/dist/hooks/useExperiment.js +123 -0
- package/dist/hooks/useFilters.d.ts +27 -0
- package/dist/hooks/useFilters.d.ts.map +1 -0
- package/dist/hooks/useFilters.js +86 -0
- package/dist/hooks/useKeyboardNavigation.d.ts +51 -0
- package/dist/hooks/useKeyboardNavigation.d.ts.map +1 -0
- package/dist/hooks/useKeyboardNavigation.js +113 -0
- package/dist/hooks/useNaturalLanguageFilters.d.ts +48 -0
- package/dist/hooks/useNaturalLanguageFilters.d.ts.map +1 -0
- package/dist/hooks/useNaturalLanguageFilters.js +221 -0
- package/dist/hooks/useProductAnalytics.d.ts +49 -0
- package/dist/hooks/useProductAnalytics.d.ts.map +1 -0
- package/dist/hooks/useProductAnalytics.js +116 -0
- package/dist/hooks/useQuerySuggestions.d.ts +21 -0
- package/dist/hooks/useQuerySuggestions.d.ts.map +1 -0
- package/dist/hooks/useQuerySuggestions.js +84 -0
- package/dist/hooks/useQuerySuggestionsEnhanced.d.ts +120 -0
- package/dist/hooks/useQuerySuggestionsEnhanced.d.ts.map +1 -0
- package/dist/hooks/useQuerySuggestionsEnhanced.js +444 -0
- package/dist/hooks/useSearchState.d.ts +35 -0
- package/dist/hooks/useSearchState.d.ts.map +1 -0
- package/dist/hooks/useSearchState.js +68 -0
- package/dist/hooks/useSeekoraSearch.d.ts +20 -0
- package/dist/hooks/useSeekoraSearch.d.ts.map +1 -0
- package/dist/hooks/useSeekoraSearch.js +63 -0
- package/dist/hooks/useSmartSuggestions.d.ts +55 -0
- package/dist/hooks/useSmartSuggestions.d.ts.map +1 -0
- package/dist/hooks/useSmartSuggestions.js +236 -0
- package/dist/hooks/useSuggestionsAnalytics.d.ts +93 -0
- package/dist/hooks/useSuggestionsAnalytics.d.ts.map +1 -0
- package/dist/hooks/useSuggestionsAnalytics.js +239 -0
- package/dist/hooks/useVariantSelection.d.ts +28 -0
- package/dist/hooks/useVariantSelection.d.ts.map +1 -0
- package/dist/hooks/useVariantSelection.js +44 -0
- package/dist/index.d.ts +105 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +110 -0
- package/dist/index.umd.js +1 -0
- package/dist/src/index.d.ts +4469 -0
- package/dist/src/index.esm.js +18952 -0
- package/dist/src/index.esm.js.map +1 -0
- package/dist/src/index.js +19086 -0
- package/dist/src/index.js.map +1 -0
- package/dist/themes/createTheme.d.ts +8 -0
- package/dist/themes/createTheme.d.ts.map +1 -0
- package/dist/themes/createTheme.js +10 -0
- package/dist/themes/dark.d.ts +6 -0
- package/dist/themes/dark.d.ts.map +1 -0
- package/dist/themes/dark.js +34 -0
- package/dist/themes/default.d.ts +6 -0
- package/dist/themes/default.d.ts.map +1 -0
- package/dist/themes/default.js +71 -0
- package/dist/themes/mergeThemes.d.ts +7 -0
- package/dist/themes/mergeThemes.d.ts.map +1 -0
- package/dist/themes/mergeThemes.js +6 -0
- package/dist/themes/minimal.d.ts +6 -0
- package/dist/themes/minimal.d.ts.map +1 -0
- package/dist/themes/minimal.js +34 -0
- package/dist/themes/suggestions.d.ts +216 -0
- package/dist/themes/suggestions.d.ts.map +1 -0
- package/dist/themes/suggestions.js +546 -0
- package/dist/themes/types.d.ts +7 -0
- package/dist/themes/types.d.ts.map +1 -0
- package/dist/themes/types.js +6 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +4 -0
- package/dist/utils/responsive.d.ts +130 -0
- package/dist/utils/responsive.d.ts.map +1 -0
- package/dist/utils/responsive.js +225 -0
- package/package.json +68 -0
- package/src/docsearch/docsearch.css +234 -0
|
@@ -0,0 +1,456 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchResults Component
|
|
3
|
+
*
|
|
4
|
+
* Displays search results with customizable rendering
|
|
5
|
+
* Includes keyboard navigation support (arrow keys, Enter to select)
|
|
6
|
+
*/
|
|
7
|
+
import React, { useState, useRef, useEffect, useCallback } from 'react';
|
|
8
|
+
import { useSearchContext } from './SearchProvider';
|
|
9
|
+
import { useSearchState } from '../hooks/useSearchState';
|
|
10
|
+
import { log } from '@seekora-ai/ui-sdk-core';
|
|
11
|
+
import { clsx } from 'clsx';
|
|
12
|
+
// Helper function to get nested value from object using dot notation
|
|
13
|
+
const getNestedValue = (obj, path) => {
|
|
14
|
+
if (!path)
|
|
15
|
+
return undefined;
|
|
16
|
+
return path.split('.').reduce((current, key) => current?.[key], obj);
|
|
17
|
+
};
|
|
18
|
+
// Helper function to format price
|
|
19
|
+
const formatPrice = (value, currency = '₹') => {
|
|
20
|
+
if (value === undefined || value === null)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (typeof value === 'number')
|
|
23
|
+
return `${currency}${value}`;
|
|
24
|
+
if (typeof value === 'string') {
|
|
25
|
+
const num = parseFloat(value);
|
|
26
|
+
if (!isNaN(num))
|
|
27
|
+
return `${currency}${num}`;
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
return String(value);
|
|
31
|
+
};
|
|
32
|
+
export const SearchResults = ({ results: resultsProp, loading: loadingProp, error: errorProp, onResultClick, renderResult, renderEmpty, renderError, className, style, theme: customTheme, itemsPerPage = 20, showPagination = false, viewMode = 'list', fieldMapping, extractResults, enableKeyboardNavigation = true, autoFocus = false, minHeight = '400px', minWidth = '100%', }) => {
|
|
33
|
+
const { theme, client, enableAnalytics } = useSearchContext();
|
|
34
|
+
const { results: stateResults, loading: stateLoading, error: stateError, currentPage, itemsPerPage: stateItemsPerPage } = useSearchState();
|
|
35
|
+
const searchResultsTheme = customTheme || {};
|
|
36
|
+
// Keyboard navigation state
|
|
37
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
38
|
+
const containerRef = useRef(null);
|
|
39
|
+
// Use props if provided, otherwise use state from state manager
|
|
40
|
+
const results = resultsProp !== undefined ? resultsProp : stateResults;
|
|
41
|
+
const loading = loadingProp !== undefined ? loadingProp : stateLoading;
|
|
42
|
+
const error = errorProp !== undefined ? errorProp : stateError;
|
|
43
|
+
// Reset active index when results change
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
setActiveIndex(-1);
|
|
46
|
+
}, [results]);
|
|
47
|
+
// Scroll active item into view
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (activeIndex >= 0 && containerRef.current && enableKeyboardNavigation) {
|
|
50
|
+
const activeEl = containerRef.current.querySelector(`[data-result-index="${activeIndex}"]`);
|
|
51
|
+
if (activeEl) {
|
|
52
|
+
activeEl.scrollIntoView({ block: 'nearest', behavior: 'smooth' });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}, [activeIndex, enableKeyboardNavigation]);
|
|
56
|
+
// Global keyboard listener for seamless navigation from search box to results
|
|
57
|
+
useEffect(() => {
|
|
58
|
+
if (!enableKeyboardNavigation)
|
|
59
|
+
return;
|
|
60
|
+
const handleGlobalKeyDown = (e) => {
|
|
61
|
+
// Only handle if we have results and the container exists
|
|
62
|
+
if (!containerRef.current)
|
|
63
|
+
return;
|
|
64
|
+
const resultElements = containerRef.current.querySelectorAll('[data-result-index]');
|
|
65
|
+
const maxIndex = resultElements.length - 1;
|
|
66
|
+
if (maxIndex < 0)
|
|
67
|
+
return;
|
|
68
|
+
// Check if focus is on an input/textarea (search box)
|
|
69
|
+
const activeElement = document.activeElement;
|
|
70
|
+
const isInputFocused = activeElement?.tagName === 'INPUT' || activeElement?.tagName === 'TEXTAREA';
|
|
71
|
+
if (e.key === 'ArrowDown') {
|
|
72
|
+
// If in search box or no result selected, select first result
|
|
73
|
+
if (isInputFocused || activeIndex === -1) {
|
|
74
|
+
e.preventDefault();
|
|
75
|
+
setActiveIndex(0);
|
|
76
|
+
containerRef.current?.focus();
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
else if (e.key === 'ArrowUp') {
|
|
80
|
+
// If first result is selected, go back to search box
|
|
81
|
+
if (activeIndex === 0) {
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
setActiveIndex(-1);
|
|
84
|
+
// Find and focus the search input
|
|
85
|
+
const searchInput = document.querySelector('input[type="text"], input[type="search"]');
|
|
86
|
+
searchInput?.focus();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
document.addEventListener('keydown', handleGlobalKeyDown);
|
|
91
|
+
return () => document.removeEventListener('keydown', handleGlobalKeyDown);
|
|
92
|
+
}, [enableKeyboardNavigation, activeIndex]);
|
|
93
|
+
// Keyboard navigation handler
|
|
94
|
+
const handleKeyDown = useCallback((e) => {
|
|
95
|
+
if (!enableKeyboardNavigation)
|
|
96
|
+
return;
|
|
97
|
+
// We need to get the result count dynamically
|
|
98
|
+
const resultElements = containerRef.current?.querySelectorAll('[data-result-index]');
|
|
99
|
+
const maxIndex = resultElements ? resultElements.length - 1 : -1;
|
|
100
|
+
switch (e.key) {
|
|
101
|
+
case 'ArrowDown':
|
|
102
|
+
e.preventDefault();
|
|
103
|
+
setActiveIndex(prev => Math.min(prev + 1, maxIndex));
|
|
104
|
+
break;
|
|
105
|
+
case 'ArrowUp':
|
|
106
|
+
e.preventDefault();
|
|
107
|
+
setActiveIndex(prev => Math.max(prev - 1, -1));
|
|
108
|
+
break;
|
|
109
|
+
case 'Enter':
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
if (activeIndex >= 0) {
|
|
112
|
+
// Trigger click on active item
|
|
113
|
+
const activeEl = containerRef.current?.querySelector(`[data-result-index="${activeIndex}"]`);
|
|
114
|
+
if (activeEl) {
|
|
115
|
+
activeEl.click();
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case 'Escape':
|
|
120
|
+
setActiveIndex(-1);
|
|
121
|
+
containerRef.current?.blur();
|
|
122
|
+
break;
|
|
123
|
+
case 'Home':
|
|
124
|
+
e.preventDefault();
|
|
125
|
+
setActiveIndex(0);
|
|
126
|
+
break;
|
|
127
|
+
case 'End':
|
|
128
|
+
e.preventDefault();
|
|
129
|
+
setActiveIndex(maxIndex);
|
|
130
|
+
break;
|
|
131
|
+
}
|
|
132
|
+
}, [enableKeyboardNavigation, activeIndex]);
|
|
133
|
+
const defaultRenderResultList = (result, index, isActive = false) => {
|
|
134
|
+
const handleClick = async () => {
|
|
135
|
+
// Track analytics event if enabled
|
|
136
|
+
if (enableAnalytics && result.id) {
|
|
137
|
+
try {
|
|
138
|
+
const results = resultsProp || stateResults;
|
|
139
|
+
const state = { currentPage, itemsPerPage: stateItemsPerPage };
|
|
140
|
+
// Calculate absolute position (1-based) accounting for pagination
|
|
141
|
+
const absolutePosition = (state.currentPage - 1) * state.itemsPerPage + index + 1;
|
|
142
|
+
const searchContext = results?.context;
|
|
143
|
+
if (client.trackClick) {
|
|
144
|
+
await client.trackClick(result.id, absolutePosition, searchContext);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
await client.trackEvent?.({
|
|
148
|
+
event_name: 'product_click',
|
|
149
|
+
clicked_item_id: result.id,
|
|
150
|
+
metadata: { result, position: absolutePosition },
|
|
151
|
+
}, searchContext);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
catch (err) {
|
|
155
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
156
|
+
log.error('SearchResults: Error tracking click', { resultId: result.id, error: error.message });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
// Call user-provided callback
|
|
160
|
+
if (onResultClick) {
|
|
161
|
+
onResultClick(result, index);
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
return (React.createElement("div", { key: result.id || index, "data-result-index": index, className: clsx(searchResultsTheme.resultItem, isActive && searchResultsTheme.resultItemHover), onClick: handleClick, onMouseEnter: () => enableKeyboardNavigation && setActiveIndex(index), style: {
|
|
165
|
+
padding: theme.spacing.medium,
|
|
166
|
+
border: `1px solid ${theme.colors.border}`,
|
|
167
|
+
borderBottom: `1px solid ${theme.colors.border}`,
|
|
168
|
+
borderRadius: 0,
|
|
169
|
+
marginBottom: 0,
|
|
170
|
+
cursor: onResultClick ? 'pointer' : 'default',
|
|
171
|
+
transition: theme.transitions?.normal || '250ms ease-in-out',
|
|
172
|
+
backgroundColor: isActive ? theme.colors.hover : theme.colors.background,
|
|
173
|
+
display: 'flex',
|
|
174
|
+
alignItems: 'flex-start',
|
|
175
|
+
gap: theme.spacing.medium,
|
|
176
|
+
outline: isActive ? `2px solid ${theme.colors.primary}` : 'none',
|
|
177
|
+
outlineOffset: '-2px',
|
|
178
|
+
} },
|
|
179
|
+
result.image && (React.createElement("img", { src: result.image, alt: result.title, className: searchResultsTheme.resultImage, style: {
|
|
180
|
+
width: '100px',
|
|
181
|
+
height: '100px',
|
|
182
|
+
objectFit: 'cover',
|
|
183
|
+
borderRadius: typeof theme.borderRadius === 'string' ? theme.borderRadius : theme.borderRadius.medium,
|
|
184
|
+
flexShrink: 0,
|
|
185
|
+
} })),
|
|
186
|
+
React.createElement("div", { style: { flex: 1, minWidth: 0 } },
|
|
187
|
+
React.createElement("h3", { className: searchResultsTheme.resultTitle, style: {
|
|
188
|
+
fontSize: theme.typography.fontSize.large,
|
|
189
|
+
fontWeight: 'bold',
|
|
190
|
+
margin: 0,
|
|
191
|
+
marginBottom: theme.spacing.small,
|
|
192
|
+
color: theme.colors.text,
|
|
193
|
+
} }, result.title),
|
|
194
|
+
result.description && (React.createElement("p", { className: searchResultsTheme.resultDescription, style: {
|
|
195
|
+
fontSize: theme.typography.fontSize.medium,
|
|
196
|
+
color: theme.colors.text,
|
|
197
|
+
margin: 0,
|
|
198
|
+
marginBottom: theme.spacing.small,
|
|
199
|
+
opacity: 0.8,
|
|
200
|
+
} }, result.description)),
|
|
201
|
+
result.price && (React.createElement("div", { className: searchResultsTheme.resultPrice, style: {
|
|
202
|
+
fontSize: theme.typography.fontSize.medium,
|
|
203
|
+
fontWeight: 'bold',
|
|
204
|
+
color: theme.colors.primary,
|
|
205
|
+
} }, result.price)))));
|
|
206
|
+
};
|
|
207
|
+
const defaultRenderResultCard = (result, index, isActive = false) => {
|
|
208
|
+
const handleClick = async () => {
|
|
209
|
+
// Track analytics event if enabled
|
|
210
|
+
if (enableAnalytics && result.id) {
|
|
211
|
+
try {
|
|
212
|
+
const results = resultsProp || stateResults;
|
|
213
|
+
const state = { currentPage, itemsPerPage: stateItemsPerPage };
|
|
214
|
+
// Calculate absolute position (1-based) accounting for pagination
|
|
215
|
+
const absolutePosition = (state.currentPage - 1) * state.itemsPerPage + index + 1;
|
|
216
|
+
const searchContext = results?.context;
|
|
217
|
+
if (client.trackClick) {
|
|
218
|
+
await client.trackClick(result.id, absolutePosition, searchContext);
|
|
219
|
+
}
|
|
220
|
+
else {
|
|
221
|
+
await client.trackEvent?.({
|
|
222
|
+
event_name: 'product_click',
|
|
223
|
+
clicked_item_id: result.id,
|
|
224
|
+
metadata: { result, position: absolutePosition },
|
|
225
|
+
}, searchContext);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
catch (err) {
|
|
229
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
230
|
+
log.error('SearchResults: Error tracking click', { resultId: result.id, error: error.message });
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Call user-provided callback
|
|
234
|
+
if (onResultClick) {
|
|
235
|
+
onResultClick(result, index);
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
// Use widget view fields if available, otherwise fall back to regular fields
|
|
239
|
+
const primaryText = result.primaryText || result.title;
|
|
240
|
+
const secondaryText = result.secondaryText || result.description;
|
|
241
|
+
const tertiaryText = result.tertiaryText || result.price;
|
|
242
|
+
const imageUrl = result.imageUrl || result.image;
|
|
243
|
+
return (React.createElement("div", { key: result.id || index, "data-result-index": index, className: clsx(searchResultsTheme.resultItem, isActive && searchResultsTheme.resultItemHover), onClick: handleClick, onMouseEnter: () => enableKeyboardNavigation && setActiveIndex(index), style: {
|
|
244
|
+
border: `1px solid ${isActive ? theme.colors.primary : theme.colors.border}`,
|
|
245
|
+
borderRadius: typeof theme.borderRadius === 'string' ? theme.borderRadius : theme.borderRadius.medium,
|
|
246
|
+
overflow: 'hidden',
|
|
247
|
+
cursor: onResultClick ? 'pointer' : 'default',
|
|
248
|
+
transition: theme.transitions?.normal || '250ms ease-in-out',
|
|
249
|
+
backgroundColor: isActive ? theme.colors.hover : theme.colors.background,
|
|
250
|
+
display: 'flex',
|
|
251
|
+
flexDirection: 'column',
|
|
252
|
+
padding: theme.spacing.medium,
|
|
253
|
+
boxShadow: isActive ? theme.shadows.medium : theme.shadows.small,
|
|
254
|
+
outline: isActive ? `2px solid ${theme.colors.primary}` : 'none',
|
|
255
|
+
outlineOffset: '-2px',
|
|
256
|
+
} },
|
|
257
|
+
imageUrl && (React.createElement("div", { style: {
|
|
258
|
+
width: '100%',
|
|
259
|
+
aspectRatio: '16/9',
|
|
260
|
+
overflow: 'hidden',
|
|
261
|
+
backgroundColor: theme.colors.hover,
|
|
262
|
+
} },
|
|
263
|
+
React.createElement("img", { src: imageUrl, alt: primaryText, style: {
|
|
264
|
+
width: '100%',
|
|
265
|
+
height: '100%',
|
|
266
|
+
objectFit: 'cover',
|
|
267
|
+
} }))),
|
|
268
|
+
React.createElement("div", { style: { padding: theme.spacing.medium } },
|
|
269
|
+
primaryText && (React.createElement("h3", { className: searchResultsTheme.resultTitle, style: {
|
|
270
|
+
fontSize: theme.typography.fontSize.large,
|
|
271
|
+
fontWeight: 'bold',
|
|
272
|
+
margin: 0,
|
|
273
|
+
marginBottom: theme.spacing.small,
|
|
274
|
+
color: theme.colors.text,
|
|
275
|
+
} }, primaryText)),
|
|
276
|
+
secondaryText && (React.createElement("p", { className: searchResultsTheme.resultDescription, style: {
|
|
277
|
+
fontSize: theme.typography.fontSize.medium,
|
|
278
|
+
color: theme.colors.text,
|
|
279
|
+
margin: 0,
|
|
280
|
+
marginBottom: theme.spacing.small,
|
|
281
|
+
opacity: 0.8,
|
|
282
|
+
display: '-webkit-box',
|
|
283
|
+
WebkitLineClamp: 2,
|
|
284
|
+
WebkitBoxOrient: 'vertical',
|
|
285
|
+
overflow: 'hidden',
|
|
286
|
+
} }, secondaryText)),
|
|
287
|
+
tertiaryText && (React.createElement("div", { className: searchResultsTheme.resultPrice, style: {
|
|
288
|
+
fontSize: theme.typography.fontSize.medium,
|
|
289
|
+
fontWeight: 'bold',
|
|
290
|
+
color: theme.colors.primary,
|
|
291
|
+
marginTop: 'auto',
|
|
292
|
+
} }, tertiaryText)))));
|
|
293
|
+
};
|
|
294
|
+
const defaultRenderResult = viewMode === 'card' || viewMode === 'grid'
|
|
295
|
+
? defaultRenderResultCard
|
|
296
|
+
: defaultRenderResultList;
|
|
297
|
+
const defaultRenderEmpty = () => (React.createElement("div", { className: searchResultsTheme.emptyState, style: {
|
|
298
|
+
padding: theme.spacing.large,
|
|
299
|
+
textAlign: 'center',
|
|
300
|
+
color: theme.colors.text,
|
|
301
|
+
} }, "No results found"));
|
|
302
|
+
const defaultRenderError = (err) => (React.createElement("div", { className: searchResultsTheme.errorState, style: {
|
|
303
|
+
padding: theme.spacing.large,
|
|
304
|
+
textAlign: 'center',
|
|
305
|
+
color: theme.colors.error,
|
|
306
|
+
} },
|
|
307
|
+
"Error: ",
|
|
308
|
+
err.message));
|
|
309
|
+
// Extract results array from response
|
|
310
|
+
let rawResults = [];
|
|
311
|
+
if (extractResults) {
|
|
312
|
+
// Use custom extraction function if provided
|
|
313
|
+
rawResults = extractResults(results) || [];
|
|
314
|
+
}
|
|
315
|
+
else if (results) {
|
|
316
|
+
const res = results;
|
|
317
|
+
if (Array.isArray(res.results) && res.results.length > 0) {
|
|
318
|
+
rawResults = res.results;
|
|
319
|
+
}
|
|
320
|
+
else if (res.data && Array.isArray(res.data.results) && res.data.results.length > 0) {
|
|
321
|
+
rawResults = res.data.results;
|
|
322
|
+
}
|
|
323
|
+
else if (res.data?.data && Array.isArray(res.data.data.results) && res.data.data.results.length > 0) {
|
|
324
|
+
rawResults = res.data.data.results;
|
|
325
|
+
}
|
|
326
|
+
else if (Array.isArray(results)) {
|
|
327
|
+
rawResults = results;
|
|
328
|
+
}
|
|
329
|
+
else if (Array.isArray(res.results)) {
|
|
330
|
+
rawResults = res.results;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
// Default field mapping (can be overridden via props)
|
|
334
|
+
const defaultFieldMapping = {
|
|
335
|
+
title: 'document.productName',
|
|
336
|
+
description: 'document.brandDesc',
|
|
337
|
+
image: 'document.image',
|
|
338
|
+
price: 'document.mrp',
|
|
339
|
+
url: 'document.url',
|
|
340
|
+
id: 'id',
|
|
341
|
+
...fieldMapping,
|
|
342
|
+
};
|
|
343
|
+
// Extract field value using dot notation path
|
|
344
|
+
const extractField = (item, path) => {
|
|
345
|
+
if (!path)
|
|
346
|
+
return undefined;
|
|
347
|
+
return getNestedValue(item, path);
|
|
348
|
+
};
|
|
349
|
+
const resultItems = rawResults.map((item, index) => {
|
|
350
|
+
try {
|
|
351
|
+
// Widget view fields (when widget_mode is enabled) - check these first
|
|
352
|
+
const primaryText = extractField(item, defaultFieldMapping.primaryText);
|
|
353
|
+
const secondaryText = extractField(item, defaultFieldMapping.secondaryText);
|
|
354
|
+
const tertiaryText = extractField(item, defaultFieldMapping.tertiaryText);
|
|
355
|
+
const imageUrl = extractField(item, defaultFieldMapping.imageUrl);
|
|
356
|
+
// Use primaryText as fallback for title if title is not found
|
|
357
|
+
const title = extractField(item, defaultFieldMapping.title) || primaryText || 'Untitled';
|
|
358
|
+
const description = extractField(item, defaultFieldMapping.description) || secondaryText;
|
|
359
|
+
const image = extractField(item, defaultFieldMapping.image) || imageUrl;
|
|
360
|
+
const priceValue = extractField(item, defaultFieldMapping.price) || tertiaryText;
|
|
361
|
+
const url = extractField(item, defaultFieldMapping.url);
|
|
362
|
+
const id = extractField(item, defaultFieldMapping.id) || String(index);
|
|
363
|
+
// Format price if it's a number
|
|
364
|
+
const price = priceValue !== undefined ? formatPrice(priceValue) : undefined;
|
|
365
|
+
// Extract custom fields if configured
|
|
366
|
+
const customFields = {};
|
|
367
|
+
if (defaultFieldMapping.custom) {
|
|
368
|
+
Object.entries(defaultFieldMapping.custom).forEach(([key, path]) => {
|
|
369
|
+
customFields[key] = extractField(item, path);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
const resultItem = {
|
|
373
|
+
id,
|
|
374
|
+
title,
|
|
375
|
+
description,
|
|
376
|
+
url,
|
|
377
|
+
image,
|
|
378
|
+
price,
|
|
379
|
+
metadata: item,
|
|
380
|
+
...customFields,
|
|
381
|
+
// Widget view fields
|
|
382
|
+
...(primaryText && { primaryText }),
|
|
383
|
+
...(secondaryText && { secondaryText }),
|
|
384
|
+
...(tertiaryText && { tertiaryText }),
|
|
385
|
+
...(imageUrl && { imageUrl }),
|
|
386
|
+
// Include original item for full access
|
|
387
|
+
_raw: item,
|
|
388
|
+
};
|
|
389
|
+
return resultItem;
|
|
390
|
+
}
|
|
391
|
+
catch (err) {
|
|
392
|
+
const error = err instanceof Error ? err : new Error(String(err));
|
|
393
|
+
log.warn('SearchResults: Error extracting result item', {
|
|
394
|
+
index,
|
|
395
|
+
error: error.message,
|
|
396
|
+
item: item?.id || 'unknown',
|
|
397
|
+
});
|
|
398
|
+
// Return a fallback result item
|
|
399
|
+
return {
|
|
400
|
+
id: String(index),
|
|
401
|
+
title: 'Error loading result',
|
|
402
|
+
metadata: item,
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
// Determine container style based on view mode
|
|
407
|
+
const containerStyle = {
|
|
408
|
+
minHeight: `var(--seekora-results-min-height, ${minHeight})`,
|
|
409
|
+
minWidth: `var(--seekora-results-min-width, ${minWidth})`,
|
|
410
|
+
...style,
|
|
411
|
+
};
|
|
412
|
+
// Determine results list style based on view mode
|
|
413
|
+
const resultsListStyle = {
|
|
414
|
+
...(viewMode === 'grid' && {
|
|
415
|
+
display: 'grid',
|
|
416
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))',
|
|
417
|
+
gap: theme.spacing.medium,
|
|
418
|
+
}),
|
|
419
|
+
...(viewMode === 'card' && {
|
|
420
|
+
display: 'grid',
|
|
421
|
+
gridTemplateColumns: 'repeat(auto-fill, minmax(280px, 1fr))',
|
|
422
|
+
gap: theme.spacing.medium,
|
|
423
|
+
}),
|
|
424
|
+
};
|
|
425
|
+
// Log results extraction
|
|
426
|
+
log.verbose('SearchResults: Extracted results', {
|
|
427
|
+
rawResultsCount: rawResults.length,
|
|
428
|
+
resultItemsCount: resultItems.length,
|
|
429
|
+
viewMode,
|
|
430
|
+
hasError: !!error,
|
|
431
|
+
isLoading: loading,
|
|
432
|
+
});
|
|
433
|
+
if (error) {
|
|
434
|
+
log.error('SearchResults: Rendering error state', {
|
|
435
|
+
error: error.message,
|
|
436
|
+
stack: error.stack,
|
|
437
|
+
});
|
|
438
|
+
return (React.createElement("div", { className: clsx(searchResultsTheme.container, className), style: containerStyle }, renderError ? renderError(error) : defaultRenderError(error)));
|
|
439
|
+
}
|
|
440
|
+
if (!results || resultItems.length === 0) {
|
|
441
|
+
log.verbose('SearchResults: No results to display');
|
|
442
|
+
return (React.createElement("div", { className: clsx(searchResultsTheme.container, className), style: containerStyle }, renderEmpty ? renderEmpty() : defaultRenderEmpty()));
|
|
443
|
+
}
|
|
444
|
+
const renderFn = renderResult || defaultRenderResult;
|
|
445
|
+
return (React.createElement("div", { ref: containerRef, className: clsx(searchResultsTheme.container, className), style: containerStyle, tabIndex: enableKeyboardNavigation ? 0 : undefined, onKeyDown: handleKeyDown, role: "listbox", "aria-label": "Search results", "aria-activedescendant": activeIndex >= 0 ? `result-${activeIndex}` : undefined },
|
|
446
|
+
(results?.totalResults !== undefined || results?.data?.total_results !== undefined) && resultItems.length > 0 && (React.createElement("div", { className: searchResultsTheme.header, style: {
|
|
447
|
+
marginBottom: theme.spacing.medium,
|
|
448
|
+
fontSize: theme.typography.fontSize.medium,
|
|
449
|
+
color: theme.colors.text,
|
|
450
|
+
} },
|
|
451
|
+
"Found ",
|
|
452
|
+
results?.totalResults || results?.data?.total_results || 0,
|
|
453
|
+
" result",
|
|
454
|
+
(results?.totalResults || results?.data?.total_results || 0) !== 1 ? 's' : '')),
|
|
455
|
+
React.createElement("div", { className: searchResultsTheme.resultsList, style: resultsListStyle }, resultItems.map((result, index) => renderFn(result, index, index === activeIndex)))));
|
|
456
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SortBy Component
|
|
3
|
+
*
|
|
4
|
+
* Displays sort options for search results in multiple display variants:
|
|
5
|
+
* - dropdown (default) — native select element
|
|
6
|
+
* - button-group — horizontal row of toggle buttons
|
|
7
|
+
* - radio-group — vertical list of radio inputs
|
|
8
|
+
*
|
|
9
|
+
* Integrates with SearchStateManager for automatic state sync.
|
|
10
|
+
*
|
|
11
|
+
* CSS Variables (apply on a parent element to customize):
|
|
12
|
+
* --seekora-sort-bg — background color
|
|
13
|
+
* --seekora-sort-color — text color
|
|
14
|
+
* --seekora-sort-border — border color
|
|
15
|
+
* --seekora-sort-active-bg — active item background
|
|
16
|
+
* --seekora-sort-active-color — active item text color
|
|
17
|
+
*/
|
|
18
|
+
import React from 'react';
|
|
19
|
+
export interface SortOption {
|
|
20
|
+
value: string;
|
|
21
|
+
label: string;
|
|
22
|
+
}
|
|
23
|
+
export type SortByVariant = 'dropdown' | 'button-group' | 'radio-group';
|
|
24
|
+
export type SortBySize = 'small' | 'medium' | 'large';
|
|
25
|
+
export interface SortByTheme {
|
|
26
|
+
/** Root container */
|
|
27
|
+
container?: string;
|
|
28
|
+
/** Dropdown select element */
|
|
29
|
+
select?: string;
|
|
30
|
+
/** Dropdown option element */
|
|
31
|
+
option?: string;
|
|
32
|
+
/** Optional label above the control */
|
|
33
|
+
label?: string;
|
|
34
|
+
/** Button group wrapper */
|
|
35
|
+
buttonGroup?: string;
|
|
36
|
+
/** Individual button in the group */
|
|
37
|
+
buttonGroupItem?: string;
|
|
38
|
+
/** Active button in the group */
|
|
39
|
+
buttonGroupItemActive?: string;
|
|
40
|
+
/** Radio group wrapper */
|
|
41
|
+
radioGroup?: string;
|
|
42
|
+
/** Individual radio row (input + label) */
|
|
43
|
+
radioItem?: string;
|
|
44
|
+
/** Active radio row */
|
|
45
|
+
radioItemActive?: string;
|
|
46
|
+
/** Radio label text */
|
|
47
|
+
radioLabel?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface SortByProps {
|
|
50
|
+
/** Available sort options */
|
|
51
|
+
options: SortOption[];
|
|
52
|
+
/** Current sort value (controlled mode - overrides StateManager) */
|
|
53
|
+
value?: string;
|
|
54
|
+
/** Default sort value */
|
|
55
|
+
defaultValue?: string;
|
|
56
|
+
/** Callback when sort changes */
|
|
57
|
+
onSortChange?: (value: string) => void;
|
|
58
|
+
/** Custom render function for select (only used in dropdown variant) */
|
|
59
|
+
renderSelect?: (props: {
|
|
60
|
+
value: string;
|
|
61
|
+
onChange: (e: React.ChangeEvent<HTMLSelectElement>) => void;
|
|
62
|
+
options: SortOption[];
|
|
63
|
+
}) => React.ReactNode;
|
|
64
|
+
/** Custom className */
|
|
65
|
+
className?: string;
|
|
66
|
+
/** Custom styles */
|
|
67
|
+
style?: React.CSSProperties;
|
|
68
|
+
/** Custom theme */
|
|
69
|
+
theme?: SortByTheme;
|
|
70
|
+
/** Placeholder text (dropdown variant) */
|
|
71
|
+
placeholder?: string;
|
|
72
|
+
/** Whether to sync with SearchStateManager (default: true) */
|
|
73
|
+
syncWithState?: boolean;
|
|
74
|
+
/** Display variant (default: 'dropdown') */
|
|
75
|
+
variant?: SortByVariant;
|
|
76
|
+
/** Optional label text displayed above the control */
|
|
77
|
+
label?: string;
|
|
78
|
+
/** Whether to show the label (default: true when label is provided) */
|
|
79
|
+
showLabel?: boolean;
|
|
80
|
+
/** Size variant affecting padding and font size (default: 'medium') */
|
|
81
|
+
size?: SortBySize;
|
|
82
|
+
}
|
|
83
|
+
export declare const SortBy: React.FC<SortByProps>;
|
|
84
|
+
//# sourceMappingURL=SortBy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SortBy.d.ts","sourceRoot":"","sources":["../../src/components/SortBy.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAwC,MAAM,OAAO,CAAC;AAU7D,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,cAAc,GAAG,aAAa,CAAC;AACxE,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEtD,MAAM,WAAW,WAAW;IAC1B,qBAAqB;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,iCAAiC;IACjC,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,0BAA0B;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,2CAA2C;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uBAAuB;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uBAAuB;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,6BAA6B;IAC7B,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,wEAAwE;IACxE,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE;QACrB,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,WAAW,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;QAC5D,OAAO,EAAE,UAAU,EAAE,CAAC;KACvB,KAAK,KAAK,CAAC,SAAS,CAAC;IACtB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,oBAAoB;IACpB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,mBAAmB;IACnB,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8DAA8D;IAC9D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uEAAuE;IACvE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uEAAuE;IACvE,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AA8BD,eAAO,MAAM,MAAM,EAAE,KAAK,CAAC,EAAE,CAAC,WAAW,CAuRxC,CAAC"}
|