@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,547 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SpotlightDropdown - macOS Spotlight / Command Palette Style
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Clean, centered modal design
|
|
6
|
+
* - Category grouping with keyboard navigation
|
|
7
|
+
* - Instant preview panel
|
|
8
|
+
* - Actions/commands support
|
|
9
|
+
* - Keyboard-first interaction
|
|
10
|
+
*/
|
|
11
|
+
import React, { useState, useRef, useCallback, forwardRef, useImperativeHandle, useMemo, useEffect, } from 'react';
|
|
12
|
+
import { extractSuggestion, extractProduct, formatPrice, highlightText, cx, mergeStyles, generateCSSVariables, scrollIntoViewIfNeeded, } from './utils';
|
|
13
|
+
import { useResponsive } from './styles/responsive';
|
|
14
|
+
import { useInjectResponsiveStyles } from './styles';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Styles
|
|
17
|
+
// ============================================================================
|
|
18
|
+
const createStyles = () => ({
|
|
19
|
+
overlay: {
|
|
20
|
+
position: 'fixed',
|
|
21
|
+
top: 0,
|
|
22
|
+
left: 0,
|
|
23
|
+
right: 0,
|
|
24
|
+
bottom: 0,
|
|
25
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
26
|
+
backdropFilter: 'blur(4px)',
|
|
27
|
+
display: 'flex',
|
|
28
|
+
alignItems: 'flex-start',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
paddingTop: '15vh',
|
|
31
|
+
zIndex: 9999,
|
|
32
|
+
},
|
|
33
|
+
root: {
|
|
34
|
+
backgroundColor: 'var(--seekora-bg-surface, rgba(255, 255, 255, 0.95))',
|
|
35
|
+
borderRadius: 'var(--seekora-border-radius, 12px)',
|
|
36
|
+
boxShadow: '0 25px 50px -12px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255,255,255,0.1)',
|
|
37
|
+
overflow: 'hidden',
|
|
38
|
+
fontFamily: 'var(--seekora-font-family, -apple-system, BlinkMacSystemFont, "SF Pro Display", sans-serif)',
|
|
39
|
+
fontSize: 'var(--seekora-font-size, 14px)',
|
|
40
|
+
backdropFilter: 'blur(20px)',
|
|
41
|
+
},
|
|
42
|
+
searchContainer: {
|
|
43
|
+
display: 'flex',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
padding: '12px 16px',
|
|
46
|
+
gap: '12px',
|
|
47
|
+
borderBottom: '1px solid var(--seekora-border-color, rgba(0,0,0,0.1))',
|
|
48
|
+
},
|
|
49
|
+
searchIcon: {
|
|
50
|
+
display: 'flex',
|
|
51
|
+
alignItems: 'center',
|
|
52
|
+
justifyContent: 'center',
|
|
53
|
+
color: 'var(--seekora-text-tertiary, #86868b)',
|
|
54
|
+
flexShrink: 0,
|
|
55
|
+
},
|
|
56
|
+
searchInput: {
|
|
57
|
+
flex: 1,
|
|
58
|
+
border: 'none',
|
|
59
|
+
background: 'transparent',
|
|
60
|
+
fontSize: '17px',
|
|
61
|
+
fontWeight: 300,
|
|
62
|
+
color: 'var(--seekora-text-primary, #1d1d1f)',
|
|
63
|
+
outline: 'none',
|
|
64
|
+
fontFamily: 'inherit',
|
|
65
|
+
},
|
|
66
|
+
shortcut: {
|
|
67
|
+
display: 'flex',
|
|
68
|
+
alignItems: 'center',
|
|
69
|
+
gap: '4px',
|
|
70
|
+
fontSize: '12px',
|
|
71
|
+
color: 'var(--seekora-text-tertiary, #86868b)',
|
|
72
|
+
},
|
|
73
|
+
kbd: {
|
|
74
|
+
display: 'inline-flex',
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
justifyContent: 'center',
|
|
77
|
+
minWidth: '20px',
|
|
78
|
+
height: '20px',
|
|
79
|
+
padding: '0 4px',
|
|
80
|
+
backgroundColor: 'var(--seekora-bg-tertiary, rgba(0,0,0,0.05))',
|
|
81
|
+
borderRadius: '4px',
|
|
82
|
+
fontSize: '11px',
|
|
83
|
+
fontFamily: 'SF Mono, Monaco, monospace',
|
|
84
|
+
},
|
|
85
|
+
content: {
|
|
86
|
+
display: 'flex',
|
|
87
|
+
maxHeight: '400px',
|
|
88
|
+
},
|
|
89
|
+
resultsColumn: {
|
|
90
|
+
flex: 1,
|
|
91
|
+
overflowY: 'auto',
|
|
92
|
+
minWidth: '300px',
|
|
93
|
+
},
|
|
94
|
+
previewColumn: {
|
|
95
|
+
width: '280px',
|
|
96
|
+
borderLeft: '1px solid var(--seekora-border-color, rgba(0,0,0,0.1))',
|
|
97
|
+
backgroundColor: 'var(--seekora-bg-secondary, rgba(0,0,0,0.02))',
|
|
98
|
+
display: 'flex',
|
|
99
|
+
flexDirection: 'column',
|
|
100
|
+
},
|
|
101
|
+
section: {
|
|
102
|
+
padding: '8px 0',
|
|
103
|
+
},
|
|
104
|
+
sectionTitle: {
|
|
105
|
+
padding: '8px 16px 6px',
|
|
106
|
+
fontSize: '11px',
|
|
107
|
+
fontWeight: 600,
|
|
108
|
+
color: 'var(--seekora-text-tertiary, #86868b)',
|
|
109
|
+
textTransform: 'uppercase',
|
|
110
|
+
letterSpacing: '0.5px',
|
|
111
|
+
},
|
|
112
|
+
item: {
|
|
113
|
+
display: 'flex',
|
|
114
|
+
alignItems: 'center',
|
|
115
|
+
padding: '8px 16px',
|
|
116
|
+
gap: '12px',
|
|
117
|
+
cursor: 'pointer',
|
|
118
|
+
transition: 'background-color 50ms',
|
|
119
|
+
margin: '0 8px',
|
|
120
|
+
borderRadius: '6px',
|
|
121
|
+
},
|
|
122
|
+
itemActive: {
|
|
123
|
+
backgroundColor: 'var(--seekora-primary, #007aff)',
|
|
124
|
+
color: 'var(--seekora-text-inverse, #ffffff)',
|
|
125
|
+
},
|
|
126
|
+
itemIcon: {
|
|
127
|
+
width: '32px',
|
|
128
|
+
height: '32px',
|
|
129
|
+
borderRadius: '6px',
|
|
130
|
+
backgroundColor: 'var(--seekora-bg-tertiary, #f5f5f7)',
|
|
131
|
+
display: 'flex',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
justifyContent: 'center',
|
|
134
|
+
color: 'var(--seekora-text-secondary, #515154)',
|
|
135
|
+
flexShrink: 0,
|
|
136
|
+
},
|
|
137
|
+
itemIconActive: {
|
|
138
|
+
backgroundColor: 'rgba(255,255,255,0.2)',
|
|
139
|
+
color: 'var(--seekora-text-inverse, #ffffff)',
|
|
140
|
+
},
|
|
141
|
+
itemIconImage: {
|
|
142
|
+
width: '100%',
|
|
143
|
+
height: '100%',
|
|
144
|
+
objectFit: 'cover',
|
|
145
|
+
borderRadius: '6px',
|
|
146
|
+
},
|
|
147
|
+
itemContent: {
|
|
148
|
+
flex: 1,
|
|
149
|
+
minWidth: 0,
|
|
150
|
+
},
|
|
151
|
+
itemTitle: {
|
|
152
|
+
fontSize: '13px',
|
|
153
|
+
fontWeight: 500,
|
|
154
|
+
color: 'var(--seekora-text-primary, #1d1d1f)',
|
|
155
|
+
whiteSpace: 'nowrap',
|
|
156
|
+
overflow: 'hidden',
|
|
157
|
+
textOverflow: 'ellipsis',
|
|
158
|
+
},
|
|
159
|
+
itemTitleActive: {
|
|
160
|
+
color: 'var(--seekora-text-inverse, #ffffff)',
|
|
161
|
+
},
|
|
162
|
+
itemSubtitle: {
|
|
163
|
+
fontSize: '11px',
|
|
164
|
+
color: 'var(--seekora-text-secondary, #86868b)',
|
|
165
|
+
whiteSpace: 'nowrap',
|
|
166
|
+
overflow: 'hidden',
|
|
167
|
+
textOverflow: 'ellipsis',
|
|
168
|
+
marginTop: '2px',
|
|
169
|
+
},
|
|
170
|
+
itemSubtitleActive: {
|
|
171
|
+
color: 'var(--seekora-text-inverse, #ffffff)',
|
|
172
|
+
opacity: 0.9,
|
|
173
|
+
},
|
|
174
|
+
itemAction: {
|
|
175
|
+
fontSize: '11px',
|
|
176
|
+
color: 'var(--seekora-text-tertiary, #86868b)',
|
|
177
|
+
opacity: 0,
|
|
178
|
+
transition: 'opacity 100ms',
|
|
179
|
+
},
|
|
180
|
+
itemActionVisible: {
|
|
181
|
+
opacity: 1,
|
|
182
|
+
},
|
|
183
|
+
itemActionActive: {
|
|
184
|
+
color: 'var(--seekora-text-inverse, #ffffff)',
|
|
185
|
+
opacity: 0.8,
|
|
186
|
+
},
|
|
187
|
+
previewContent: {
|
|
188
|
+
flex: 1,
|
|
189
|
+
padding: '16px',
|
|
190
|
+
display: 'flex',
|
|
191
|
+
flexDirection: 'column',
|
|
192
|
+
alignItems: 'center',
|
|
193
|
+
justifyContent: 'center',
|
|
194
|
+
},
|
|
195
|
+
previewImage: {
|
|
196
|
+
width: '160px',
|
|
197
|
+
height: '160px',
|
|
198
|
+
objectFit: 'contain',
|
|
199
|
+
borderRadius: '8px',
|
|
200
|
+
marginBottom: '16px',
|
|
201
|
+
backgroundColor: 'var(--seekora-bg-surface, #ffffff)',
|
|
202
|
+
boxShadow: '0 2px 8px rgba(0,0,0,0.1)',
|
|
203
|
+
},
|
|
204
|
+
previewTitle: {
|
|
205
|
+
fontSize: '14px',
|
|
206
|
+
fontWeight: 600,
|
|
207
|
+
color: 'var(--seekora-text-primary, #1d1d1f)',
|
|
208
|
+
textAlign: 'center',
|
|
209
|
+
marginBottom: '4px',
|
|
210
|
+
},
|
|
211
|
+
previewSubtitle: {
|
|
212
|
+
fontSize: '12px',
|
|
213
|
+
color: 'var(--seekora-text-secondary, #86868b)',
|
|
214
|
+
textAlign: 'center',
|
|
215
|
+
marginBottom: '8px',
|
|
216
|
+
},
|
|
217
|
+
previewPrice: {
|
|
218
|
+
fontSize: '18px',
|
|
219
|
+
fontWeight: 700,
|
|
220
|
+
color: 'var(--seekora-primary, #007aff)',
|
|
221
|
+
},
|
|
222
|
+
previewActions: {
|
|
223
|
+
display: 'flex',
|
|
224
|
+
gap: '8px',
|
|
225
|
+
marginTop: '16px',
|
|
226
|
+
},
|
|
227
|
+
previewAction: {
|
|
228
|
+
padding: '6px 12px',
|
|
229
|
+
fontSize: '12px',
|
|
230
|
+
fontWeight: 500,
|
|
231
|
+
borderRadius: '6px',
|
|
232
|
+
border: 'none',
|
|
233
|
+
cursor: 'pointer',
|
|
234
|
+
transition: 'all 100ms',
|
|
235
|
+
},
|
|
236
|
+
previewActionPrimary: {
|
|
237
|
+
backgroundColor: 'var(--seekora-primary, #007aff)',
|
|
238
|
+
color: 'var(--seekora-text-inverse, #ffffff)',
|
|
239
|
+
},
|
|
240
|
+
previewActionSecondary: {
|
|
241
|
+
backgroundColor: 'var(--seekora-bg-tertiary, #f5f5f7)',
|
|
242
|
+
color: 'var(--seekora-text-primary, #1d1d1f)',
|
|
243
|
+
},
|
|
244
|
+
footer: {
|
|
245
|
+
padding: '8px 16px',
|
|
246
|
+
borderTop: '1px solid var(--seekora-border-color, rgba(0,0,0,0.1))',
|
|
247
|
+
display: 'flex',
|
|
248
|
+
alignItems: 'center',
|
|
249
|
+
justifyContent: 'space-between',
|
|
250
|
+
backgroundColor: 'var(--seekora-bg-secondary, rgba(0,0,0,0.02))',
|
|
251
|
+
fontSize: '11px',
|
|
252
|
+
color: 'var(--seekora-text-tertiary, #86868b)',
|
|
253
|
+
},
|
|
254
|
+
footerActions: {
|
|
255
|
+
display: 'flex',
|
|
256
|
+
alignItems: 'center',
|
|
257
|
+
gap: '16px',
|
|
258
|
+
},
|
|
259
|
+
footerAction: {
|
|
260
|
+
display: 'flex',
|
|
261
|
+
alignItems: 'center',
|
|
262
|
+
gap: '4px',
|
|
263
|
+
},
|
|
264
|
+
loading: {
|
|
265
|
+
display: 'flex',
|
|
266
|
+
alignItems: 'center',
|
|
267
|
+
justifyContent: 'center',
|
|
268
|
+
padding: '40px',
|
|
269
|
+
color: 'var(--seekora-text-secondary, #86868b)',
|
|
270
|
+
},
|
|
271
|
+
spinner: {
|
|
272
|
+
width: '24px',
|
|
273
|
+
height: '24px',
|
|
274
|
+
border: '2px solid var(--seekora-border-color, #e5e5e5)',
|
|
275
|
+
borderTopColor: 'var(--seekora-primary, #007aff)',
|
|
276
|
+
borderRadius: '50%',
|
|
277
|
+
animation: 'seekora-spin 0.8s linear infinite',
|
|
278
|
+
},
|
|
279
|
+
empty: {
|
|
280
|
+
padding: '40px 20px',
|
|
281
|
+
textAlign: 'center',
|
|
282
|
+
color: 'var(--seekora-text-secondary, #86868b)',
|
|
283
|
+
},
|
|
284
|
+
});
|
|
285
|
+
// ============================================================================
|
|
286
|
+
// Icons
|
|
287
|
+
// ============================================================================
|
|
288
|
+
const SearchIcon = () => (React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "currentColor" },
|
|
289
|
+
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" })));
|
|
290
|
+
const CommandIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", width: "16", height: "16" },
|
|
291
|
+
React.createElement("path", { d: "M3.5 6A1.5 1.5 0 015 4.5h1.5A1.5 1.5 0 018 6v1.5H5A1.5 1.5 0 013.5 6zM8 6v8H5a1.5 1.5 0 110-3h3V8H5a1.5 1.5 0 010-3h3v1z" }),
|
|
292
|
+
React.createElement("path", { d: "M12 6v8h3a1.5 1.5 0 100-3h-3V8h3a1.5 1.5 0 100-3h-3v1z" }),
|
|
293
|
+
React.createElement("path", { d: "M16.5 6A1.5 1.5 0 0015 4.5h-1.5A1.5 1.5 0 0012 6v1.5h3A1.5 1.5 0 0016.5 6z" })));
|
|
294
|
+
const DocumentIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", width: "16", height: "16" },
|
|
295
|
+
React.createElement("path", { fillRule: "evenodd", d: "M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z", clipRule: "evenodd" })));
|
|
296
|
+
const ShoppingIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", width: "16", height: "16" },
|
|
297
|
+
React.createElement("path", { d: "M10 2a4 4 0 00-4 4v1H5a1 1 0 00-.994.89l-1 9A1 1 0 004 18h12a1 1 0 00.994-1.11l-1-9A1 1 0 0015 7h-1V6a4 4 0 00-4-4zm2 5V6a2 2 0 10-4 0v1h4zm-6 3a1 1 0 112 0 1 1 0 01-2 0zm7-1a1 1 0 100 2 1 1 0 000-2z" })));
|
|
298
|
+
const ClockIcon = () => (React.createElement("svg", { viewBox: "0 0 20 20", fill: "currentColor", width: "16", height: "16" },
|
|
299
|
+
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" })));
|
|
300
|
+
export const SpotlightDropdown = forwardRef(function SpotlightDropdown(props, ref) {
|
|
301
|
+
const { query, isOpen = true, loading = false, suggestions = [], products = [], recentSearches = [], suggestionFields = { query: 'query' }, productFields = { id: 'id', title: 'title' }, productDisplay = {}, theme = {}, showPreview = true, asOverlay = true, placeholder = 'Search...', showShortcuts = true, actions = [], width = '680px', maxHeight = '500px', zIndex = 9999, className, style, classNames = {}, inputRef, onSuggestionSelect, onProductClick, onRecentClick, onClose, onSearchSubmit, header, footer, renderLoading, renderEmpty, } = props;
|
|
302
|
+
// Inject global responsive styles
|
|
303
|
+
useInjectResponsiveStyles();
|
|
304
|
+
// Responsive state
|
|
305
|
+
const responsive = useResponsive();
|
|
306
|
+
const { isMobile } = responsive;
|
|
307
|
+
const styles = useMemo(() => createStyles(), []);
|
|
308
|
+
const containerRef = useRef(null);
|
|
309
|
+
const listRef = useRef(null);
|
|
310
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
311
|
+
// Process data
|
|
312
|
+
const processedSuggestions = useMemo(() => suggestions.map(s => extractSuggestion(s, suggestionFields)), [suggestions, suggestionFields]);
|
|
313
|
+
const processedProducts = useMemo(() => products.map(p => extractProduct(p, productFields)), [products, productFields]);
|
|
314
|
+
const recentQueries = useMemo(() => recentSearches.map(r => typeof r === 'string' ? r : r.query).slice(0, 3), [recentSearches]);
|
|
315
|
+
// Build flat list of all items
|
|
316
|
+
const allItems = useMemo(() => {
|
|
317
|
+
const items = [];
|
|
318
|
+
// Actions first
|
|
319
|
+
actions.forEach(action => {
|
|
320
|
+
items.push({
|
|
321
|
+
type: 'action',
|
|
322
|
+
id: action.id,
|
|
323
|
+
title: action.label,
|
|
324
|
+
icon: action.icon,
|
|
325
|
+
data: action,
|
|
326
|
+
});
|
|
327
|
+
});
|
|
328
|
+
// Recent searches
|
|
329
|
+
if (!query && recentQueries.length > 0) {
|
|
330
|
+
recentQueries.forEach((q, idx) => {
|
|
331
|
+
items.push({
|
|
332
|
+
type: 'recent',
|
|
333
|
+
id: `recent-${idx}`,
|
|
334
|
+
title: q,
|
|
335
|
+
icon: React.createElement(ClockIcon, null),
|
|
336
|
+
data: q,
|
|
337
|
+
});
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
// Suggestions
|
|
341
|
+
processedSuggestions.forEach((s, idx) => {
|
|
342
|
+
items.push({
|
|
343
|
+
type: 'suggestion',
|
|
344
|
+
id: s.id || `suggestion-${idx}`,
|
|
345
|
+
title: s.query,
|
|
346
|
+
icon: React.createElement(DocumentIcon, null),
|
|
347
|
+
data: s,
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
// Products
|
|
351
|
+
processedProducts.forEach((p, idx) => {
|
|
352
|
+
items.push({
|
|
353
|
+
type: 'product',
|
|
354
|
+
id: p.id,
|
|
355
|
+
title: p.title,
|
|
356
|
+
subtitle: p.brand,
|
|
357
|
+
icon: React.createElement(ShoppingIcon, null),
|
|
358
|
+
image: p.image,
|
|
359
|
+
price: p.price,
|
|
360
|
+
data: p,
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
return items;
|
|
364
|
+
}, [actions, query, recentQueries, processedSuggestions, processedProducts]);
|
|
365
|
+
// Navigation
|
|
366
|
+
const navigateNext = useCallback(() => {
|
|
367
|
+
setActiveIndex(prev => Math.min(prev + 1, allItems.length - 1));
|
|
368
|
+
}, [allItems.length]);
|
|
369
|
+
const navigatePrevious = useCallback(() => {
|
|
370
|
+
setActiveIndex(prev => Math.max(prev - 1, -1));
|
|
371
|
+
}, []);
|
|
372
|
+
const selectActive = useCallback(() => {
|
|
373
|
+
if (activeIndex < 0) {
|
|
374
|
+
// No selection, submit current query
|
|
375
|
+
if (query.trim())
|
|
376
|
+
onSearchSubmit?.(query.trim());
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
const item = allItems[activeIndex];
|
|
380
|
+
if (!item)
|
|
381
|
+
return;
|
|
382
|
+
switch (item.type) {
|
|
383
|
+
case 'action':
|
|
384
|
+
item.data.onAction?.();
|
|
385
|
+
break;
|
|
386
|
+
case 'recent':
|
|
387
|
+
onRecentClick?.(item.data);
|
|
388
|
+
break;
|
|
389
|
+
case 'suggestion':
|
|
390
|
+
onSuggestionSelect?.(item.data._raw, activeIndex);
|
|
391
|
+
break;
|
|
392
|
+
case 'product':
|
|
393
|
+
onProductClick?.(item.data._raw, activeIndex);
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
}, [activeIndex, allItems, query, onSearchSubmit, onRecentClick, onSuggestionSelect, onProductClick]);
|
|
397
|
+
// Expose ref
|
|
398
|
+
useImperativeHandle(ref, () => ({
|
|
399
|
+
getActiveIndex: () => activeIndex,
|
|
400
|
+
setActiveIndex,
|
|
401
|
+
selectActive,
|
|
402
|
+
navigateNext,
|
|
403
|
+
navigatePrevious,
|
|
404
|
+
focus: () => inputRef?.current?.focus(),
|
|
405
|
+
close: () => onClose?.(),
|
|
406
|
+
}), [activeIndex, selectActive, navigateNext, navigatePrevious, inputRef, onClose]);
|
|
407
|
+
// Scroll active item into view
|
|
408
|
+
useEffect(() => {
|
|
409
|
+
if (listRef.current && activeIndex >= 0) {
|
|
410
|
+
const activeEl = listRef.current.querySelector(`[data-index="${activeIndex}"]`);
|
|
411
|
+
if (activeEl) {
|
|
412
|
+
scrollIntoViewIfNeeded(activeEl, listRef.current);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
}, [activeIndex]);
|
|
416
|
+
// Reset index when query changes
|
|
417
|
+
useEffect(() => {
|
|
418
|
+
setActiveIndex(-1);
|
|
419
|
+
}, [query]);
|
|
420
|
+
if (!isOpen)
|
|
421
|
+
return null;
|
|
422
|
+
const cssVariables = generateCSSVariables(theme);
|
|
423
|
+
const activeItem = allItems[activeIndex];
|
|
424
|
+
const content = (React.createElement("div", { ref: containerRef, className: cx('seekora-spotlight-dropdown', className, classNames.root), style: mergeStyles(styles.root, { width, zIndex: asOverlay ? undefined : zIndex }, cssVariables, style) },
|
|
425
|
+
React.createElement("style", null, `
|
|
426
|
+
@keyframes seekora-spin {
|
|
427
|
+
to { transform: rotate(360deg); }
|
|
428
|
+
}
|
|
429
|
+
`),
|
|
430
|
+
React.createElement("div", { style: styles.searchContainer },
|
|
431
|
+
React.createElement("div", { style: styles.searchIcon },
|
|
432
|
+
React.createElement(SearchIcon, null)),
|
|
433
|
+
React.createElement("input", { ref: inputRef, type: "text", placeholder: placeholder, defaultValue: query, style: styles.searchInput, onChange: (e) => onSearchSubmit?.(e.target.value), onKeyDown: (e) => {
|
|
434
|
+
if (e.key === 'ArrowDown') {
|
|
435
|
+
e.preventDefault();
|
|
436
|
+
navigateNext();
|
|
437
|
+
}
|
|
438
|
+
else if (e.key === 'ArrowUp') {
|
|
439
|
+
e.preventDefault();
|
|
440
|
+
navigatePrevious();
|
|
441
|
+
}
|
|
442
|
+
else if (e.key === 'Enter') {
|
|
443
|
+
e.preventDefault();
|
|
444
|
+
selectActive();
|
|
445
|
+
}
|
|
446
|
+
else if (e.key === 'Escape') {
|
|
447
|
+
onClose?.();
|
|
448
|
+
}
|
|
449
|
+
}, autoFocus: true }),
|
|
450
|
+
showShortcuts && (React.createElement("div", { style: styles.shortcut },
|
|
451
|
+
React.createElement("span", { style: styles.kbd }, "\u2318"),
|
|
452
|
+
React.createElement("span", { style: styles.kbd }, "K")))),
|
|
453
|
+
header,
|
|
454
|
+
React.createElement("div", { style: styles.content },
|
|
455
|
+
React.createElement("div", { ref: listRef, style: { ...styles.resultsColumn, maxHeight } }, loading ? (renderLoading ? renderLoading() : (React.createElement("div", { style: styles.loading },
|
|
456
|
+
React.createElement("div", { style: styles.spinner })))) : allItems.length === 0 ? (renderEmpty ? renderEmpty(query) : (React.createElement("div", { style: styles.empty },
|
|
457
|
+
"No results for \"",
|
|
458
|
+
query,
|
|
459
|
+
"\""))) : (React.createElement(React.Fragment, null,
|
|
460
|
+
actions.length > 0 && (React.createElement("div", { style: styles.section },
|
|
461
|
+
React.createElement("div", { style: styles.sectionTitle }, "Actions"),
|
|
462
|
+
allItems.filter(i => i.type === 'action').map((item) => {
|
|
463
|
+
const idx = allItems.indexOf(item);
|
|
464
|
+
const isActive = activeIndex === idx;
|
|
465
|
+
return (React.createElement("div", { key: item.id, "data-index": idx, style: mergeStyles(styles.item, isActive ? styles.itemActive : undefined), onClick: () => {
|
|
466
|
+
setActiveIndex(idx);
|
|
467
|
+
selectActive();
|
|
468
|
+
}, onMouseEnter: () => setActiveIndex(idx) },
|
|
469
|
+
React.createElement("div", { style: mergeStyles(styles.itemIcon, isActive ? styles.itemIconActive : undefined) }, item.icon),
|
|
470
|
+
React.createElement("div", { style: styles.itemContent },
|
|
471
|
+
React.createElement("div", { style: mergeStyles(styles.itemTitle, isActive ? styles.itemTitleActive : undefined) }, item.title))));
|
|
472
|
+
}))),
|
|
473
|
+
recentQueries.length > 0 && !query && (React.createElement("div", { style: styles.section },
|
|
474
|
+
React.createElement("div", { style: styles.sectionTitle }, "Recent"),
|
|
475
|
+
allItems.filter(i => i.type === 'recent').map((item) => {
|
|
476
|
+
const idx = allItems.indexOf(item);
|
|
477
|
+
const isActive = activeIndex === idx;
|
|
478
|
+
return (React.createElement("div", { key: item.id, "data-index": idx, style: mergeStyles(styles.item, isActive ? styles.itemActive : undefined), onClick: () => {
|
|
479
|
+
setActiveIndex(idx);
|
|
480
|
+
onRecentClick?.(item.data);
|
|
481
|
+
}, onMouseEnter: () => setActiveIndex(idx) },
|
|
482
|
+
React.createElement("div", { style: mergeStyles(styles.itemIcon, isActive ? styles.itemIconActive : undefined) }, item.icon),
|
|
483
|
+
React.createElement("div", { style: styles.itemContent },
|
|
484
|
+
React.createElement("div", { style: mergeStyles(styles.itemTitle, isActive ? styles.itemTitleActive : undefined) }, item.title))));
|
|
485
|
+
}))),
|
|
486
|
+
processedSuggestions.length > 0 && (React.createElement("div", { style: styles.section },
|
|
487
|
+
React.createElement("div", { style: styles.sectionTitle }, "Suggestions"),
|
|
488
|
+
allItems.filter(i => i.type === 'suggestion').map((item) => {
|
|
489
|
+
const idx = allItems.indexOf(item);
|
|
490
|
+
const isActive = activeIndex === idx;
|
|
491
|
+
return (React.createElement("div", { key: item.id, "data-index": idx, style: mergeStyles(styles.item, isActive ? styles.itemActive : undefined), onClick: () => {
|
|
492
|
+
setActiveIndex(idx);
|
|
493
|
+
onSuggestionSelect?.(item.data._raw, idx);
|
|
494
|
+
}, onMouseEnter: () => setActiveIndex(idx) },
|
|
495
|
+
React.createElement("div", { style: mergeStyles(styles.itemIcon, isActive ? styles.itemIconActive : undefined) }, item.icon),
|
|
496
|
+
React.createElement("div", { style: styles.itemContent },
|
|
497
|
+
React.createElement("div", { style: mergeStyles(styles.itemTitle, isActive ? styles.itemTitleActive : undefined), dangerouslySetInnerHTML: {
|
|
498
|
+
__html: highlightText(item.title, query, { tag: 'strong' })
|
|
499
|
+
} }))));
|
|
500
|
+
}))),
|
|
501
|
+
processedProducts.length > 0 && (React.createElement("div", { style: styles.section },
|
|
502
|
+
React.createElement("div", { style: styles.sectionTitle }, "Products"),
|
|
503
|
+
allItems.filter(i => i.type === 'product').map((item) => {
|
|
504
|
+
const idx = allItems.indexOf(item);
|
|
505
|
+
const isActive = activeIndex === idx;
|
|
506
|
+
return (React.createElement("div", { key: item.id, "data-index": idx, style: mergeStyles(styles.item, isActive ? styles.itemActive : undefined), onClick: () => {
|
|
507
|
+
setActiveIndex(idx);
|
|
508
|
+
onProductClick?.(item.data._raw, idx);
|
|
509
|
+
}, onMouseEnter: () => setActiveIndex(idx) },
|
|
510
|
+
React.createElement("div", { style: mergeStyles(styles.itemIcon, isActive ? styles.itemIconActive : undefined) }, item.image ? (React.createElement("img", { src: item.image, alt: "", style: styles.itemIconImage })) : (item.icon)),
|
|
511
|
+
React.createElement("div", { style: styles.itemContent },
|
|
512
|
+
React.createElement("div", { style: mergeStyles(styles.itemTitle, isActive ? styles.itemTitleActive : undefined) }, item.title),
|
|
513
|
+
item.subtitle && (React.createElement("div", { style: mergeStyles(styles.itemSubtitle, isActive ? styles.itemSubtitleActive : undefined) }, item.subtitle))),
|
|
514
|
+
item.price !== undefined && (React.createElement("span", { style: mergeStyles(styles.itemAction, styles.itemActionVisible, isActive ? styles.itemActionActive : undefined) }, formatPrice(item.price, { currency: productDisplay.currency })))));
|
|
515
|
+
})))))),
|
|
516
|
+
showPreview && activeItem && activeItem.type === 'product' && (React.createElement("div", { style: styles.previewColumn },
|
|
517
|
+
React.createElement("div", { style: styles.previewContent },
|
|
518
|
+
activeItem.image && (React.createElement("img", { src: activeItem.image, alt: "", style: styles.previewImage })),
|
|
519
|
+
React.createElement("div", { style: styles.previewTitle }, activeItem.title),
|
|
520
|
+
activeItem.subtitle && (React.createElement("div", { style: styles.previewSubtitle }, activeItem.subtitle)),
|
|
521
|
+
activeItem.price !== undefined && (React.createElement("div", { style: styles.previewPrice }, formatPrice(activeItem.price, { currency: productDisplay.currency }))),
|
|
522
|
+
React.createElement("div", { style: styles.previewActions },
|
|
523
|
+
React.createElement("button", { style: { ...styles.previewAction, ...styles.previewActionPrimary }, onClick: () => onProductClick?.(activeItem.data._raw, activeIndex) }, "View Product")))))),
|
|
524
|
+
footer !== undefined ? footer : (React.createElement("div", { style: styles.footer },
|
|
525
|
+
React.createElement("div", { style: styles.footerActions },
|
|
526
|
+
React.createElement("span", { style: styles.footerAction },
|
|
527
|
+
React.createElement("span", { style: styles.kbd }, "\u2191"),
|
|
528
|
+
React.createElement("span", { style: styles.kbd }, "\u2193"),
|
|
529
|
+
"navigate"),
|
|
530
|
+
React.createElement("span", { style: styles.footerAction },
|
|
531
|
+
React.createElement("span", { style: styles.kbd }, "\u21B5"),
|
|
532
|
+
"select"),
|
|
533
|
+
React.createElement("span", { style: styles.footerAction },
|
|
534
|
+
React.createElement("span", { style: styles.kbd }, "esc"),
|
|
535
|
+
"close")),
|
|
536
|
+
React.createElement("span", null,
|
|
537
|
+
allItems.length,
|
|
538
|
+
" results")))));
|
|
539
|
+
if (asOverlay) {
|
|
540
|
+
return (React.createElement("div", { style: { ...styles.overlay, zIndex }, onClick: (e) => {
|
|
541
|
+
if (e.target === e.currentTarget)
|
|
542
|
+
onClose?.();
|
|
543
|
+
} }, content));
|
|
544
|
+
}
|
|
545
|
+
return content;
|
|
546
|
+
});
|
|
547
|
+
export default SpotlightDropdown;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SuggestionSearchBar - Unified Search Component with Premium Dropdowns
|
|
3
|
+
*
|
|
4
|
+
* A self-contained search component that:
|
|
5
|
+
* - Fetches suggestions from the API automatically
|
|
6
|
+
* - Parses responses internally (no user-side parsing needed)
|
|
7
|
+
* - Renders any of the 7 premium dropdown variants
|
|
8
|
+
* - Handles analytics tracking
|
|
9
|
+
* - Supports recent searches via localStorage
|
|
10
|
+
* - Fully responsive and mobile-ready
|
|
11
|
+
*
|
|
12
|
+
* Usage:
|
|
13
|
+
* ```tsx
|
|
14
|
+
* <SuggestionSearchBar
|
|
15
|
+
* client={seekoraClient}
|
|
16
|
+
* variant="amazon"
|
|
17
|
+
* onSearch={(query) => router.push(`/search?q=${query}`)}
|
|
18
|
+
* />
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
import React from 'react';
|
|
22
|
+
import type { SeekoraClient } from '@seekora-ai/search-sdk';
|
|
23
|
+
import type { SuggestionDropdownVariant, SuggestionFieldMapping, ProductFieldMapping, DropdownThemeConfig, AnalyticsConfig } from './types';
|
|
24
|
+
export interface SuggestionSearchBarProps {
|
|
25
|
+
/** Seekora client instance - REQUIRED */
|
|
26
|
+
client: SeekoraClient;
|
|
27
|
+
/** Dropdown variant to use */
|
|
28
|
+
variant?: SuggestionDropdownVariant;
|
|
29
|
+
/** Auto-select mobile variant on small screens */
|
|
30
|
+
autoMobileVariant?: boolean;
|
|
31
|
+
/** Placeholder text */
|
|
32
|
+
placeholder?: string;
|
|
33
|
+
/** Initial/default query */
|
|
34
|
+
defaultQuery?: string;
|
|
35
|
+
/** Controlled query value */
|
|
36
|
+
value?: string;
|
|
37
|
+
/** Min characters before fetching */
|
|
38
|
+
minQueryLength?: number;
|
|
39
|
+
/** Max suggestions to fetch */
|
|
40
|
+
maxSuggestions?: number;
|
|
41
|
+
/** Debounce delay in ms */
|
|
42
|
+
debounceMs?: number;
|
|
43
|
+
/** Include dropdown recommendations (products, tabs, trending) */
|
|
44
|
+
includeDropdownRecommendations?: boolean;
|
|
45
|
+
/** Include categories per suggestion */
|
|
46
|
+
includeCategories?: boolean;
|
|
47
|
+
/** Filtered tabs configuration */
|
|
48
|
+
filteredTabs?: Array<{
|
|
49
|
+
id?: string;
|
|
50
|
+
label: string;
|
|
51
|
+
filter: string;
|
|
52
|
+
}>;
|
|
53
|
+
/** Analytics tags */
|
|
54
|
+
analyticsTags?: string[];
|
|
55
|
+
/** Enable recent searches */
|
|
56
|
+
enableRecentSearches?: boolean;
|
|
57
|
+
/** Max recent searches to store */
|
|
58
|
+
maxRecentSearches?: number;
|
|
59
|
+
/** Show products in dropdown */
|
|
60
|
+
showProducts?: boolean;
|
|
61
|
+
/** Show trending when empty */
|
|
62
|
+
showTrendingOnEmpty?: boolean;
|
|
63
|
+
/** Enable analytics tracking */
|
|
64
|
+
enableAnalytics?: boolean;
|
|
65
|
+
/** Analytics configuration */
|
|
66
|
+
analyticsConfig?: AnalyticsConfig;
|
|
67
|
+
/** Map suggestion fields to your data */
|
|
68
|
+
suggestionFields?: SuggestionFieldMapping;
|
|
69
|
+
/** Map product fields to your data */
|
|
70
|
+
productFields?: ProductFieldMapping;
|
|
71
|
+
/** Theme configuration */
|
|
72
|
+
theme?: DropdownThemeConfig;
|
|
73
|
+
/** Called when search is submitted */
|
|
74
|
+
onSearch?: (query: string) => void;
|
|
75
|
+
/** Called when query changes */
|
|
76
|
+
onQueryChange?: (query: string) => void;
|
|
77
|
+
/** Called when a suggestion is selected */
|
|
78
|
+
onSuggestionSelect?: (suggestion: any, index: number) => void;
|
|
79
|
+
/** Called when a product is clicked */
|
|
80
|
+
onProductClick?: (product: any, index: number) => void;
|
|
81
|
+
/** Called when a category/tab is clicked */
|
|
82
|
+
onCategoryClick?: (category: any, index: number) => void;
|
|
83
|
+
/** Called when a tab is changed */
|
|
84
|
+
onTabChange?: (tabId: string) => void;
|
|
85
|
+
/** Container class name */
|
|
86
|
+
className?: string;
|
|
87
|
+
/** Container style */
|
|
88
|
+
style?: React.CSSProperties;
|
|
89
|
+
/** Input class name */
|
|
90
|
+
inputClassName?: string;
|
|
91
|
+
/** Dropdown width */
|
|
92
|
+
dropdownWidth?: string | number;
|
|
93
|
+
/** Dropdown max height */
|
|
94
|
+
dropdownMaxHeight?: string | number;
|
|
95
|
+
/** Z-index for dropdown */
|
|
96
|
+
zIndex?: number;
|
|
97
|
+
/** Enable caching for suggestions (reduces API calls) */
|
|
98
|
+
enableCache?: boolean;
|
|
99
|
+
/** Cache TTL in milliseconds (default: 30000 = 30 seconds) */
|
|
100
|
+
cacheTtlMs?: number;
|
|
101
|
+
/** Maximum cache entries (default: 100) */
|
|
102
|
+
cacheMaxSize?: number;
|
|
103
|
+
}
|
|
104
|
+
export interface SuggestionSearchBarRef {
|
|
105
|
+
focus: () => void;
|
|
106
|
+
blur: () => void;
|
|
107
|
+
clear: () => void;
|
|
108
|
+
getQuery: () => string;
|
|
109
|
+
setQuery: (query: string) => void;
|
|
110
|
+
openDropdown: () => void;
|
|
111
|
+
closeDropdown: () => void;
|
|
112
|
+
refresh: () => void;
|
|
113
|
+
/** Clear the suggestions cache */
|
|
114
|
+
clearCache: () => void;
|
|
115
|
+
/** Get cache statistics */
|
|
116
|
+
getCacheStats: () => {
|
|
117
|
+
size: number;
|
|
118
|
+
maxSize: number;
|
|
119
|
+
} | null;
|
|
120
|
+
}
|
|
121
|
+
export declare const SuggestionSearchBar: React.ForwardRefExoticComponent<SuggestionSearchBarProps & React.RefAttributes<SuggestionSearchBarRef>>;
|
|
122
|
+
export default SuggestionSearchBar;
|
|
123
|
+
//# sourceMappingURL=SuggestionSearchBar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SuggestionSearchBar.d.ts","sourceRoot":"","sources":["../../../src/components/suggestions/SuggestionSearchBar.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,KAAK,EACV,yBAAyB,EAGzB,sBAAsB,EACtB,mBAAmB,EACnB,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