@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,485 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MobileSheetDropdown - Mobile-First Bottom Sheet Style
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - iOS-style bottom sheet with drag handle
|
|
6
|
+
* - Full-screen overlay with smooth transitions
|
|
7
|
+
* - Touch-friendly large tap targets
|
|
8
|
+
* - Swipe to dismiss
|
|
9
|
+
* - Optimized for small screens
|
|
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 { useInjectResponsiveStyles } from './styles';
|
|
14
|
+
// ============================================================================
|
|
15
|
+
// Styles
|
|
16
|
+
// ============================================================================
|
|
17
|
+
const createStyles = () => ({
|
|
18
|
+
overlay: {
|
|
19
|
+
position: 'fixed',
|
|
20
|
+
top: 0,
|
|
21
|
+
left: 0,
|
|
22
|
+
right: 0,
|
|
23
|
+
bottom: 0,
|
|
24
|
+
backgroundColor: 'rgba(0, 0, 0, 0.4)',
|
|
25
|
+
zIndex: 9998,
|
|
26
|
+
transition: 'opacity 200ms ease',
|
|
27
|
+
},
|
|
28
|
+
root: {
|
|
29
|
+
position: 'fixed',
|
|
30
|
+
left: 0,
|
|
31
|
+
right: 0,
|
|
32
|
+
bottom: 0,
|
|
33
|
+
backgroundColor: 'var(--seekora-bg-surface, #fff)',
|
|
34
|
+
borderRadius: '16px 16px 0 0',
|
|
35
|
+
boxShadow: '0 -4px 20px rgba(0, 0, 0, 0.15)',
|
|
36
|
+
fontFamily: 'var(--seekora-font-family, -apple-system, BlinkMacSystemFont, "SF Pro Text", sans-serif)',
|
|
37
|
+
fontSize: 'var(--seekora-font-size, 16px)',
|
|
38
|
+
zIndex: 9999,
|
|
39
|
+
transform: 'translateY(0)',
|
|
40
|
+
transition: 'transform 300ms cubic-bezier(0.32, 0.72, 0, 1)',
|
|
41
|
+
maxHeight: '90vh',
|
|
42
|
+
display: 'flex',
|
|
43
|
+
flexDirection: 'column',
|
|
44
|
+
},
|
|
45
|
+
rootHidden: {
|
|
46
|
+
transform: 'translateY(100%)',
|
|
47
|
+
},
|
|
48
|
+
dragHandle: {
|
|
49
|
+
display: 'flex',
|
|
50
|
+
justifyContent: 'center',
|
|
51
|
+
padding: '12px',
|
|
52
|
+
cursor: 'grab',
|
|
53
|
+
},
|
|
54
|
+
dragBar: {
|
|
55
|
+
width: '36px',
|
|
56
|
+
height: '5px',
|
|
57
|
+
backgroundColor: 'var(--seekora-border-color, #e0e0e0)',
|
|
58
|
+
borderRadius: '3px',
|
|
59
|
+
},
|
|
60
|
+
header: {
|
|
61
|
+
padding: '0 16px 16px',
|
|
62
|
+
borderBottom: '1px solid var(--seekora-border-color, #f0f0f0)',
|
|
63
|
+
},
|
|
64
|
+
searchContainer: {
|
|
65
|
+
display: 'flex',
|
|
66
|
+
alignItems: 'center',
|
|
67
|
+
backgroundColor: 'var(--seekora-bg-secondary, #f5f5f5)',
|
|
68
|
+
borderRadius: '12px',
|
|
69
|
+
padding: '12px 16px',
|
|
70
|
+
gap: '12px',
|
|
71
|
+
},
|
|
72
|
+
searchIcon: {
|
|
73
|
+
width: '20px',
|
|
74
|
+
height: '20px',
|
|
75
|
+
color: 'var(--seekora-text-tertiary, #8e8e93)',
|
|
76
|
+
flexShrink: 0,
|
|
77
|
+
},
|
|
78
|
+
searchInput: {
|
|
79
|
+
flex: 1,
|
|
80
|
+
border: 'none',
|
|
81
|
+
background: 'transparent',
|
|
82
|
+
fontSize: '17px',
|
|
83
|
+
color: 'var(--seekora-text-primary, #000)',
|
|
84
|
+
outline: 'none',
|
|
85
|
+
},
|
|
86
|
+
cancelBtn: {
|
|
87
|
+
padding: '8px',
|
|
88
|
+
background: 'none',
|
|
89
|
+
border: 'none',
|
|
90
|
+
color: 'var(--seekora-primary, #007aff)',
|
|
91
|
+
fontSize: '17px',
|
|
92
|
+
cursor: 'pointer',
|
|
93
|
+
},
|
|
94
|
+
content: {
|
|
95
|
+
flex: 1,
|
|
96
|
+
overflowY: 'auto',
|
|
97
|
+
overscrollBehavior: 'contain',
|
|
98
|
+
WebkitOverflowScrolling: 'touch',
|
|
99
|
+
},
|
|
100
|
+
section: {
|
|
101
|
+
padding: '8px 0',
|
|
102
|
+
},
|
|
103
|
+
sectionHeader: {
|
|
104
|
+
padding: '16px 16px 8px',
|
|
105
|
+
display: 'flex',
|
|
106
|
+
alignItems: 'center',
|
|
107
|
+
justifyContent: 'space-between',
|
|
108
|
+
},
|
|
109
|
+
sectionTitle: {
|
|
110
|
+
fontSize: '13px',
|
|
111
|
+
fontWeight: 600,
|
|
112
|
+
color: 'var(--seekora-text-secondary, #8e8e93)',
|
|
113
|
+
textTransform: 'uppercase',
|
|
114
|
+
letterSpacing: '0.5px',
|
|
115
|
+
},
|
|
116
|
+
clearBtn: {
|
|
117
|
+
fontSize: '15px',
|
|
118
|
+
color: 'var(--seekora-primary, #007aff)',
|
|
119
|
+
background: 'none',
|
|
120
|
+
border: 'none',
|
|
121
|
+
cursor: 'pointer',
|
|
122
|
+
},
|
|
123
|
+
item: {
|
|
124
|
+
display: 'flex',
|
|
125
|
+
alignItems: 'center',
|
|
126
|
+
padding: '14px 16px',
|
|
127
|
+
gap: '14px',
|
|
128
|
+
cursor: 'pointer',
|
|
129
|
+
transition: 'background-color 100ms',
|
|
130
|
+
minHeight: '56px', // Touch-friendly
|
|
131
|
+
color: 'var(--seekora-text-primary, #000)',
|
|
132
|
+
},
|
|
133
|
+
itemActive: {
|
|
134
|
+
backgroundColor: 'var(--seekora-bg-hover, #f2f2f7)',
|
|
135
|
+
color: 'var(--seekora-text-primary, #000)',
|
|
136
|
+
},
|
|
137
|
+
itemIcon: {
|
|
138
|
+
width: '24px',
|
|
139
|
+
height: '24px',
|
|
140
|
+
color: 'var(--seekora-text-tertiary, #8e8e93)',
|
|
141
|
+
flexShrink: 0,
|
|
142
|
+
},
|
|
143
|
+
itemImage: {
|
|
144
|
+
width: '48px',
|
|
145
|
+
height: '48px',
|
|
146
|
+
borderRadius: '8px',
|
|
147
|
+
objectFit: 'cover',
|
|
148
|
+
backgroundColor: 'var(--seekora-bg-secondary, #f5f5f5)',
|
|
149
|
+
flexShrink: 0,
|
|
150
|
+
},
|
|
151
|
+
itemContent: {
|
|
152
|
+
flex: 1,
|
|
153
|
+
minWidth: 0,
|
|
154
|
+
},
|
|
155
|
+
itemTitle: {
|
|
156
|
+
fontSize: '17px',
|
|
157
|
+
color: 'var(--seekora-text-primary, #000)',
|
|
158
|
+
whiteSpace: 'nowrap',
|
|
159
|
+
overflow: 'hidden',
|
|
160
|
+
textOverflow: 'ellipsis',
|
|
161
|
+
},
|
|
162
|
+
itemSubtitle: {
|
|
163
|
+
fontSize: '15px',
|
|
164
|
+
color: 'var(--seekora-text-secondary, #8e8e93)',
|
|
165
|
+
marginTop: '2px',
|
|
166
|
+
whiteSpace: 'nowrap',
|
|
167
|
+
overflow: 'hidden',
|
|
168
|
+
textOverflow: 'ellipsis',
|
|
169
|
+
},
|
|
170
|
+
itemAction: {
|
|
171
|
+
color: 'var(--seekora-text-tertiary, #c7c7cc)',
|
|
172
|
+
flexShrink: 0,
|
|
173
|
+
},
|
|
174
|
+
productsScroll: {
|
|
175
|
+
display: 'flex',
|
|
176
|
+
gap: '12px',
|
|
177
|
+
padding: '0 16px 16px',
|
|
178
|
+
overflowX: 'auto',
|
|
179
|
+
scrollSnapType: 'x mandatory',
|
|
180
|
+
WebkitOverflowScrolling: 'touch',
|
|
181
|
+
},
|
|
182
|
+
productCard: {
|
|
183
|
+
flex: '0 0 140px',
|
|
184
|
+
scrollSnapAlign: 'start',
|
|
185
|
+
cursor: 'pointer',
|
|
186
|
+
},
|
|
187
|
+
productImage: {
|
|
188
|
+
width: '140px',
|
|
189
|
+
height: '140px',
|
|
190
|
+
borderRadius: '12px',
|
|
191
|
+
objectFit: 'cover',
|
|
192
|
+
backgroundColor: 'var(--seekora-bg-secondary, #f5f5f5)',
|
|
193
|
+
marginBottom: '8px',
|
|
194
|
+
},
|
|
195
|
+
productTitle: {
|
|
196
|
+
fontSize: '15px',
|
|
197
|
+
color: 'var(--seekora-text-primary, #000)',
|
|
198
|
+
marginBottom: '4px',
|
|
199
|
+
whiteSpace: 'nowrap',
|
|
200
|
+
overflow: 'hidden',
|
|
201
|
+
textOverflow: 'ellipsis',
|
|
202
|
+
},
|
|
203
|
+
productPrice: {
|
|
204
|
+
fontSize: '15px',
|
|
205
|
+
fontWeight: 600,
|
|
206
|
+
color: 'var(--seekora-text-primary, #000)',
|
|
207
|
+
},
|
|
208
|
+
footer: {
|
|
209
|
+
padding: '12px 16px',
|
|
210
|
+
paddingBottom: 'calc(12px + env(safe-area-inset-bottom, 0px))',
|
|
211
|
+
borderTop: '1px solid var(--seekora-border-color, #f0f0f0)',
|
|
212
|
+
backgroundColor: 'var(--seekora-bg-secondary, #f8f8f8)',
|
|
213
|
+
},
|
|
214
|
+
footerBtn: {
|
|
215
|
+
width: '100%',
|
|
216
|
+
padding: '16px',
|
|
217
|
+
backgroundColor: 'var(--seekora-primary, #007aff)',
|
|
218
|
+
color: 'var(--seekora-text-inverse, #ffffff)',
|
|
219
|
+
border: 'none',
|
|
220
|
+
borderRadius: '12px',
|
|
221
|
+
fontSize: '17px',
|
|
222
|
+
fontWeight: 600,
|
|
223
|
+
cursor: 'pointer',
|
|
224
|
+
},
|
|
225
|
+
loading: {
|
|
226
|
+
display: 'flex',
|
|
227
|
+
alignItems: 'center',
|
|
228
|
+
justifyContent: 'center',
|
|
229
|
+
padding: '60px',
|
|
230
|
+
color: 'var(--seekora-text-secondary, #8e8e93)',
|
|
231
|
+
},
|
|
232
|
+
spinner: {
|
|
233
|
+
width: '28px',
|
|
234
|
+
height: '28px',
|
|
235
|
+
border: '3px solid var(--seekora-border-color, #e5e5ea)',
|
|
236
|
+
borderTopColor: 'var(--seekora-primary, #007aff)',
|
|
237
|
+
borderRadius: '50%',
|
|
238
|
+
animation: 'seekora-spin 0.8s linear infinite',
|
|
239
|
+
},
|
|
240
|
+
empty: {
|
|
241
|
+
padding: '60px 20px',
|
|
242
|
+
textAlign: 'center',
|
|
243
|
+
color: 'var(--seekora-text-secondary, #8e8e93)',
|
|
244
|
+
fontSize: '17px',
|
|
245
|
+
},
|
|
246
|
+
emptyIcon: {
|
|
247
|
+
width: '48px',
|
|
248
|
+
height: '48px',
|
|
249
|
+
margin: '0 auto 16px',
|
|
250
|
+
color: 'var(--seekora-text-tertiary, #c7c7cc)',
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
// ============================================================================
|
|
254
|
+
// Icons
|
|
255
|
+
// ============================================================================
|
|
256
|
+
const SearchIcon = () => (React.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" },
|
|
257
|
+
React.createElement("circle", { cx: "11", cy: "11", r: "7" }),
|
|
258
|
+
React.createElement("path", { d: "M21 21l-4.35-4.35" })));
|
|
259
|
+
const ClockIcon = () => (React.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" },
|
|
260
|
+
React.createElement("circle", { cx: "12", cy: "12", r: "10" }),
|
|
261
|
+
React.createElement("polyline", { points: "12 6 12 12 16 14" })));
|
|
262
|
+
const TrendingIcon = () => (React.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2" },
|
|
263
|
+
React.createElement("polyline", { points: "23 6 13.5 15.5 8.5 10.5 1 18" }),
|
|
264
|
+
React.createElement("polyline", { points: "17 6 23 6 23 12" })));
|
|
265
|
+
const ChevronIcon = () => (React.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", width: "20", height: "20" },
|
|
266
|
+
React.createElement("polyline", { points: "9 18 15 12 9 6" })));
|
|
267
|
+
const ArrowUpIcon = () => (React.createElement("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", width: "20", height: "20" },
|
|
268
|
+
React.createElement("path", { d: "M7 17l5-5-5-5M13 17l5-5-5-5" })));
|
|
269
|
+
export const MobileSheetDropdown = forwardRef(function MobileSheetDropdown(props, ref) {
|
|
270
|
+
const { query, isOpen = true, loading = false, suggestions = [], products = [], recentSearches = [], trendingSearches = [], suggestionFields = { query: 'query' }, productFields = { id: 'id', title: 'title' }, productDisplay = {}, theme = {}, showSearchInput = true, showCancel = true, cancelText = 'Cancel', showDragHandle = true, swipeToDismiss = true, footerButtonText = 'Search', showFooterButton = true, width = '100%', maxHeight = '85vh', zIndex = 9999, className, style, classNames = {}, inputRef, onSuggestionSelect, onProductClick, onRecentClick, onRecentClearAll, onSearchSubmit, onClose, header, footer, renderLoading, renderEmpty, } = props;
|
|
271
|
+
// Inject global responsive styles
|
|
272
|
+
useInjectResponsiveStyles();
|
|
273
|
+
const styles = useMemo(() => createStyles(), []);
|
|
274
|
+
const containerRef = useRef(null);
|
|
275
|
+
const [activeIndex, setActiveIndex] = useState(-1);
|
|
276
|
+
const [inputValue, setInputValue] = useState(query);
|
|
277
|
+
const [dragY, setDragY] = useState(0);
|
|
278
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
279
|
+
const dragStartY = useRef(0);
|
|
280
|
+
// Process data
|
|
281
|
+
const processedSuggestions = useMemo(() => suggestions.map(s => extractSuggestion(s, suggestionFields)), [suggestions, suggestionFields]);
|
|
282
|
+
const processedProducts = useMemo(() => products.map(p => extractProduct(p, productFields)), [products, productFields]);
|
|
283
|
+
const recentQueries = useMemo(() => recentSearches.map(r => typeof r === 'string' ? r : r.query).slice(0, 5), [recentSearches]);
|
|
284
|
+
const trendingQueries = useMemo(() => trendingSearches.map(t => typeof t === 'string' ? t : t.query).slice(0, 5), [trendingSearches]);
|
|
285
|
+
// Navigation
|
|
286
|
+
// Build all navigable items
|
|
287
|
+
const allItems = useMemo(() => {
|
|
288
|
+
const items = [];
|
|
289
|
+
recentQueries.forEach(q => items.push({ type: 'recent', data: q }));
|
|
290
|
+
trendingQueries.forEach(q => items.push({ type: 'trending', data: q }));
|
|
291
|
+
processedSuggestions.forEach(s => items.push({ type: 'suggestion', data: s }));
|
|
292
|
+
return items;
|
|
293
|
+
}, [recentQueries, trendingQueries, processedSuggestions]);
|
|
294
|
+
const navigateNext = useCallback(() => {
|
|
295
|
+
setActiveIndex(prev => Math.min(prev + 1, allItems.length - 1));
|
|
296
|
+
}, [allItems.length]);
|
|
297
|
+
const navigatePrevious = useCallback(() => {
|
|
298
|
+
setActiveIndex(prev => Math.max(prev - 1, -1));
|
|
299
|
+
}, []);
|
|
300
|
+
const selectActive = useCallback(() => {
|
|
301
|
+
if (activeIndex < 0 || activeIndex >= allItems.length) {
|
|
302
|
+
// No selection, submit current query
|
|
303
|
+
if (inputValue.trim())
|
|
304
|
+
onSearchSubmit?.(inputValue.trim());
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
307
|
+
const item = allItems[activeIndex];
|
|
308
|
+
if (item.type === 'recent' || item.type === 'trending') {
|
|
309
|
+
onRecentClick?.(item.data);
|
|
310
|
+
}
|
|
311
|
+
else if (item.type === 'suggestion') {
|
|
312
|
+
onSuggestionSelect?.(item.data._raw, activeIndex);
|
|
313
|
+
}
|
|
314
|
+
}, [activeIndex, allItems, inputValue, onSearchSubmit, onRecentClick, onSuggestionSelect]);
|
|
315
|
+
// Expose ref
|
|
316
|
+
useImperativeHandle(ref, () => ({
|
|
317
|
+
getActiveIndex: () => activeIndex,
|
|
318
|
+
setActiveIndex,
|
|
319
|
+
selectActive,
|
|
320
|
+
navigateNext,
|
|
321
|
+
navigatePrevious,
|
|
322
|
+
focus: () => inputRef?.current?.focus(),
|
|
323
|
+
close: () => onClose?.(),
|
|
324
|
+
}), [activeIndex, selectActive, navigateNext, navigatePrevious, inputRef, onClose]);
|
|
325
|
+
// Scroll active item into view
|
|
326
|
+
useEffect(() => {
|
|
327
|
+
if (activeIndex >= 0 && containerRef.current) {
|
|
328
|
+
const activeEl = containerRef.current.querySelector(`[data-index="${activeIndex}"]`);
|
|
329
|
+
if (activeEl) {
|
|
330
|
+
scrollIntoViewIfNeeded(activeEl, containerRef.current);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
}, [activeIndex]);
|
|
334
|
+
// Drag to dismiss
|
|
335
|
+
const handleDragStart = (e) => {
|
|
336
|
+
if (!swipeToDismiss)
|
|
337
|
+
return;
|
|
338
|
+
setIsDragging(true);
|
|
339
|
+
dragStartY.current = e.touches[0].clientY;
|
|
340
|
+
};
|
|
341
|
+
const handleDrag = (e) => {
|
|
342
|
+
if (!isDragging)
|
|
343
|
+
return;
|
|
344
|
+
const deltaY = e.touches[0].clientY - dragStartY.current;
|
|
345
|
+
if (deltaY > 0) {
|
|
346
|
+
setDragY(deltaY);
|
|
347
|
+
}
|
|
348
|
+
};
|
|
349
|
+
const handleDragEnd = () => {
|
|
350
|
+
if (!isDragging)
|
|
351
|
+
return;
|
|
352
|
+
setIsDragging(false);
|
|
353
|
+
if (dragY > 150) {
|
|
354
|
+
onClose?.();
|
|
355
|
+
}
|
|
356
|
+
setDragY(0);
|
|
357
|
+
};
|
|
358
|
+
// Sync input value
|
|
359
|
+
useEffect(() => {
|
|
360
|
+
setInputValue(query);
|
|
361
|
+
}, [query]);
|
|
362
|
+
if (!isOpen)
|
|
363
|
+
return null;
|
|
364
|
+
const cssVariables = generateCSSVariables(theme);
|
|
365
|
+
const showRecent = !inputValue && recentQueries.length > 0;
|
|
366
|
+
const showTrending = !inputValue && trendingQueries.length > 0;
|
|
367
|
+
const showProducts = processedProducts.length > 0;
|
|
368
|
+
return (React.createElement(React.Fragment, null,
|
|
369
|
+
React.createElement("div", { style: {
|
|
370
|
+
...styles.overlay,
|
|
371
|
+
opacity: isDragging ? 1 - (dragY / 300) : 1,
|
|
372
|
+
}, onClick: onClose }),
|
|
373
|
+
React.createElement("div", { ref: containerRef, className: cx('seekora-mobile-sheet', className, classNames.root), style: mergeStyles(styles.root, {
|
|
374
|
+
maxHeight,
|
|
375
|
+
zIndex,
|
|
376
|
+
transform: isDragging ? `translateY(${dragY}px)` : 'translateY(0)',
|
|
377
|
+
}, cssVariables, style), onTouchStart: handleDragStart, onTouchMove: handleDrag, onTouchEnd: handleDragEnd },
|
|
378
|
+
React.createElement("style", null, `
|
|
379
|
+
@keyframes seekora-spin {
|
|
380
|
+
to { transform: rotate(360deg); }
|
|
381
|
+
}
|
|
382
|
+
`),
|
|
383
|
+
showDragHandle && (React.createElement("div", { style: styles.dragHandle },
|
|
384
|
+
React.createElement("div", { style: styles.dragBar }))),
|
|
385
|
+
(showSearchInput || header) && (React.createElement("div", { style: styles.header }, header || (React.createElement("div", { style: { display: 'flex', alignItems: 'center', gap: '12px' } },
|
|
386
|
+
React.createElement("div", { style: styles.searchContainer },
|
|
387
|
+
React.createElement("div", { style: styles.searchIcon },
|
|
388
|
+
React.createElement(SearchIcon, null)),
|
|
389
|
+
React.createElement("input", { ref: inputRef, type: "text", placeholder: "Search...", value: inputValue, onChange: (e) => setInputValue(e.target.value), onKeyDown: (e) => {
|
|
390
|
+
if (e.key === 'Enter') {
|
|
391
|
+
e.preventDefault();
|
|
392
|
+
if (activeIndex >= 0) {
|
|
393
|
+
selectActive();
|
|
394
|
+
}
|
|
395
|
+
else if (inputValue.trim()) {
|
|
396
|
+
onSearchSubmit?.(inputValue.trim());
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
else if (e.key === 'ArrowDown') {
|
|
400
|
+
e.preventDefault();
|
|
401
|
+
navigateNext();
|
|
402
|
+
}
|
|
403
|
+
else if (e.key === 'ArrowUp') {
|
|
404
|
+
e.preventDefault();
|
|
405
|
+
navigatePrevious();
|
|
406
|
+
}
|
|
407
|
+
else if (e.key === 'Escape') {
|
|
408
|
+
onClose?.();
|
|
409
|
+
}
|
|
410
|
+
}, style: styles.searchInput, autoFocus: true })),
|
|
411
|
+
showCancel && (React.createElement("button", { style: styles.cancelBtn, onClick: onClose }, cancelText)))))),
|
|
412
|
+
React.createElement("div", { style: styles.content }, loading ? (renderLoading ? renderLoading() : (React.createElement("div", { style: styles.loading },
|
|
413
|
+
React.createElement("div", { style: styles.spinner })))) : (React.createElement(React.Fragment, null,
|
|
414
|
+
showRecent && (React.createElement("div", { style: styles.section },
|
|
415
|
+
React.createElement("div", { style: styles.sectionHeader },
|
|
416
|
+
React.createElement("span", { style: styles.sectionTitle }, "Recent"),
|
|
417
|
+
React.createElement("button", { style: styles.clearBtn, onClick: onRecentClearAll }, "Clear")),
|
|
418
|
+
recentQueries.map((q, idx) => (React.createElement("div", { key: `recent-${q}`, "data-index": idx, style: mergeStyles(styles.item, activeIndex === idx ? styles.itemActive : undefined), onClick: () => {
|
|
419
|
+
onRecentClick?.(q);
|
|
420
|
+
setInputValue(q);
|
|
421
|
+
}, onMouseEnter: () => setActiveIndex(idx) },
|
|
422
|
+
React.createElement("div", { style: styles.itemIcon },
|
|
423
|
+
React.createElement(ClockIcon, null)),
|
|
424
|
+
React.createElement("div", { style: styles.itemContent },
|
|
425
|
+
React.createElement("div", { style: styles.itemTitle }, q)),
|
|
426
|
+
React.createElement("div", { style: styles.itemAction },
|
|
427
|
+
React.createElement(ArrowUpIcon, null))))))),
|
|
428
|
+
showTrending && (React.createElement("div", { style: styles.section },
|
|
429
|
+
React.createElement("div", { style: styles.sectionHeader },
|
|
430
|
+
React.createElement("span", { style: styles.sectionTitle }, "Trending")),
|
|
431
|
+
trendingQueries.map((q, idx) => {
|
|
432
|
+
const globalIdx = recentQueries.length + idx;
|
|
433
|
+
return (React.createElement("div", { key: `trending-${q}`, "data-index": globalIdx, style: mergeStyles(styles.item, activeIndex === globalIdx ? styles.itemActive : undefined), onClick: () => {
|
|
434
|
+
onRecentClick?.(q);
|
|
435
|
+
setInputValue(q);
|
|
436
|
+
}, onMouseEnter: () => setActiveIndex(globalIdx) },
|
|
437
|
+
React.createElement("div", { style: styles.itemIcon },
|
|
438
|
+
React.createElement(TrendingIcon, null)),
|
|
439
|
+
React.createElement("div", { style: styles.itemContent },
|
|
440
|
+
React.createElement("div", { style: styles.itemTitle }, q)),
|
|
441
|
+
React.createElement("div", { style: styles.itemAction },
|
|
442
|
+
React.createElement(ChevronIcon, null))));
|
|
443
|
+
}))),
|
|
444
|
+
inputValue && processedSuggestions.length > 0 && (React.createElement("div", { style: styles.section },
|
|
445
|
+
React.createElement("div", { style: styles.sectionHeader },
|
|
446
|
+
React.createElement("span", { style: styles.sectionTitle }, "Suggestions")),
|
|
447
|
+
processedSuggestions.map((s, idx) => {
|
|
448
|
+
const globalIdx = recentQueries.length + trendingQueries.length + idx;
|
|
449
|
+
return (React.createElement("div", { key: s.id || idx, "data-index": globalIdx, style: mergeStyles(styles.item, activeIndex === globalIdx ? styles.itemActive : undefined), onClick: () => onSuggestionSelect?.(s._raw, idx), onMouseEnter: () => setActiveIndex(globalIdx) },
|
|
450
|
+
React.createElement("div", { style: styles.itemIcon },
|
|
451
|
+
React.createElement(SearchIcon, null)),
|
|
452
|
+
React.createElement("div", { style: styles.itemContent },
|
|
453
|
+
React.createElement("div", { style: styles.itemTitle, dangerouslySetInnerHTML: {
|
|
454
|
+
__html: highlightText(s.query, inputValue, { tag: 'strong' })
|
|
455
|
+
} }),
|
|
456
|
+
s.count && (React.createElement("div", { style: styles.itemSubtitle },
|
|
457
|
+
s.count,
|
|
458
|
+
" results"))),
|
|
459
|
+
React.createElement("div", { style: styles.itemAction },
|
|
460
|
+
React.createElement(ChevronIcon, null))));
|
|
461
|
+
}))),
|
|
462
|
+
showProducts && (React.createElement("div", { style: styles.section },
|
|
463
|
+
React.createElement("div", { style: styles.sectionHeader },
|
|
464
|
+
React.createElement("span", { style: styles.sectionTitle }, "Products")),
|
|
465
|
+
React.createElement("div", { style: styles.productsScroll }, processedProducts.slice(0, 8).map((p, idx) => (React.createElement("div", { key: p.id, style: styles.productCard, onClick: () => onProductClick?.(p._raw, idx) },
|
|
466
|
+
p.image ? (React.createElement("img", { src: p.image, alt: p.title, style: styles.productImage, loading: "lazy" })) : (React.createElement("div", { style: styles.productImage })),
|
|
467
|
+
React.createElement("div", { style: styles.productTitle }, p.title),
|
|
468
|
+
p.price !== undefined && (React.createElement("div", { style: styles.productPrice }, formatPrice(p.price, {
|
|
469
|
+
currency: productDisplay.currency || p.currency || '$'
|
|
470
|
+
}))))))))),
|
|
471
|
+
inputValue && processedSuggestions.length === 0 && !loading && (renderEmpty ? renderEmpty(inputValue) : (React.createElement("div", { style: styles.empty },
|
|
472
|
+
React.createElement("div", { style: styles.emptyIcon },
|
|
473
|
+
React.createElement(SearchIcon, null)),
|
|
474
|
+
React.createElement("p", null,
|
|
475
|
+
"No results for \"",
|
|
476
|
+
inputValue,
|
|
477
|
+
"\""))))))),
|
|
478
|
+
footer !== undefined ? footer : (showFooterButton && inputValue && (React.createElement("div", { style: styles.footer },
|
|
479
|
+
React.createElement("button", { style: styles.footerBtn, onClick: () => onSearchSubmit?.(inputValue) },
|
|
480
|
+
footerButtonText,
|
|
481
|
+
" \"",
|
|
482
|
+
inputValue,
|
|
483
|
+
"\"")))))));
|
|
484
|
+
});
|
|
485
|
+
export default MobileSheetDropdown;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PinterestDropdown - Visual Discovery Style Suggestions
|
|
3
|
+
*
|
|
4
|
+
* Features:
|
|
5
|
+
* - Visually-driven masonry/grid product display
|
|
6
|
+
* - Large hero images
|
|
7
|
+
* - Category chips/pills for filtering
|
|
8
|
+
* - Smooth hover effects with quick preview
|
|
9
|
+
* - Color palette extraction ready
|
|
10
|
+
*/
|
|
11
|
+
import React from 'react';
|
|
12
|
+
import type { BaseDropdownProps, DropdownRef } from './types';
|
|
13
|
+
export interface PinterestDropdownProps extends BaseDropdownProps {
|
|
14
|
+
/** Show save/pin button on products */
|
|
15
|
+
showSaveButton?: boolean;
|
|
16
|
+
/** Save button handler */
|
|
17
|
+
onSaveProduct?: (product: any) => void;
|
|
18
|
+
/** Active category ID */
|
|
19
|
+
activeCategory?: string;
|
|
20
|
+
/** Show price overlay on hover */
|
|
21
|
+
showPriceOverlay?: boolean;
|
|
22
|
+
/** Grid columns */
|
|
23
|
+
gridColumns?: number;
|
|
24
|
+
/** Card aspect ratio */
|
|
25
|
+
cardAspectRatio?: 'square' | 'portrait' | 'landscape';
|
|
26
|
+
}
|
|
27
|
+
export declare const PinterestDropdown: React.ForwardRefExoticComponent<PinterestDropdownProps & React.RefAttributes<DropdownRef>>;
|
|
28
|
+
export default PinterestDropdown;
|
|
29
|
+
//# sourceMappingURL=PinterestDropdown.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PinterestDropdown.d.ts","sourceRoot":"","sources":["../../../src/components/suggestions/PinterestDropdown.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAQN,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAsU9D,MAAM,WAAW,sBAAuB,SAAQ,iBAAiB;IAC/D,uCAAuC;IACvC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,0BAA0B;IAC1B,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACvC,yBAAyB;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,mBAAmB;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,wBAAwB;IACxB,eAAe,CAAC,EAAE,QAAQ,GAAG,UAAU,GAAG,WAAW,CAAC;CACvD;AAED,eAAO,MAAM,iBAAiB,4FA0X7B,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|