@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,451 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ShopifyDropdown - Modern E-commerce Style Suggestions
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Hero product with large image
|
|
6
|
+
* - Horizontal product scroll
|
|
7
|
+
* - Collection/category links
|
|
8
|
+
* - Clean, modern design
|
|
9
|
+
* - Quick add to cart
|
|
10
|
+
*/
|
|
11
|
+
import React, { useState, useRef, useCallback, forwardRef, useImperativeHandle, useMemo, useEffect, } from 'react';
|
|
12
|
+
import { extractSuggestion, extractProduct, extractCategory, formatPrice, highlightText, cx, mergeStyles, generateCSSVariables, calculateDiscount, scrollIntoViewIfNeeded, } from './utils';
|
|
13
|
+
import { useResponsive } from './styles/responsive';
|
|
14
|
+
import { useInjectResponsiveStyles } from './styles';
|
|
15
|
+
// ============================================================================
|
|
16
|
+
// Styles
|
|
17
|
+
// ============================================================================
|
|
18
|
+
const createStyles = (isMobile = false) => ({
|
|
19
|
+
root: {
|
|
20
|
+
position: isMobile ? 'fixed' : 'absolute',
|
|
21
|
+
top: isMobile ? 0 : '100%',
|
|
22
|
+
left: 0,
|
|
23
|
+
right: 0,
|
|
24
|
+
bottom: isMobile ? 0 : 'auto',
|
|
25
|
+
marginTop: isMobile ? 0 : '8px',
|
|
26
|
+
backgroundColor: 'var(--seekora-bg-surface, #ffffff)',
|
|
27
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
28
|
+
borderRadius: isMobile ? 0 : '16px',
|
|
29
|
+
boxShadow: isMobile ? 'none' : '0 4px 30px rgba(0, 0, 0, 0.12)',
|
|
30
|
+
overflow: 'hidden',
|
|
31
|
+
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
32
|
+
fontSize: isMobile ? '16px' : '14px',
|
|
33
|
+
display: 'flex',
|
|
34
|
+
flexDirection: 'column',
|
|
35
|
+
},
|
|
36
|
+
layout: {
|
|
37
|
+
display: isMobile ? 'flex' : 'grid',
|
|
38
|
+
flexDirection: 'column',
|
|
39
|
+
gridTemplateColumns: isMobile ? '1fr' : '1fr 1fr',
|
|
40
|
+
minHeight: isMobile ? 'auto' : '400px',
|
|
41
|
+
flex: 1,
|
|
42
|
+
overflowY: 'auto',
|
|
43
|
+
},
|
|
44
|
+
leftPanel: {
|
|
45
|
+
backgroundColor: 'var(--seekora-bg-surface, #ffffff)',
|
|
46
|
+
borderRight: isMobile ? 'none' : '1px solid var(--seekora-border-color, #e8e8e1)',
|
|
47
|
+
borderBottom: isMobile ? '1px solid var(--seekora-border-color, #e8e8e1)' : 'none',
|
|
48
|
+
display: 'flex',
|
|
49
|
+
flexDirection: 'column',
|
|
50
|
+
},
|
|
51
|
+
rightPanel: {
|
|
52
|
+
backgroundColor: 'var(--seekora-bg-secondary, #fafafa)',
|
|
53
|
+
padding: isMobile ? '16px' : '24px',
|
|
54
|
+
display: 'flex',
|
|
55
|
+
flexDirection: 'column',
|
|
56
|
+
overflow: 'hidden',
|
|
57
|
+
},
|
|
58
|
+
section: {
|
|
59
|
+
flex: 1,
|
|
60
|
+
overflowY: 'auto',
|
|
61
|
+
},
|
|
62
|
+
sectionHeader: {
|
|
63
|
+
padding: '16px 20px 12px',
|
|
64
|
+
display: 'flex',
|
|
65
|
+
alignItems: 'center',
|
|
66
|
+
justifyContent: 'space-between',
|
|
67
|
+
borderBottom: '1px solid var(--seekora-border-color, #e8e8e1)',
|
|
68
|
+
},
|
|
69
|
+
sectionTitle: {
|
|
70
|
+
fontSize: '11px',
|
|
71
|
+
fontWeight: 600,
|
|
72
|
+
color: 'var(--seekora-text-secondary, #666)',
|
|
73
|
+
textTransform: 'uppercase',
|
|
74
|
+
letterSpacing: '0.1em',
|
|
75
|
+
},
|
|
76
|
+
viewAllLink: {
|
|
77
|
+
fontSize: '12px',
|
|
78
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
79
|
+
textDecoration: 'underline',
|
|
80
|
+
cursor: 'pointer',
|
|
81
|
+
},
|
|
82
|
+
suggestionItem: {
|
|
83
|
+
display: 'flex',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
padding: isMobile ? '14px 16px' : '12px 16px',
|
|
86
|
+
gap: '12px',
|
|
87
|
+
cursor: 'pointer',
|
|
88
|
+
transition: 'all 150ms ease',
|
|
89
|
+
minHeight: '48px',
|
|
90
|
+
margin: '4px 8px',
|
|
91
|
+
borderRadius: '10px',
|
|
92
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
93
|
+
},
|
|
94
|
+
suggestionItemActive: {
|
|
95
|
+
backgroundColor: 'var(--seekora-bg-hover, #f5f5f5)',
|
|
96
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
97
|
+
},
|
|
98
|
+
suggestionIcon: {
|
|
99
|
+
display: 'flex',
|
|
100
|
+
alignItems: 'center',
|
|
101
|
+
justifyContent: 'center',
|
|
102
|
+
color: 'var(--seekora-text-tertiary, #999999)',
|
|
103
|
+
flexShrink: 0,
|
|
104
|
+
},
|
|
105
|
+
suggestionContent: {
|
|
106
|
+
flex: 1,
|
|
107
|
+
minWidth: 0,
|
|
108
|
+
},
|
|
109
|
+
suggestionQuery: {
|
|
110
|
+
fontSize: '14px',
|
|
111
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
112
|
+
fontWeight: 400,
|
|
113
|
+
},
|
|
114
|
+
suggestionMeta: {
|
|
115
|
+
fontSize: '12px',
|
|
116
|
+
color: 'var(--seekora-text-secondary, #666)',
|
|
117
|
+
marginTop: '2px',
|
|
118
|
+
},
|
|
119
|
+
suggestionArrow: {
|
|
120
|
+
width: '16px',
|
|
121
|
+
height: '16px',
|
|
122
|
+
color: 'var(--seekora-text-tertiary, #ccc)',
|
|
123
|
+
transform: 'rotate(-45deg)',
|
|
124
|
+
opacity: 0,
|
|
125
|
+
transition: 'opacity 150ms',
|
|
126
|
+
},
|
|
127
|
+
suggestionArrowVisible: {
|
|
128
|
+
opacity: 1,
|
|
129
|
+
},
|
|
130
|
+
collectionsGrid: {
|
|
131
|
+
display: 'grid',
|
|
132
|
+
gridTemplateColumns: 'repeat(2, 1fr)',
|
|
133
|
+
gap: '1px',
|
|
134
|
+
backgroundColor: 'var(--seekora-border-color, #e8e8e1)',
|
|
135
|
+
borderTop: '1px solid var(--seekora-border-color, #e8e8e1)',
|
|
136
|
+
},
|
|
137
|
+
collectionItem: {
|
|
138
|
+
backgroundColor: 'var(--seekora-bg-surface, #ffffff)',
|
|
139
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
140
|
+
padding: '16px 20px',
|
|
141
|
+
cursor: 'pointer',
|
|
142
|
+
transition: 'background-color 150ms',
|
|
143
|
+
},
|
|
144
|
+
collectionItemHover: {
|
|
145
|
+
backgroundColor: 'var(--seekora-bg-hover, #f0f0f0)',
|
|
146
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
147
|
+
},
|
|
148
|
+
collectionName: {
|
|
149
|
+
fontSize: '13px',
|
|
150
|
+
fontWeight: 500,
|
|
151
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
152
|
+
marginBottom: '4px',
|
|
153
|
+
},
|
|
154
|
+
collectionCount: {
|
|
155
|
+
fontSize: '11px',
|
|
156
|
+
color: 'var(--seekora-text-secondary, #666)',
|
|
157
|
+
},
|
|
158
|
+
heroProduct: {
|
|
159
|
+
marginBottom: '24px',
|
|
160
|
+
},
|
|
161
|
+
heroImage: {
|
|
162
|
+
width: '100%',
|
|
163
|
+
aspectRatio: '1',
|
|
164
|
+
objectFit: 'cover',
|
|
165
|
+
borderRadius: '2px',
|
|
166
|
+
marginBottom: '16px',
|
|
167
|
+
backgroundColor: 'var(--seekora-bg-tertiary, #f5f5f5)',
|
|
168
|
+
},
|
|
169
|
+
heroTitle: {
|
|
170
|
+
fontSize: '16px',
|
|
171
|
+
fontWeight: 500,
|
|
172
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
173
|
+
marginBottom: '8px',
|
|
174
|
+
lineHeight: 1.3,
|
|
175
|
+
},
|
|
176
|
+
heroBrand: {
|
|
177
|
+
fontSize: '12px',
|
|
178
|
+
color: 'var(--seekora-text-secondary, #666)',
|
|
179
|
+
marginBottom: '12px',
|
|
180
|
+
textTransform: 'uppercase',
|
|
181
|
+
letterSpacing: '0.05em',
|
|
182
|
+
},
|
|
183
|
+
heroPricing: {
|
|
184
|
+
display: 'flex',
|
|
185
|
+
alignItems: 'center',
|
|
186
|
+
gap: '8px',
|
|
187
|
+
marginBottom: '16px',
|
|
188
|
+
},
|
|
189
|
+
heroPrice: {
|
|
190
|
+
fontSize: '18px',
|
|
191
|
+
fontWeight: 500,
|
|
192
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
193
|
+
},
|
|
194
|
+
heroComparePrice: {
|
|
195
|
+
fontSize: '14px',
|
|
196
|
+
color: 'var(--seekora-text-tertiary, #999)',
|
|
197
|
+
textDecoration: 'line-through',
|
|
198
|
+
},
|
|
199
|
+
heroDiscount: {
|
|
200
|
+
fontSize: '12px',
|
|
201
|
+
fontWeight: 600,
|
|
202
|
+
color: 'var(--seekora-error, #d02e2e)',
|
|
203
|
+
backgroundColor: 'var(--seekora-error-light, #fdf2f2)',
|
|
204
|
+
padding: '2px 8px',
|
|
205
|
+
borderRadius: '2px',
|
|
206
|
+
},
|
|
207
|
+
heroButton: {
|
|
208
|
+
width: '100%',
|
|
209
|
+
padding: '14px 20px',
|
|
210
|
+
backgroundColor: 'var(--seekora-text-primary, #121212)',
|
|
211
|
+
color: 'var(--seekora-bg-surface, #ffffff)',
|
|
212
|
+
border: 'none',
|
|
213
|
+
borderRadius: '2px',
|
|
214
|
+
fontSize: '13px',
|
|
215
|
+
fontWeight: 500,
|
|
216
|
+
textTransform: 'uppercase',
|
|
217
|
+
letterSpacing: '0.1em',
|
|
218
|
+
cursor: 'pointer',
|
|
219
|
+
transition: 'background-color 150ms',
|
|
220
|
+
},
|
|
221
|
+
heroButtonHover: {
|
|
222
|
+
backgroundColor: 'var(--seekora-text-secondary, #666666)',
|
|
223
|
+
color: 'var(--seekora-bg-surface, #ffffff)',
|
|
224
|
+
},
|
|
225
|
+
productsScroll: {
|
|
226
|
+
flex: 1,
|
|
227
|
+
overflowX: 'auto',
|
|
228
|
+
overflowY: 'hidden',
|
|
229
|
+
display: 'flex',
|
|
230
|
+
gap: '16px',
|
|
231
|
+
paddingBottom: '8px',
|
|
232
|
+
scrollbarWidth: 'thin',
|
|
233
|
+
},
|
|
234
|
+
productCard: {
|
|
235
|
+
flex: '0 0 140px',
|
|
236
|
+
cursor: 'pointer',
|
|
237
|
+
transition: 'opacity 150ms',
|
|
238
|
+
},
|
|
239
|
+
productCardHover: {
|
|
240
|
+
opacity: 0.7,
|
|
241
|
+
},
|
|
242
|
+
productImage: {
|
|
243
|
+
width: '140px',
|
|
244
|
+
height: '175px',
|
|
245
|
+
objectFit: 'cover',
|
|
246
|
+
backgroundColor: 'var(--seekora-bg-tertiary, #f5f5f5)',
|
|
247
|
+
marginBottom: '10px',
|
|
248
|
+
},
|
|
249
|
+
productTitle: {
|
|
250
|
+
fontSize: '12px',
|
|
251
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
252
|
+
marginBottom: '4px',
|
|
253
|
+
whiteSpace: 'nowrap',
|
|
254
|
+
overflow: 'hidden',
|
|
255
|
+
textOverflow: 'ellipsis',
|
|
256
|
+
},
|
|
257
|
+
productPrice: {
|
|
258
|
+
fontSize: '12px',
|
|
259
|
+
fontWeight: 500,
|
|
260
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
261
|
+
},
|
|
262
|
+
footer: {
|
|
263
|
+
padding: '12px 20px',
|
|
264
|
+
borderTop: '1px solid var(--seekora-border-color, #e8e8e1)',
|
|
265
|
+
backgroundColor: 'var(--seekora-bg-secondary, #fafafa)',
|
|
266
|
+
display: 'flex',
|
|
267
|
+
alignItems: 'center',
|
|
268
|
+
justifyContent: 'space-between',
|
|
269
|
+
fontSize: '11px',
|
|
270
|
+
color: 'var(--seekora-text-secondary, #666)',
|
|
271
|
+
},
|
|
272
|
+
footerLink: {
|
|
273
|
+
color: 'var(--seekora-text-primary, #121212)',
|
|
274
|
+
textDecoration: 'underline',
|
|
275
|
+
cursor: 'pointer',
|
|
276
|
+
},
|
|
277
|
+
loading: {
|
|
278
|
+
display: 'flex',
|
|
279
|
+
alignItems: 'center',
|
|
280
|
+
justifyContent: 'center',
|
|
281
|
+
padding: '60px',
|
|
282
|
+
color: 'var(--seekora-text-secondary, #666)',
|
|
283
|
+
},
|
|
284
|
+
spinner: {
|
|
285
|
+
width: '24px',
|
|
286
|
+
height: '24px',
|
|
287
|
+
border: '2px solid var(--seekora-border-color, #e8e8e1)',
|
|
288
|
+
borderTopColor: 'var(--seekora-text-primary, #121212)',
|
|
289
|
+
borderRadius: '50%',
|
|
290
|
+
animation: 'seekora-spin 0.8s linear infinite',
|
|
291
|
+
},
|
|
292
|
+
empty: {
|
|
293
|
+
padding: '60px 20px',
|
|
294
|
+
textAlign: 'center',
|
|
295
|
+
color: 'var(--seekora-text-secondary, #666)',
|
|
296
|
+
},
|
|
297
|
+
highlight: {
|
|
298
|
+
fontWeight: 600,
|
|
299
|
+
textDecoration: 'underline',
|
|
300
|
+
textDecorationColor: 'var(--seekora-text-primary, #121212)',
|
|
301
|
+
},
|
|
302
|
+
});
|
|
303
|
+
// ============================================================================
|
|
304
|
+
// Icons
|
|
305
|
+
// ============================================================================
|
|
306
|
+
const SearchIcon = () => (React.createElement("svg", { width: "18", height: "18", viewBox: "0 0 20 20", fill: "none", stroke: "currentColor", strokeWidth: "1.5" },
|
|
307
|
+
React.createElement("path", { d: "M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" })));
|
|
308
|
+
const ArrowIcon = () => (React.createElement("svg", { width: "16", height: "16", viewBox: "0 0 20 20", fill: "currentColor" },
|
|
309
|
+
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" })));
|
|
310
|
+
export const ShopifyDropdown = forwardRef(function ShopifyDropdown(props, ref) {
|
|
311
|
+
const { query, isOpen = true, loading = false, suggestions = [], products = [], categories = [], suggestionFields = { query: 'query' }, productFields = { id: 'id', title: 'title' }, categoryFields = { id: 'id', label: 'label' }, productDisplay = {}, theme = {}, showHeroProduct = true, showCollections = true, showAddToCart = true, addToCartText = 'Quick Add', showComparePrice = true, width = '100%', maxHeight = '500px', zIndex = 1000, className, style, classNames = {}, onSuggestionSelect, onProductClick, onCategoryClick, onTabChange, onAddToCart, onViewAll, onClose, header, footer, renderLoading, renderEmpty, } = props;
|
|
312
|
+
// Inject global responsive styles
|
|
313
|
+
useInjectResponsiveStyles();
|
|
314
|
+
// Responsive state
|
|
315
|
+
const responsive = useResponsive();
|
|
316
|
+
const { isMobile } = responsive;
|
|
317
|
+
const styles = useMemo(() => createStyles(isMobile), [isMobile]);
|
|
318
|
+
const containerRef = useRef(null);
|
|
319
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
320
|
+
const [hoveredProduct, setHoveredProduct] = useState(null);
|
|
321
|
+
const [hoveredCollection, setHoveredCollection] = useState(null);
|
|
322
|
+
const [hoveredButton, setHoveredButton] = useState(false);
|
|
323
|
+
// Process data
|
|
324
|
+
const processedSuggestions = useMemo(() => suggestions.map(s => extractSuggestion(s, suggestionFields)), [suggestions, suggestionFields]);
|
|
325
|
+
const processedProducts = useMemo(() => products.map(p => extractProduct(p, productFields)), [products, productFields]);
|
|
326
|
+
const processedCategories = useMemo(() => categories.map(c => extractCategory(c, categoryFields)), [categories, categoryFields]);
|
|
327
|
+
// Hero product (first product)
|
|
328
|
+
const heroProduct = processedProducts[0];
|
|
329
|
+
const otherProducts = processedProducts.slice(1, 7);
|
|
330
|
+
// Navigation
|
|
331
|
+
const navigateNext = useCallback(() => {
|
|
332
|
+
setActiveIndex(prev => Math.min(prev + 1, processedSuggestions.length - 1));
|
|
333
|
+
}, [processedSuggestions.length]);
|
|
334
|
+
const navigatePrevious = useCallback(() => {
|
|
335
|
+
setActiveIndex(prev => Math.max(prev - 1, -1));
|
|
336
|
+
}, []);
|
|
337
|
+
const selectActive = useCallback(() => {
|
|
338
|
+
if (activeIndex >= 0 && processedSuggestions[activeIndex]) {
|
|
339
|
+
onSuggestionSelect?.(processedSuggestions[activeIndex]._raw, activeIndex);
|
|
340
|
+
}
|
|
341
|
+
}, [activeIndex, processedSuggestions, onSuggestionSelect]);
|
|
342
|
+
// Expose ref
|
|
343
|
+
useImperativeHandle(ref, () => ({
|
|
344
|
+
getActiveIndex: () => activeIndex,
|
|
345
|
+
setActiveIndex,
|
|
346
|
+
selectActive,
|
|
347
|
+
navigateNext,
|
|
348
|
+
navigatePrevious,
|
|
349
|
+
focus: () => containerRef.current?.focus(),
|
|
350
|
+
close: () => onClose?.(),
|
|
351
|
+
}), [activeIndex, selectActive, navigateNext, navigatePrevious, onClose]);
|
|
352
|
+
// Scroll active item into view
|
|
353
|
+
useEffect(() => {
|
|
354
|
+
if (activeIndex >= 0 && containerRef.current) {
|
|
355
|
+
const activeEl = containerRef.current.querySelector(`[data-index="${activeIndex}"]`);
|
|
356
|
+
if (activeEl) {
|
|
357
|
+
scrollIntoViewIfNeeded(activeEl, containerRef.current);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
}, [activeIndex]);
|
|
361
|
+
if (!isOpen)
|
|
362
|
+
return null;
|
|
363
|
+
const cssVariables = generateCSSVariables(theme);
|
|
364
|
+
const heroDiscount = heroProduct
|
|
365
|
+
? calculateDiscount(heroProduct.price, heroProduct.comparePrice)
|
|
366
|
+
: undefined;
|
|
367
|
+
return (React.createElement("div", { ref: containerRef, role: "listbox", "aria-label": "Search suggestions", className: cx('seekora-shopify-dropdown', className, classNames.root), style: mergeStyles(styles.root, {
|
|
368
|
+
width: isMobile ? '100%' : width,
|
|
369
|
+
maxHeight: isMobile ? '100vh' : maxHeight,
|
|
370
|
+
zIndex
|
|
371
|
+
}, cssVariables, style), tabIndex: -1 },
|
|
372
|
+
React.createElement("style", null, `
|
|
373
|
+
@keyframes seekora-spin {
|
|
374
|
+
to { transform: rotate(360deg); }
|
|
375
|
+
}
|
|
376
|
+
.seekora-shopify-dropdown mark {
|
|
377
|
+
background: transparent;
|
|
378
|
+
text-decoration: underline;
|
|
379
|
+
font-weight: 600;
|
|
380
|
+
}
|
|
381
|
+
`),
|
|
382
|
+
header,
|
|
383
|
+
loading ? (renderLoading ? renderLoading() : (React.createElement("div", { style: styles.loading },
|
|
384
|
+
React.createElement("div", { style: styles.spinner })))) : (React.createElement("div", { style: styles.layout },
|
|
385
|
+
React.createElement("div", { style: styles.leftPanel },
|
|
386
|
+
React.createElement("div", { style: styles.section },
|
|
387
|
+
React.createElement("div", { style: styles.sectionHeader },
|
|
388
|
+
React.createElement("span", { style: styles.sectionTitle }, "Suggestions"),
|
|
389
|
+
processedSuggestions.length > 5 && (React.createElement("span", { style: styles.viewAllLink, onClick: () => onViewAll?.('suggestions') }, "View all"))),
|
|
390
|
+
processedSuggestions.slice(0, 5).map((suggestion, idx) => {
|
|
391
|
+
const isActive = activeIndex === idx;
|
|
392
|
+
return (React.createElement("div", { key: suggestion.id || idx, "data-index": idx, role: "option", "aria-selected": isActive, style: mergeStyles(styles.suggestionItem, isActive ? styles.suggestionItemActive : undefined), onClick: () => onSuggestionSelect?.(suggestion._raw, idx), onMouseEnter: () => setActiveIndex(idx) },
|
|
393
|
+
React.createElement("div", { style: styles.suggestionIcon },
|
|
394
|
+
React.createElement(SearchIcon, null)),
|
|
395
|
+
React.createElement("div", { style: styles.suggestionContent },
|
|
396
|
+
React.createElement("div", { style: styles.suggestionQuery, dangerouslySetInnerHTML: {
|
|
397
|
+
__html: highlightText(suggestion.query, query, { tag: 'mark' })
|
|
398
|
+
} }),
|
|
399
|
+
suggestion.count && (React.createElement("div", { style: styles.suggestionMeta },
|
|
400
|
+
suggestion.count,
|
|
401
|
+
" results"))),
|
|
402
|
+
React.createElement("div", { style: mergeStyles(styles.suggestionArrow, isActive ? styles.suggestionArrowVisible : undefined) },
|
|
403
|
+
React.createElement(ArrowIcon, null))));
|
|
404
|
+
}),
|
|
405
|
+
processedSuggestions.length === 0 && query && (renderEmpty ? renderEmpty(query) : (React.createElement("div", { style: { padding: '20px', textAlign: 'center', color: '#666' } },
|
|
406
|
+
"No suggestions for \"",
|
|
407
|
+
query,
|
|
408
|
+
"\"")))),
|
|
409
|
+
showCollections && processedCategories.length > 0 && (React.createElement(React.Fragment, null,
|
|
410
|
+
React.createElement("div", { style: styles.sectionHeader },
|
|
411
|
+
React.createElement("span", { style: styles.sectionTitle }, "Collections")),
|
|
412
|
+
React.createElement("div", { style: styles.collectionsGrid }, processedCategories.slice(0, 4).map(cat => (React.createElement("div", { key: cat.id, style: mergeStyles(styles.collectionItem, hoveredCollection === cat.id ? styles.collectionItemHover : undefined), onClick: () => onTabChange?.(cat.id), onMouseEnter: () => setHoveredCollection(cat.id), onMouseLeave: () => setHoveredCollection(null) },
|
|
413
|
+
React.createElement("div", { style: styles.collectionName }, cat.label),
|
|
414
|
+
cat.count && (React.createElement("div", { style: styles.collectionCount },
|
|
415
|
+
cat.count,
|
|
416
|
+
" products"))))))))),
|
|
417
|
+
React.createElement("div", { style: styles.rightPanel },
|
|
418
|
+
showHeroProduct && heroProduct && (React.createElement("div", { style: styles.heroProduct },
|
|
419
|
+
heroProduct.image && (React.createElement("img", { src: heroProduct.image, alt: heroProduct.title, style: styles.heroImage, loading: "lazy" })),
|
|
420
|
+
heroProduct.brand && (React.createElement("div", { style: styles.heroBrand }, heroProduct.brand)),
|
|
421
|
+
React.createElement("div", { style: styles.heroTitle }, heroProduct.title),
|
|
422
|
+
React.createElement("div", { style: styles.heroPricing },
|
|
423
|
+
React.createElement("span", { style: styles.heroPrice }, formatPrice(heroProduct.price, {
|
|
424
|
+
currency: productDisplay.currency || heroProduct.currency || '$'
|
|
425
|
+
})),
|
|
426
|
+
showComparePrice && heroProduct.comparePrice && (React.createElement("span", { style: styles.heroComparePrice }, formatPrice(heroProduct.comparePrice, {
|
|
427
|
+
currency: productDisplay.currency || heroProduct.currency || '$'
|
|
428
|
+
}))),
|
|
429
|
+
heroDiscount && (React.createElement("span", { style: styles.heroDiscount },
|
|
430
|
+
"-",
|
|
431
|
+
heroDiscount,
|
|
432
|
+
"%"))),
|
|
433
|
+
showAddToCart && (React.createElement("button", { style: mergeStyles(styles.heroButton, hoveredButton ? styles.heroButtonHover : undefined), onClick: () => onAddToCart?.(heroProduct._raw), onMouseEnter: () => setHoveredButton(true), onMouseLeave: () => setHoveredButton(false) }, addToCartText)))),
|
|
434
|
+
otherProducts.length > 0 && (React.createElement(React.Fragment, null,
|
|
435
|
+
React.createElement("div", { style: { ...styles.sectionTitle, marginBottom: '12px' } }, "More Products"),
|
|
436
|
+
React.createElement("div", { style: styles.productsScroll }, otherProducts.map((product, idx) => (React.createElement("div", { key: product.id, style: mergeStyles(styles.productCard, hoveredProduct === product.id ? styles.productCardHover : undefined), onClick: () => onProductClick?.(product._raw, idx + 1), onMouseEnter: () => setHoveredProduct(product.id), onMouseLeave: () => setHoveredProduct(null) },
|
|
437
|
+
product.image ? (React.createElement("img", { src: product.image, alt: product.title, style: styles.productImage, loading: "lazy" })) : (React.createElement("div", { style: styles.productImage })),
|
|
438
|
+
React.createElement("div", { style: styles.productTitle }, product.title),
|
|
439
|
+
product.price !== undefined && (React.createElement("div", { style: styles.productPrice }, formatPrice(product.price, {
|
|
440
|
+
currency: productDisplay.currency || product.currency || '$'
|
|
441
|
+
})))))))))))),
|
|
442
|
+
footer !== undefined ? footer : (React.createElement("div", { style: styles.footer },
|
|
443
|
+
React.createElement("span", null,
|
|
444
|
+
"Press ",
|
|
445
|
+
React.createElement("strong", null, "Enter"),
|
|
446
|
+
" to search, ",
|
|
447
|
+
React.createElement("strong", null, "\u2191\u2193"),
|
|
448
|
+
" to navigate"),
|
|
449
|
+
React.createElement("span", { style: styles.footerLink, onClick: () => onViewAll?.('products') }, "View all results")))));
|
|
450
|
+
});
|
|
451
|
+
export default ShopifyDropdown;
|
|
@@ -0,0 +1,33 @@
|
|
|
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 from 'react';
|
|
12
|
+
import type { BaseDropdownProps, DropdownRef } from './types';
|
|
13
|
+
export interface SpotlightDropdownProps extends BaseDropdownProps {
|
|
14
|
+
/** Show preview panel */
|
|
15
|
+
showPreview?: boolean;
|
|
16
|
+
/** Show as overlay */
|
|
17
|
+
asOverlay?: boolean;
|
|
18
|
+
/** Placeholder text */
|
|
19
|
+
placeholder?: string;
|
|
20
|
+
/** Show keyboard shortcuts */
|
|
21
|
+
showShortcuts?: boolean;
|
|
22
|
+
/** Quick actions */
|
|
23
|
+
actions?: Array<{
|
|
24
|
+
id: string;
|
|
25
|
+
label: string;
|
|
26
|
+
icon?: React.ReactNode;
|
|
27
|
+
shortcut?: string;
|
|
28
|
+
onAction: () => void;
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
31
|
+
export declare const SpotlightDropdown: React.ForwardRefExoticComponent<SpotlightDropdownProps & React.RefAttributes<DropdownRef>>;
|
|
32
|
+
export default SpotlightDropdown;
|
|
33
|
+
//# sourceMappingURL=SpotlightDropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SpotlightDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/suggestions/SpotlightDropdown.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAuU9D,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,yBAAyB;IACzB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,sBAAsB;IACtB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,uBAAuB;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,oBAAoB;IACpB,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,EAAE,EAAE,MAAM,CAAC;QACX,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;QACvB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;KACtB,CAAC,CAAC;CACJ;AAED,eAAO,MAAM,iBAAiB,4FA+gB7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|