@seekora-ai/ui-sdk-react 1.0.0
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 +80 -0
- package/dist/components/CurrentRefinements.d.ts +41 -0
- package/dist/components/CurrentRefinements.d.ts.map +1 -0
- package/dist/components/CurrentRefinements.js +83 -0
- package/dist/components/Facets.d.ts +53 -0
- package/dist/components/Facets.d.ts.map +1 -0
- package/dist/components/Facets.js +195 -0
- package/dist/components/FederatedDropdown.d.ts +92 -0
- package/dist/components/FederatedDropdown.d.ts.map +1 -0
- package/dist/components/FederatedDropdown.js +510 -0
- package/dist/components/HierarchicalMenu.d.ts +55 -0
- package/dist/components/HierarchicalMenu.d.ts.map +1 -0
- package/dist/components/HierarchicalMenu.js +168 -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 +72 -0
- package/dist/components/InfiniteHits.d.ts +56 -0
- package/dist/components/InfiniteHits.d.ts.map +1 -0
- package/dist/components/InfiniteHits.js +181 -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 +44 -0
- package/dist/components/Pagination.d.ts.map +1 -0
- package/dist/components/Pagination.js +142 -0
- package/dist/components/QuerySuggestions.d.ts +38 -0
- package/dist/components/QuerySuggestions.d.ts.map +1 -0
- package/dist/components/QuerySuggestions.js +86 -0
- package/dist/components/QuerySuggestionsDropdown.d.ts +86 -0
- package/dist/components/QuerySuggestionsDropdown.d.ts.map +1 -0
- package/dist/components/QuerySuggestionsDropdown.js +395 -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 +193 -0
- package/dist/components/Recommendations.d.ts +90 -0
- package/dist/components/Recommendations.d.ts.map +1 -0
- package/dist/components/Recommendations.js +270 -0
- package/dist/components/RichQuerySuggestions.d.ts +77 -0
- package/dist/components/RichQuerySuggestions.d.ts.map +1 -0
- package/dist/components/RichQuerySuggestions.js +492 -0
- package/dist/components/SearchBar.d.ts +40 -0
- package/dist/components/SearchBar.d.ts.map +1 -0
- package/dist/components/SearchBar.js +217 -0
- package/dist/components/SearchBarWithSuggestions.d.ts +99 -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 +56 -0
- package/dist/components/SearchProvider.d.ts +28 -0
- package/dist/components/SearchProvider.d.ts.map +1 -0
- package/dist/components/SearchProvider.js +43 -0
- package/dist/components/SearchResults.d.ts +51 -0
- package/dist/components/SearchResults.d.ts.map +1 -0
- package/dist/components/SearchResults.js +485 -0
- package/dist/components/SortBy.d.ts +44 -0
- package/dist/components/SortBy.d.ts.map +1 -0
- package/dist/components/SortBy.js +61 -0
- package/dist/components/Stats.d.ts +37 -0
- package/dist/components/Stats.d.ts.map +1 -0
- package/dist/components/Stats.js +52 -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 +529 -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 +370 -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 +314 -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 +485 -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 +450 -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 +451 -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 +547 -0
- package/dist/components/suggestions/SuggestionSearchBar.d.ts +123 -0
- package/dist/components/suggestions/SuggestionSearchBar.d.ts.map +1 -0
- package/dist/components/suggestions/SuggestionSearchBar.js +652 -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 +489 -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 +213 -0
- package/dist/components/suggestions/utils.d.ts.map +1 -0
- package/dist/components/suggestions/utils.js +514 -0
- package/dist/hooks/useAnalytics.d.ts +20 -0
- package/dist/hooks/useAnalytics.d.ts.map +1 -0
- package/dist/hooks/useAnalytics.js +62 -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/useQuerySuggestions.d.ts +21 -0
- package/dist/hooks/useQuerySuggestions.d.ts.map +1 -0
- package/dist/hooks/useQuerySuggestions.js +68 -0
- package/dist/hooks/useQuerySuggestionsEnhanced.d.ts +114 -0
- package/dist/hooks/useQuerySuggestionsEnhanced.d.ts.map +1 -0
- package/dist/hooks/useQuerySuggestionsEnhanced.js +376 -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 +91 -0
- package/dist/hooks/useSuggestionsAnalytics.d.ts.map +1 -0
- package/dist/hooks/useSuggestionsAnalytics.js +226 -0
- package/dist/index.d.ts +80 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/index.umd.js +1 -0
- package/dist/src/index.d.ts +2849 -0
- package/dist/src/index.esm.js +11679 -0
- package/dist/src/index.esm.js.map +1 -0
- package/dist/src/index.js +11761 -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/package.json +65 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RichQuerySuggestions Component
|
|
3
|
+
*
|
|
4
|
+
* Advanced multi-section dropdown with:
|
|
5
|
+
* - Suggestions with categories
|
|
6
|
+
* - Trending searches
|
|
7
|
+
* - Recent searches
|
|
8
|
+
* - Top searches (popular)
|
|
9
|
+
* - Related searches
|
|
10
|
+
* - Configurable sections
|
|
11
|
+
* - Rich styling options
|
|
12
|
+
*/
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import type { SuggestionItem, RecentSearch, TrendingSearch, SuggestionCategory, QuerySuggestionsClassNames, QuerySuggestionsEventHandlers, DropdownSectionConfig } from '@seekora-ai/ui-sdk-types';
|
|
15
|
+
export interface RichQuerySuggestionsProps extends QuerySuggestionsEventHandlers {
|
|
16
|
+
/** Current query string */
|
|
17
|
+
query: string;
|
|
18
|
+
/** Whether the dropdown is visible */
|
|
19
|
+
isOpen?: boolean;
|
|
20
|
+
/** Section configuration */
|
|
21
|
+
sections?: DropdownSectionConfig[];
|
|
22
|
+
/** Maximum suggestions per section */
|
|
23
|
+
maxSuggestionsPerSection?: number;
|
|
24
|
+
/** Minimum query length */
|
|
25
|
+
minQueryLength?: number;
|
|
26
|
+
/** Debounce delay in ms */
|
|
27
|
+
debounceMs?: number;
|
|
28
|
+
/** Include dropdown recommendations from API */
|
|
29
|
+
includeDropdownRecommendations?: boolean;
|
|
30
|
+
/** Include categories in suggestions */
|
|
31
|
+
includeCategories?: boolean;
|
|
32
|
+
/** Max categories per suggestion */
|
|
33
|
+
maxCategories?: number;
|
|
34
|
+
/** Show suggestion counts */
|
|
35
|
+
showCounts?: boolean;
|
|
36
|
+
/** Show category counts */
|
|
37
|
+
showCategoryCounts?: boolean;
|
|
38
|
+
/** Show section headers */
|
|
39
|
+
showSectionHeaders?: boolean;
|
|
40
|
+
/** Custom class names */
|
|
41
|
+
classNames?: QuerySuggestionsClassNames;
|
|
42
|
+
/** Custom CSS styles */
|
|
43
|
+
style?: React.CSSProperties;
|
|
44
|
+
/** Custom render for suggestion */
|
|
45
|
+
renderSuggestion?: (suggestion: SuggestionItem, isActive: boolean) => React.ReactNode;
|
|
46
|
+
/** Custom render for category pill */
|
|
47
|
+
renderCategory?: (category: SuggestionCategory) => React.ReactNode;
|
|
48
|
+
/** Custom render for trending item */
|
|
49
|
+
renderTrendingItem?: (item: TrendingSearch, index: number) => React.ReactNode;
|
|
50
|
+
/** Custom render for recent item */
|
|
51
|
+
renderRecentItem?: (item: RecentSearch) => React.ReactNode;
|
|
52
|
+
/** Custom header content */
|
|
53
|
+
header?: React.ReactNode;
|
|
54
|
+
/** Custom footer content */
|
|
55
|
+
footer?: React.ReactNode;
|
|
56
|
+
/** Dropdown width */
|
|
57
|
+
width?: string | number;
|
|
58
|
+
/** Dropdown max height */
|
|
59
|
+
maxHeight?: string | number;
|
|
60
|
+
/** Z-index */
|
|
61
|
+
zIndex?: number;
|
|
62
|
+
/** ARIA label */
|
|
63
|
+
ariaLabel?: string;
|
|
64
|
+
/** Analytics tags */
|
|
65
|
+
analyticsTags?: string[];
|
|
66
|
+
}
|
|
67
|
+
export interface RichQuerySuggestionsRef {
|
|
68
|
+
getActiveIndex: () => number;
|
|
69
|
+
setActiveIndex: (index: number) => void;
|
|
70
|
+
selectActive: () => void;
|
|
71
|
+
navigateNext: () => void;
|
|
72
|
+
navigatePrevious: () => void;
|
|
73
|
+
getTotalItems: () => number;
|
|
74
|
+
}
|
|
75
|
+
export declare const RichQuerySuggestions: React.ForwardRefExoticComponent<RichQuerySuggestionsProps & React.RefAttributes<RichQuerySuggestionsRef>>;
|
|
76
|
+
export default RichQuerySuggestions;
|
|
77
|
+
//# sourceMappingURL=RichQuerySuggestions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RichQuerySuggestions.d.ts","sourceRoot":"","sources":["../../src/components/RichQuerySuggestions.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAQN,MAAM,OAAO,CAAC;AAIf,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EACZ,cAAc,EAGd,kBAAkB,EAClB,0BAA0B,EAC1B,6BAA6B,EAE7B,qBAAqB,EACtB,MAAM,0BAA0B,CAAC;AAMlC,MAAM,WAAW,yBAA0B,SAAQ,6BAA6B;IAC9E,2BAA2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,sCAAsC;IACtC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4BAA4B;IAC5B,QAAQ,CAAC,EAAE,qBAAqB,EAAE,CAAC;IACnC,sCAAsC;IACtC,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,2BAA2B;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gDAAgD;IAChD,8BAA8B,CAAC,EAAE,OAAO,CAAC;IACzC,wCAAwC;IACxC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,oCAAoC;IACpC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6BAA6B;IAC7B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,yBAAyB;IACzB,UAAU,CAAC,EAAE,0BAA0B,CAAC;IACxC,wBAAwB;IACxB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,mCAAmC;IACnC,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,EAAE,OAAO,KAAK,KAAK,CAAC,SAAS,CAAC;IACtF,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,KAAK,CAAC,SAAS,CAAC;IACnE,sCAAsC;IACtC,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAC9E,oCAAoC;IACpC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,KAAK,CAAC,SAAS,CAAC;IAC3D,4BAA4B;IAC5B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,4BAA4B;IAC5B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,qBAAqB;IACrB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,0BAA0B;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,cAAc;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qBAAqB;IACrB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,MAAM,MAAM,CAAC;IAC7B,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,MAAM,CAAC;CAC7B;AAqPD,eAAO,MAAM,oBAAoB,2GAkchC,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,492 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RichQuerySuggestions Component
|
|
3
|
+
*
|
|
4
|
+
* Advanced multi-section dropdown with:
|
|
5
|
+
* - Suggestions with categories
|
|
6
|
+
* - Trending searches
|
|
7
|
+
* - Recent searches
|
|
8
|
+
* - Top searches (popular)
|
|
9
|
+
* - Related searches
|
|
10
|
+
* - Configurable sections
|
|
11
|
+
* - Rich styling options
|
|
12
|
+
*/
|
|
13
|
+
import React, { useState, useRef, useCallback, useMemo, forwardRef, useImperativeHandle, } from 'react';
|
|
14
|
+
import { useSearchContext } from './SearchProvider';
|
|
15
|
+
import { useQuerySuggestionsEnhanced } from '../hooks/useQuerySuggestionsEnhanced';
|
|
16
|
+
import { clsx } from 'clsx';
|
|
17
|
+
// Default section order
|
|
18
|
+
const DEFAULT_SECTIONS = [
|
|
19
|
+
{ id: 'recent', title: 'Recent Searches', maxItems: 5, enabled: true, order: 1 },
|
|
20
|
+
{ id: 'suggestions', title: 'Suggestions', maxItems: 8, enabled: true, order: 2 },
|
|
21
|
+
{ id: 'trending', title: 'Trending', maxItems: 5, enabled: true, order: 3 },
|
|
22
|
+
{ id: 'categories', title: 'Categories', maxItems: 6, enabled: false, order: 4 },
|
|
23
|
+
];
|
|
24
|
+
// ============================================================================
|
|
25
|
+
// Styles
|
|
26
|
+
// ============================================================================
|
|
27
|
+
const styles = {
|
|
28
|
+
container: {
|
|
29
|
+
backgroundColor: 'var(--seekora-bg-surface, #ffffff)',
|
|
30
|
+
border: '1px solid var(--seekora-border-color, #e5e7eb)',
|
|
31
|
+
borderRadius: 'var(--seekora-border-radius-lg, 12px)',
|
|
32
|
+
boxShadow: 'var(--seekora-shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04))',
|
|
33
|
+
overflow: 'hidden',
|
|
34
|
+
},
|
|
35
|
+
header: {
|
|
36
|
+
padding: '12px 16px',
|
|
37
|
+
borderBottom: '1px solid var(--seekora-border-color, #e5e7eb)',
|
|
38
|
+
backgroundColor: 'var(--seekora-bg-secondary, #f9fafb)',
|
|
39
|
+
},
|
|
40
|
+
content: {
|
|
41
|
+
overflowY: 'auto',
|
|
42
|
+
overflowX: 'hidden',
|
|
43
|
+
},
|
|
44
|
+
section: {
|
|
45
|
+
padding: '8px 0',
|
|
46
|
+
},
|
|
47
|
+
sectionHeader: {
|
|
48
|
+
display: 'flex',
|
|
49
|
+
alignItems: 'center',
|
|
50
|
+
justifyContent: 'space-between',
|
|
51
|
+
padding: '8px 16px 4px',
|
|
52
|
+
},
|
|
53
|
+
sectionTitle: {
|
|
54
|
+
fontSize: '11px',
|
|
55
|
+
fontWeight: 600,
|
|
56
|
+
color: 'var(--seekora-text-tertiary, #9ca3af)',
|
|
57
|
+
textTransform: 'uppercase',
|
|
58
|
+
letterSpacing: '0.05em',
|
|
59
|
+
margin: 0,
|
|
60
|
+
},
|
|
61
|
+
sectionAction: {
|
|
62
|
+
fontSize: '12px',
|
|
63
|
+
color: 'var(--seekora-primary, #3b82f6)',
|
|
64
|
+
cursor: 'pointer',
|
|
65
|
+
textDecoration: 'none',
|
|
66
|
+
fontWeight: 500,
|
|
67
|
+
},
|
|
68
|
+
item: {
|
|
69
|
+
display: 'flex',
|
|
70
|
+
alignItems: 'flex-start',
|
|
71
|
+
padding: '10px 16px',
|
|
72
|
+
cursor: 'pointer',
|
|
73
|
+
transition: 'background-color 100ms ease',
|
|
74
|
+
gap: '12px',
|
|
75
|
+
},
|
|
76
|
+
itemActive: {
|
|
77
|
+
backgroundColor: 'var(--seekora-bg-hover, #f3f4f6)',
|
|
78
|
+
},
|
|
79
|
+
itemIcon: {
|
|
80
|
+
width: '18px',
|
|
81
|
+
height: '18px',
|
|
82
|
+
color: 'var(--seekora-text-secondary, #6b7280)',
|
|
83
|
+
flexShrink: 0,
|
|
84
|
+
marginTop: '2px',
|
|
85
|
+
},
|
|
86
|
+
itemContent: {
|
|
87
|
+
flex: 1,
|
|
88
|
+
minWidth: 0,
|
|
89
|
+
},
|
|
90
|
+
itemQuery: {
|
|
91
|
+
fontSize: '14px',
|
|
92
|
+
color: 'var(--seekora-text-primary, #111827)',
|
|
93
|
+
fontWeight: 500,
|
|
94
|
+
margin: 0,
|
|
95
|
+
overflow: 'hidden',
|
|
96
|
+
textOverflow: 'ellipsis',
|
|
97
|
+
whiteSpace: 'nowrap',
|
|
98
|
+
},
|
|
99
|
+
itemMeta: {
|
|
100
|
+
fontSize: '12px',
|
|
101
|
+
color: 'var(--seekora-text-secondary, #6b7280)',
|
|
102
|
+
marginTop: '2px',
|
|
103
|
+
},
|
|
104
|
+
itemCount: {
|
|
105
|
+
fontSize: '12px',
|
|
106
|
+
color: 'var(--seekora-text-tertiary, #9ca3af)',
|
|
107
|
+
flexShrink: 0,
|
|
108
|
+
},
|
|
109
|
+
categoriesContainer: {
|
|
110
|
+
display: 'flex',
|
|
111
|
+
flexWrap: 'wrap',
|
|
112
|
+
gap: '6px',
|
|
113
|
+
marginTop: '6px',
|
|
114
|
+
},
|
|
115
|
+
categoryPill: {
|
|
116
|
+
display: 'inline-flex',
|
|
117
|
+
alignItems: 'center',
|
|
118
|
+
gap: '4px',
|
|
119
|
+
padding: '3px 8px',
|
|
120
|
+
fontSize: '11px',
|
|
121
|
+
fontWeight: 500,
|
|
122
|
+
color: 'var(--seekora-text-secondary, #6b7280)',
|
|
123
|
+
backgroundColor: 'var(--seekora-bg-tertiary, #f3f4f6)',
|
|
124
|
+
borderRadius: '12px',
|
|
125
|
+
cursor: 'pointer',
|
|
126
|
+
transition: 'all 100ms ease',
|
|
127
|
+
},
|
|
128
|
+
categoryPillHover: {
|
|
129
|
+
backgroundColor: 'var(--seekora-primary-light, #dbeafe)',
|
|
130
|
+
color: 'var(--seekora-primary, #3b82f6)',
|
|
131
|
+
},
|
|
132
|
+
categoryCount: {
|
|
133
|
+
color: 'var(--seekora-text-tertiary, #9ca3af)',
|
|
134
|
+
},
|
|
135
|
+
trendingList: {
|
|
136
|
+
display: 'flex',
|
|
137
|
+
flexWrap: 'wrap',
|
|
138
|
+
gap: '8px',
|
|
139
|
+
padding: '8px 16px',
|
|
140
|
+
},
|
|
141
|
+
trendingChip: {
|
|
142
|
+
display: 'inline-flex',
|
|
143
|
+
alignItems: 'center',
|
|
144
|
+
gap: '6px',
|
|
145
|
+
padding: '6px 12px',
|
|
146
|
+
fontSize: '13px',
|
|
147
|
+
fontWeight: 500,
|
|
148
|
+
color: 'var(--seekora-text-primary, #374151)',
|
|
149
|
+
backgroundColor: 'var(--seekora-bg-secondary, #f3f4f6)',
|
|
150
|
+
border: '1px solid var(--seekora-border-color, #e5e7eb)',
|
|
151
|
+
borderRadius: '20px',
|
|
152
|
+
cursor: 'pointer',
|
|
153
|
+
transition: 'all 150ms ease',
|
|
154
|
+
},
|
|
155
|
+
trendingChipHover: {
|
|
156
|
+
borderColor: 'var(--seekora-primary, #3b82f6)',
|
|
157
|
+
backgroundColor: 'var(--seekora-primary-light, #eff6ff)',
|
|
158
|
+
},
|
|
159
|
+
trendingIcon: {
|
|
160
|
+
width: '14px',
|
|
161
|
+
height: '14px',
|
|
162
|
+
color: 'var(--seekora-success, #10b981)',
|
|
163
|
+
},
|
|
164
|
+
trendingRank: {
|
|
165
|
+
width: '18px',
|
|
166
|
+
height: '18px',
|
|
167
|
+
borderRadius: '50%',
|
|
168
|
+
backgroundColor: 'var(--seekora-primary, #3b82f6)',
|
|
169
|
+
color: 'white',
|
|
170
|
+
fontSize: '10px',
|
|
171
|
+
fontWeight: 600,
|
|
172
|
+
display: 'flex',
|
|
173
|
+
alignItems: 'center',
|
|
174
|
+
justifyContent: 'center',
|
|
175
|
+
},
|
|
176
|
+
removeButton: {
|
|
177
|
+
padding: '4px',
|
|
178
|
+
marginLeft: 'auto',
|
|
179
|
+
borderRadius: '4px',
|
|
180
|
+
border: 'none',
|
|
181
|
+
background: 'transparent',
|
|
182
|
+
cursor: 'pointer',
|
|
183
|
+
color: 'var(--seekora-text-tertiary, #9ca3af)',
|
|
184
|
+
opacity: 0,
|
|
185
|
+
transition: 'opacity 100ms ease',
|
|
186
|
+
},
|
|
187
|
+
divider: {
|
|
188
|
+
height: '1px',
|
|
189
|
+
backgroundColor: 'var(--seekora-border-color, #e5e7eb)',
|
|
190
|
+
margin: '4px 16px',
|
|
191
|
+
},
|
|
192
|
+
footer: {
|
|
193
|
+
padding: '12px 16px',
|
|
194
|
+
borderTop: '1px solid var(--seekora-border-color, #e5e7eb)',
|
|
195
|
+
backgroundColor: 'var(--seekora-bg-secondary, #f9fafb)',
|
|
196
|
+
fontSize: '12px',
|
|
197
|
+
color: 'var(--seekora-text-secondary, #6b7280)',
|
|
198
|
+
},
|
|
199
|
+
loadingOverlay: {
|
|
200
|
+
position: 'absolute',
|
|
201
|
+
inset: 0,
|
|
202
|
+
display: 'flex',
|
|
203
|
+
alignItems: 'center',
|
|
204
|
+
justifyContent: 'center',
|
|
205
|
+
backgroundColor: 'rgba(255, 255, 255, 0.8)',
|
|
206
|
+
},
|
|
207
|
+
emptyState: {
|
|
208
|
+
padding: '32px 16px',
|
|
209
|
+
textAlign: 'center',
|
|
210
|
+
color: 'var(--seekora-text-secondary, #6b7280)',
|
|
211
|
+
},
|
|
212
|
+
highlight: {
|
|
213
|
+
backgroundColor: 'var(--seekora-highlight-bg, #fef9c3)',
|
|
214
|
+
fontWeight: 600,
|
|
215
|
+
borderRadius: '2px',
|
|
216
|
+
padding: '0 1px',
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
// ============================================================================
|
|
220
|
+
// Icons
|
|
221
|
+
// ============================================================================
|
|
222
|
+
const SearchIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", style: styles.itemIcon },
|
|
223
|
+
React.createElement("path", { fillRule: "evenodd", d: "M8 4a4 4 0 100 8 4 4 0 000-8zM2 8a6 6 0 1110.89 3.476l4.817 4.817a1 1 0 01-1.414 1.414l-4.816-4.816A6 6 0 012 8z", clipRule: "evenodd" })));
|
|
224
|
+
const ClockIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", style: styles.itemIcon },
|
|
225
|
+
React.createElement("path", { fillRule: "evenodd", d: "M10 18a8 8 0 100-16 8 8 0 000 16zm1-12a1 1 0 10-2 0v4a1 1 0 00.293.707l2.828 2.829a1 1 0 101.415-1.415L11 9.586V6z", clipRule: "evenodd" })));
|
|
226
|
+
const TrendingIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", style: styles.trendingIcon },
|
|
227
|
+
React.createElement("path", { fillRule: "evenodd", d: "M12 7a1 1 0 110-2h5a1 1 0 011 1v5a1 1 0 11-2 0V8.414l-4.293 4.293a1 1 0 01-1.414 0L8 10.414l-4.293 4.293a1 1 0 01-1.414-1.414l5-5a1 1 0 011.414 0L11 10.586 14.586 7H12z", clipRule: "evenodd" })));
|
|
228
|
+
const ArrowIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", style: { width: 16, height: 16 } },
|
|
229
|
+
React.createElement("path", { fillRule: "evenodd", d: "M10.293 3.293a1 1 0 011.414 0l6 6a1 1 0 010 1.414l-6 6a1 1 0 01-1.414-1.414L14.586 11H3a1 1 0 110-2h11.586l-4.293-4.293a1 1 0 010-1.414z", clipRule: "evenodd" })));
|
|
230
|
+
const CloseIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", style: { width: 14, height: 14 } },
|
|
231
|
+
React.createElement("path", { fillRule: "evenodd", d: "M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z", clipRule: "evenodd" })));
|
|
232
|
+
// ============================================================================
|
|
233
|
+
// Component
|
|
234
|
+
// ============================================================================
|
|
235
|
+
export const RichQuerySuggestions = forwardRef(function RichQuerySuggestions(props, ref) {
|
|
236
|
+
const { query, isOpen = true, sections = DEFAULT_SECTIONS, maxSuggestionsPerSection = 8, minQueryLength = 0, debounceMs = 200, includeDropdownRecommendations = true, includeCategories = true, maxCategories = 3, showCounts = true, showCategoryCounts = true, showSectionHeaders = true, classNames = {}, style, renderSuggestion, renderCategory, renderTrendingItem, renderRecentItem, header, footer, width = '100%', maxHeight = '480px', zIndex = 1000, ariaLabel = 'Search suggestions', analyticsTags, onSuggestionSelect, onCategoryClick, onRecentSearchClick, onRecentSearchRemove, onViewAllClick, onOpen, onClose, } = props;
|
|
237
|
+
const { client } = useSearchContext();
|
|
238
|
+
const containerRef = useRef(null);
|
|
239
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
240
|
+
const [hoveredCategory, setHoveredCategory] = useState(null);
|
|
241
|
+
// Use enhanced hook
|
|
242
|
+
const { suggestions, loading, trendingSearches, topSearches, recentSearches, addRecentSearch, removeRecentSearch, hasContent, } = useQuerySuggestionsEnhanced({
|
|
243
|
+
client,
|
|
244
|
+
query,
|
|
245
|
+
enabled: isOpen,
|
|
246
|
+
debounceMs,
|
|
247
|
+
maxSuggestions: maxSuggestionsPerSection,
|
|
248
|
+
minQueryLength,
|
|
249
|
+
includeDropdownRecommendations,
|
|
250
|
+
includeCategories,
|
|
251
|
+
maxCategories,
|
|
252
|
+
analyticsTags,
|
|
253
|
+
enableRecentSearches: true,
|
|
254
|
+
});
|
|
255
|
+
// Sort and filter sections
|
|
256
|
+
const enabledSections = useMemo(() => {
|
|
257
|
+
return sections
|
|
258
|
+
.filter(s => s.enabled !== false)
|
|
259
|
+
.sort((a, b) => (a.order || 0) - (b.order || 0));
|
|
260
|
+
}, [sections]);
|
|
261
|
+
// Get section config
|
|
262
|
+
const getSectionConfig = (id) => {
|
|
263
|
+
return enabledSections.find(s => s.id === id);
|
|
264
|
+
};
|
|
265
|
+
// Build flat list of all navigable items
|
|
266
|
+
const allItems = useMemo(() => {
|
|
267
|
+
const items = [];
|
|
268
|
+
enabledSections.forEach((section, sectionIndex) => {
|
|
269
|
+
switch (section.id) {
|
|
270
|
+
case 'recent':
|
|
271
|
+
if (query.length === 0) {
|
|
272
|
+
recentSearches.slice(0, section.maxItems || 5).forEach(search => {
|
|
273
|
+
items.push({ type: 'recent', data: search, sectionIndex });
|
|
274
|
+
});
|
|
275
|
+
}
|
|
276
|
+
break;
|
|
277
|
+
case 'suggestions':
|
|
278
|
+
suggestions.slice(0, section.maxItems || maxSuggestionsPerSection).forEach(suggestion => {
|
|
279
|
+
items.push({ type: 'suggestion', data: suggestion, sectionIndex });
|
|
280
|
+
});
|
|
281
|
+
break;
|
|
282
|
+
case 'trending':
|
|
283
|
+
if (query.length === 0) {
|
|
284
|
+
(trendingSearches.length > 0 ? trendingSearches : topSearches)
|
|
285
|
+
.slice(0, section.maxItems || 5)
|
|
286
|
+
.forEach(trending => {
|
|
287
|
+
items.push({ type: 'trending', data: trending, sectionIndex });
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
break;
|
|
291
|
+
}
|
|
292
|
+
});
|
|
293
|
+
return items;
|
|
294
|
+
}, [enabledSections, query, recentSearches, suggestions, trendingSearches, topSearches, maxSuggestionsPerSection]);
|
|
295
|
+
// Navigation functions
|
|
296
|
+
const navigateNext = useCallback(() => {
|
|
297
|
+
setActiveIndex(prev => (prev < allItems.length - 1 ? prev + 1 : 0));
|
|
298
|
+
}, [allItems.length]);
|
|
299
|
+
const navigatePrevious = useCallback(() => {
|
|
300
|
+
setActiveIndex(prev => (prev > 0 ? prev - 1 : allItems.length - 1));
|
|
301
|
+
}, [allItems.length]);
|
|
302
|
+
const selectActive = useCallback(() => {
|
|
303
|
+
if (activeIndex < 0 || activeIndex >= allItems.length)
|
|
304
|
+
return;
|
|
305
|
+
const item = allItems[activeIndex];
|
|
306
|
+
switch (item.type) {
|
|
307
|
+
case 'recent':
|
|
308
|
+
onRecentSearchClick?.(item.data);
|
|
309
|
+
break;
|
|
310
|
+
case 'suggestion':
|
|
311
|
+
onSuggestionSelect?.(item.data);
|
|
312
|
+
addRecentSearch(item.data.query, item.data.count);
|
|
313
|
+
break;
|
|
314
|
+
case 'trending':
|
|
315
|
+
onSuggestionSelect?.({ query: item.data.query, count: item.data.count });
|
|
316
|
+
addRecentSearch(item.data.query);
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
}, [activeIndex, allItems, onRecentSearchClick, onSuggestionSelect, addRecentSearch]);
|
|
320
|
+
// Expose ref methods
|
|
321
|
+
useImperativeHandle(ref, () => ({
|
|
322
|
+
getActiveIndex: () => activeIndex,
|
|
323
|
+
setActiveIndex,
|
|
324
|
+
selectActive,
|
|
325
|
+
navigateNext,
|
|
326
|
+
navigatePrevious,
|
|
327
|
+
getTotalItems: () => allItems.length,
|
|
328
|
+
}), [activeIndex, selectActive, navigateNext, navigatePrevious, allItems.length]);
|
|
329
|
+
// Highlight query in text
|
|
330
|
+
const highlightQuery = (text) => {
|
|
331
|
+
if (!query)
|
|
332
|
+
return text;
|
|
333
|
+
const parts = text.split(new RegExp(`(${query})`, 'gi'));
|
|
334
|
+
return parts.map((part, i) => part.toLowerCase() === query.toLowerCase() ? (React.createElement("span", { key: i, style: styles.highlight }, part)) : part);
|
|
335
|
+
};
|
|
336
|
+
// Get item index offset for a section
|
|
337
|
+
const getItemIndex = (sectionId, itemIndex) => {
|
|
338
|
+
let offset = 0;
|
|
339
|
+
for (const item of allItems) {
|
|
340
|
+
const sectionConfig = enabledSections[item.sectionIndex];
|
|
341
|
+
if (sectionConfig.id === sectionId) {
|
|
342
|
+
return offset + itemIndex;
|
|
343
|
+
}
|
|
344
|
+
if (item.sectionIndex < enabledSections.findIndex(s => s.id === sectionId)) {
|
|
345
|
+
offset++;
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
return offset + itemIndex;
|
|
349
|
+
};
|
|
350
|
+
// Render recent searches section
|
|
351
|
+
const renderRecentSection = () => {
|
|
352
|
+
const config = getSectionConfig('recent');
|
|
353
|
+
if (!config || query.length > 0 || recentSearches.length === 0)
|
|
354
|
+
return null;
|
|
355
|
+
return (React.createElement("div", { className: clsx('seekora-section', 'seekora-section-recent', classNames.section) },
|
|
356
|
+
showSectionHeaders && (React.createElement("div", { style: styles.sectionHeader },
|
|
357
|
+
React.createElement("h3", { style: styles.sectionTitle }, config.title || 'Recent Searches'),
|
|
358
|
+
recentSearches.length > (config.maxItems || 5) && (React.createElement("button", { style: styles.sectionAction, onClick: () => onViewAllClick?.('recent') }, "View all")))),
|
|
359
|
+
recentSearches.slice(0, config.maxItems || 5).map((search, index) => {
|
|
360
|
+
const itemIndex = getItemIndex('recent', index);
|
|
361
|
+
const isActive = activeIndex === itemIndex;
|
|
362
|
+
return (React.createElement("div", { key: `recent-${search.query}`, role: "option", "aria-selected": isActive, style: { ...styles.item, ...(isActive ? styles.itemActive : {}) }, onClick: () => {
|
|
363
|
+
onRecentSearchClick?.(search);
|
|
364
|
+
}, onMouseEnter: () => setActiveIndex(itemIndex), className: clsx(classNames.recentItem, isActive && classNames.suggestionItemActive) }, renderRecentItem ? renderRecentItem(search) : (React.createElement(React.Fragment, null,
|
|
365
|
+
React.createElement(ClockIcon, null),
|
|
366
|
+
React.createElement("div", { style: styles.itemContent },
|
|
367
|
+
React.createElement("p", { style: styles.itemQuery }, search.query)),
|
|
368
|
+
React.createElement("button", { style: styles.removeButton, onClick: (e) => {
|
|
369
|
+
e.stopPropagation();
|
|
370
|
+
removeRecentSearch(search.query);
|
|
371
|
+
onRecentSearchRemove?.(search);
|
|
372
|
+
}, "aria-label": "Remove" },
|
|
373
|
+
React.createElement(CloseIcon, null))))));
|
|
374
|
+
})));
|
|
375
|
+
};
|
|
376
|
+
// Render suggestions section
|
|
377
|
+
const renderSuggestionsSection = () => {
|
|
378
|
+
const config = getSectionConfig('suggestions');
|
|
379
|
+
if (!config || suggestions.length === 0)
|
|
380
|
+
return null;
|
|
381
|
+
return (React.createElement("div", { className: clsx('seekora-section', 'seekora-section-suggestions', classNames.section) },
|
|
382
|
+
showSectionHeaders && query.length > 0 && (React.createElement("div", { style: styles.sectionHeader },
|
|
383
|
+
React.createElement("h3", { style: styles.sectionTitle }, config.title || 'Suggestions'))),
|
|
384
|
+
suggestions.slice(0, config.maxItems || maxSuggestionsPerSection).map((suggestion, index) => {
|
|
385
|
+
const itemIndex = allItems.findIndex((item, idx) => item.type === 'suggestion' &&
|
|
386
|
+
allItems.slice(0, idx).filter(i => i.type === 'suggestion').length === index);
|
|
387
|
+
const isActive = activeIndex === itemIndex;
|
|
388
|
+
return (React.createElement("div", { key: suggestion.objectID || `suggestion-${index}`, role: "option", "aria-selected": isActive, style: { ...styles.item, ...(isActive ? styles.itemActive : {}) }, onClick: () => {
|
|
389
|
+
onSuggestionSelect?.(suggestion);
|
|
390
|
+
addRecentSearch(suggestion.query, suggestion.count);
|
|
391
|
+
}, onMouseEnter: () => setActiveIndex(itemIndex), className: clsx(classNames.suggestionItem, isActive && classNames.suggestionItemActive) }, renderSuggestion ? renderSuggestion(suggestion, isActive) : (React.createElement(React.Fragment, null,
|
|
392
|
+
React.createElement(SearchIcon, null),
|
|
393
|
+
React.createElement("div", { style: styles.itemContent },
|
|
394
|
+
React.createElement("p", { style: styles.itemQuery }, highlightQuery(suggestion.query)),
|
|
395
|
+
includeCategories && suggestion.categories && suggestion.categories.length > 0 && (React.createElement("div", { style: styles.categoriesContainer }, suggestion.categories.slice(0, maxCategories).map((category, catIndex) => (renderCategory ? renderCategory(category) : (React.createElement("span", { key: `cat-${catIndex}`, style: {
|
|
396
|
+
...styles.categoryPill,
|
|
397
|
+
...(hoveredCategory === category.value ? styles.categoryPillHover : {}),
|
|
398
|
+
}, onClick: (e) => {
|
|
399
|
+
e.stopPropagation();
|
|
400
|
+
onCategoryClick?.(category);
|
|
401
|
+
}, onMouseEnter: () => setHoveredCategory(category.value), onMouseLeave: () => setHoveredCategory(null) },
|
|
402
|
+
category.value,
|
|
403
|
+
showCategoryCounts && category.count !== undefined && (React.createElement("span", { style: styles.categoryCount },
|
|
404
|
+
"(",
|
|
405
|
+
category.count,
|
|
406
|
+
")"))))))))),
|
|
407
|
+
showCounts && suggestion.count !== undefined && (React.createElement("span", { style: styles.itemCount }, suggestion.count.toLocaleString()))))));
|
|
408
|
+
})));
|
|
409
|
+
};
|
|
410
|
+
// Render trending section
|
|
411
|
+
const renderTrendingSection = () => {
|
|
412
|
+
const config = getSectionConfig('trending');
|
|
413
|
+
const trending = trendingSearches.length > 0 ? trendingSearches : topSearches;
|
|
414
|
+
if (!config || query.length > 0 || trending.length === 0)
|
|
415
|
+
return null;
|
|
416
|
+
return (React.createElement("div", { className: clsx('seekora-section', 'seekora-section-trending', classNames.section) },
|
|
417
|
+
showSectionHeaders && (React.createElement("div", { style: styles.sectionHeader },
|
|
418
|
+
React.createElement("h3", { style: styles.sectionTitle }, config.title || 'Trending'))),
|
|
419
|
+
React.createElement("div", { style: styles.trendingList }, trending.slice(0, config.maxItems || 5).map((item, index) => {
|
|
420
|
+
const itemIndex = allItems.findIndex((navItem, idx) => navItem.type === 'trending' &&
|
|
421
|
+
allItems.slice(0, idx).filter(i => i.type === 'trending').length === index);
|
|
422
|
+
const isActive = activeIndex === itemIndex;
|
|
423
|
+
return renderTrendingItem ? renderTrendingItem(item, index) : (React.createElement("button", { key: `trending-${item.query}`, style: {
|
|
424
|
+
...styles.trendingChip,
|
|
425
|
+
...(isActive ? styles.trendingChipHover : {}),
|
|
426
|
+
}, onClick: () => {
|
|
427
|
+
onSuggestionSelect?.({
|
|
428
|
+
query: item.query,
|
|
429
|
+
count: item.count,
|
|
430
|
+
});
|
|
431
|
+
addRecentSearch(item.query);
|
|
432
|
+
}, onMouseEnter: () => setActiveIndex(itemIndex), className: clsx(classNames.trendingItem, isActive && classNames.suggestionItemActive) },
|
|
433
|
+
React.createElement("span", { style: styles.trendingRank }, index + 1),
|
|
434
|
+
React.createElement("span", null, item.query),
|
|
435
|
+
React.createElement(TrendingIcon, null)));
|
|
436
|
+
}))));
|
|
437
|
+
};
|
|
438
|
+
// Don't render if closed or no content
|
|
439
|
+
if (!isOpen)
|
|
440
|
+
return null;
|
|
441
|
+
const showContent = hasContent || loading || query.length === 0;
|
|
442
|
+
if (!showContent)
|
|
443
|
+
return null;
|
|
444
|
+
return (React.createElement("div", { ref: containerRef, role: "listbox", "aria-label": ariaLabel, className: clsx('seekora-rich-suggestions', classNames.root, classNames.container), style: {
|
|
445
|
+
position: 'absolute',
|
|
446
|
+
width,
|
|
447
|
+
zIndex,
|
|
448
|
+
...styles.container,
|
|
449
|
+
...style,
|
|
450
|
+
} },
|
|
451
|
+
header && React.createElement("div", { style: styles.header }, header),
|
|
452
|
+
React.createElement("div", { style: { ...styles.content, maxHeight } },
|
|
453
|
+
loading && (React.createElement("div", { style: styles.loadingOverlay },
|
|
454
|
+
React.createElement("span", null, "Loading..."))),
|
|
455
|
+
enabledSections.map((section, index) => {
|
|
456
|
+
let content = null;
|
|
457
|
+
switch (section.id) {
|
|
458
|
+
case 'recent':
|
|
459
|
+
content = renderRecentSection();
|
|
460
|
+
break;
|
|
461
|
+
case 'suggestions':
|
|
462
|
+
content = renderSuggestionsSection();
|
|
463
|
+
break;
|
|
464
|
+
case 'trending':
|
|
465
|
+
content = renderTrendingSection();
|
|
466
|
+
break;
|
|
467
|
+
}
|
|
468
|
+
if (!content)
|
|
469
|
+
return null;
|
|
470
|
+
return (React.createElement(React.Fragment, { key: section.id },
|
|
471
|
+
index > 0 && React.createElement("div", { style: styles.divider }),
|
|
472
|
+
content));
|
|
473
|
+
}),
|
|
474
|
+
!loading && query.length > 0 && suggestions.length === 0 && (React.createElement("div", { style: styles.emptyState },
|
|
475
|
+
React.createElement("p", null,
|
|
476
|
+
"No suggestions found for \"",
|
|
477
|
+
query,
|
|
478
|
+
"\"")))),
|
|
479
|
+
footer && React.createElement("div", { style: styles.footer }, footer),
|
|
480
|
+
React.createElement("style", null, `
|
|
481
|
+
.seekora-rich-suggestions [role="option"]:hover button {
|
|
482
|
+
opacity: 1;
|
|
483
|
+
}
|
|
484
|
+
.seekora-rich-suggestions mark {
|
|
485
|
+
background-color: var(--seekora-highlight-bg, #fef9c3);
|
|
486
|
+
font-weight: 600;
|
|
487
|
+
border-radius: 2px;
|
|
488
|
+
padding: 0 1px;
|
|
489
|
+
}
|
|
490
|
+
`)));
|
|
491
|
+
});
|
|
492
|
+
export default RichQuerySuggestions;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchBar Component
|
|
3
|
+
*
|
|
4
|
+
* Interactive search input component with query suggestions support
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import type { SearchOptions } from '@seekora-ai/search-sdk';
|
|
8
|
+
export interface SearchBarTheme {
|
|
9
|
+
container?: string;
|
|
10
|
+
input?: string;
|
|
11
|
+
inputFocused?: string;
|
|
12
|
+
suggestionsContainer?: string;
|
|
13
|
+
suggestionItem?: string;
|
|
14
|
+
suggestionItemHover?: string;
|
|
15
|
+
suggestionItemActive?: string;
|
|
16
|
+
loadingIndicator?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface SearchBarProps {
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
showSuggestions?: boolean;
|
|
21
|
+
debounceMs?: number;
|
|
22
|
+
minQueryLength?: number;
|
|
23
|
+
maxSuggestions?: number;
|
|
24
|
+
onSearch?: (query: string, results: any) => void;
|
|
25
|
+
onQueryChange?: (query: string) => void;
|
|
26
|
+
onSuggestionSelect?: (suggestion: string) => void;
|
|
27
|
+
onSearchStateChange?: (state: {
|
|
28
|
+
results: any;
|
|
29
|
+
loading: boolean;
|
|
30
|
+
error: Error | null;
|
|
31
|
+
}) => void;
|
|
32
|
+
searchOptions?: Omit<SearchOptions, 'q'>;
|
|
33
|
+
className?: string;
|
|
34
|
+
style?: React.CSSProperties;
|
|
35
|
+
theme?: SearchBarTheme;
|
|
36
|
+
renderSuggestion?: (suggestion: string, index: number) => React.ReactNode;
|
|
37
|
+
renderLoading?: () => React.ReactNode;
|
|
38
|
+
}
|
|
39
|
+
export declare const SearchBar: React.FC<SearchBarProps>;
|
|
40
|
+
//# sourceMappingURL=SearchBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SearchBar.d.ts","sourceRoot":"","sources":["../../src/components/SearchBar.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAMxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,WAAW,cAAc;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACjD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACxC,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,IAAI,CAAC;IAClD,mBAAmB,CAAC,EAAE,CAAC,KAAK,EAAE;QAAE,OAAO,EAAE,GAAG,CAAC;QAAC,OAAO,EAAE,OAAO,CAAC;QAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAA;KAAE,KAAK,IAAI,CAAC;IAC/F,aAAa,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,gBAAgB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,KAAK,CAAC,SAAS,CAAC;IAC1E,aAAa,CAAC,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;CACvC;AAED,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAuT9C,CAAC"}
|