@seekora-ai/ui-sdk-vanilla 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/clear-refinements.d.ts +39 -0
- package/dist/components/clear-refinements.d.ts.map +1 -0
- package/dist/components/clear-refinements.js +133 -0
- package/dist/components/current-refinements.d.ts +36 -0
- package/dist/components/current-refinements.d.ts.map +1 -0
- package/dist/components/current-refinements.js +186 -0
- package/dist/components/facets.d.ts +45 -0
- package/dist/components/facets.d.ts.map +1 -0
- package/dist/components/facets.js +259 -0
- package/dist/components/hits-per-page.d.ts +37 -0
- package/dist/components/hits-per-page.d.ts.map +1 -0
- package/dist/components/hits-per-page.js +132 -0
- package/dist/components/infinite-hits.d.ts +61 -0
- package/dist/components/infinite-hits.d.ts.map +1 -0
- package/dist/components/infinite-hits.js +316 -0
- package/dist/components/pagination.d.ts +33 -0
- package/dist/components/pagination.d.ts.map +1 -0
- package/dist/components/pagination.js +364 -0
- package/dist/components/query-suggestions.d.ts +39 -0
- package/dist/components/query-suggestions.d.ts.map +1 -0
- package/dist/components/query-suggestions.js +217 -0
- package/dist/components/range-input.d.ts +42 -0
- package/dist/components/range-input.d.ts.map +1 -0
- package/dist/components/range-input.js +274 -0
- package/dist/components/search-bar.d.ts +140 -0
- package/dist/components/search-bar.d.ts.map +1 -0
- package/dist/components/search-bar.js +899 -0
- package/dist/components/search-layout.d.ts +35 -0
- package/dist/components/search-layout.d.ts.map +1 -0
- package/dist/components/search-layout.js +144 -0
- package/dist/components/search-provider.d.ts +28 -0
- package/dist/components/search-provider.d.ts.map +1 -0
- package/dist/components/search-provider.js +44 -0
- package/dist/components/search-results.d.ts +55 -0
- package/dist/components/search-results.d.ts.map +1 -0
- package/dist/components/search-results.js +537 -0
- package/dist/components/sort-by.d.ts +33 -0
- package/dist/components/sort-by.d.ts.map +1 -0
- package/dist/components/sort-by.js +122 -0
- package/dist/components/stats.d.ts +36 -0
- package/dist/components/stats.d.ts.map +1 -0
- package/dist/components/stats.js +138 -0
- package/dist/index.d.ts +670 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +4008 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +4055 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +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/types.d.ts +7 -0
- package/dist/themes/types.d.ts.map +1 -0
- package/dist/themes/types.js +6 -0
- package/dist/utils/search-manager.d.ts +33 -0
- package/dist/utils/search-manager.d.ts.map +1 -0
- package/dist/utils/search-manager.js +89 -0
- package/package.json +60 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,670 @@
|
|
|
1
|
+
import { SeekoraClient, SearchOptions, SearchResponse } from '@seekora-ai/search-sdk';
|
|
2
|
+
import { SearchStateManager, SearchStateManagerConfig } from '@seekora-ai/ui-sdk-core';
|
|
3
|
+
export { HighlightOptions, HighlightPart, SnippetOptions, getHighlightedValue, getSnippetedValue, highlightQuery, mergeThemes, parseHighlightedParts, parseQueryHighlightParts, stripHighlightTags } from '@seekora-ai/ui-sdk-core';
|
|
4
|
+
import * as _seekora_ai_ui_sdk_types from '@seekora-ai/ui-sdk-types';
|
|
5
|
+
import { Theme, ThemeConfig, ViewMode, FieldMapping, ResultItem } from '@seekora-ai/ui-sdk-types';
|
|
6
|
+
export { FieldMapping, ResultItem, SuggestionItem, Theme, ThemeConfig, ViewMode } from '@seekora-ai/ui-sdk-types';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* SearchProvider
|
|
10
|
+
*
|
|
11
|
+
* Provides search context, theme, and state management to child components
|
|
12
|
+
* Centralizes all search state and coordination (similar to InstantSearch.js)
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
interface SearchProviderConfig {
|
|
16
|
+
client: SeekoraClient;
|
|
17
|
+
theme?: ThemeConfig;
|
|
18
|
+
enableAnalytics?: boolean;
|
|
19
|
+
autoTrackSearch?: boolean;
|
|
20
|
+
stateManager?: SearchStateManagerConfig;
|
|
21
|
+
}
|
|
22
|
+
declare class SearchProvider {
|
|
23
|
+
readonly client: SeekoraClient;
|
|
24
|
+
readonly theme: Theme;
|
|
25
|
+
readonly enableAnalytics: boolean;
|
|
26
|
+
readonly autoTrackSearch: boolean;
|
|
27
|
+
readonly stateManager: SearchStateManager;
|
|
28
|
+
private static instance;
|
|
29
|
+
constructor(config: SearchProviderConfig);
|
|
30
|
+
static getInstance(): SearchProvider | null;
|
|
31
|
+
static setInstance(provider: SearchProvider): void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* SearchBar Component
|
|
36
|
+
*
|
|
37
|
+
* Creates a search bar with autocomplete suggestions
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
interface TrendingProduct {
|
|
41
|
+
id: string;
|
|
42
|
+
title: string;
|
|
43
|
+
image?: string;
|
|
44
|
+
price?: number | string;
|
|
45
|
+
currency?: string;
|
|
46
|
+
url?: string;
|
|
47
|
+
clicks: number;
|
|
48
|
+
conversions?: number;
|
|
49
|
+
revenue?: number;
|
|
50
|
+
trend_score?: number;
|
|
51
|
+
metadata?: Record<string, any>;
|
|
52
|
+
}
|
|
53
|
+
interface PopularBrand {
|
|
54
|
+
name: string;
|
|
55
|
+
logo?: string;
|
|
56
|
+
searches: number;
|
|
57
|
+
clicks?: number;
|
|
58
|
+
conversions?: number;
|
|
59
|
+
metadata?: Record<string, any>;
|
|
60
|
+
}
|
|
61
|
+
interface SearchBarOptions {
|
|
62
|
+
container: HTMLElement | string;
|
|
63
|
+
placeholder?: string;
|
|
64
|
+
showSuggestions?: boolean;
|
|
65
|
+
minQueryLength?: number;
|
|
66
|
+
maxSuggestions?: number;
|
|
67
|
+
debounceMs?: number;
|
|
68
|
+
enableRichSuggestions?: boolean;
|
|
69
|
+
onSearch?: (query: string, results: any) => void;
|
|
70
|
+
onSuggestionSelect?: (suggestion: string) => void;
|
|
71
|
+
onProductClick?: (productId: string, product: TrendingProduct) => void;
|
|
72
|
+
onBrandClick?: (brandName: string, brand: PopularBrand) => void;
|
|
73
|
+
searchOptions?: Partial<SearchOptions> | (() => Partial<SearchOptions>);
|
|
74
|
+
}
|
|
75
|
+
declare class SearchBar {
|
|
76
|
+
private container;
|
|
77
|
+
private inputWrapper;
|
|
78
|
+
private input;
|
|
79
|
+
private responseTimeElement;
|
|
80
|
+
private suggestionsContainer;
|
|
81
|
+
private provider;
|
|
82
|
+
private client;
|
|
83
|
+
private options;
|
|
84
|
+
private suggestions;
|
|
85
|
+
private richSuggestionsData;
|
|
86
|
+
private selectedIndex;
|
|
87
|
+
private debounceTimer;
|
|
88
|
+
private isFocused;
|
|
89
|
+
private unsubscribeStateManager;
|
|
90
|
+
private cachedStoreId;
|
|
91
|
+
private cachedReadSecret;
|
|
92
|
+
private cachedEnvironment;
|
|
93
|
+
constructor(providerOrClient: SearchProvider | SeekoraClient, options: SearchBarOptions);
|
|
94
|
+
private render;
|
|
95
|
+
private injectPlaceholderStyles;
|
|
96
|
+
private attachEventListeners;
|
|
97
|
+
private handleInputChange;
|
|
98
|
+
private handleKeyDown;
|
|
99
|
+
private selectSuggestion;
|
|
100
|
+
private fetchRichSuggestions;
|
|
101
|
+
private fallbackToBasicSuggestions;
|
|
102
|
+
private cacheClientCredentials;
|
|
103
|
+
private performSearch;
|
|
104
|
+
private renderSuggestions;
|
|
105
|
+
private updateSuggestionsVisibility;
|
|
106
|
+
private getInputStyle;
|
|
107
|
+
private getResponseTimeStyle;
|
|
108
|
+
private getSuggestionsContainerStyle;
|
|
109
|
+
private getSuggestionItemStyle;
|
|
110
|
+
private getSectionStyle;
|
|
111
|
+
private getSectionTitleStyle;
|
|
112
|
+
private getSuggestionsListStyle;
|
|
113
|
+
private getCountStyle;
|
|
114
|
+
private getProductsGridStyle;
|
|
115
|
+
private getProductCardStyle;
|
|
116
|
+
private getProductImageStyle;
|
|
117
|
+
private getProductInfoStyle;
|
|
118
|
+
private getProductTitleStyle;
|
|
119
|
+
private getProductPriceStyle;
|
|
120
|
+
private getBrandsListStyle;
|
|
121
|
+
private getBrandItemStyle;
|
|
122
|
+
private getBrandLogoStyle;
|
|
123
|
+
private getBrandNameStyle;
|
|
124
|
+
/**
|
|
125
|
+
* Trigger a search programmatically
|
|
126
|
+
* @param query - Optional query string. If not provided, uses current input value or "*" for all
|
|
127
|
+
*/
|
|
128
|
+
search(query?: string): Promise<void>;
|
|
129
|
+
destroy(): void;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* SearchResults Component
|
|
134
|
+
*
|
|
135
|
+
* Displays search results with customizable rendering
|
|
136
|
+
*/
|
|
137
|
+
|
|
138
|
+
interface SearchResultsOptions {
|
|
139
|
+
container: HTMLElement | string;
|
|
140
|
+
results?: SearchResponse | null;
|
|
141
|
+
loading?: boolean;
|
|
142
|
+
error?: Error | null;
|
|
143
|
+
viewMode?: ViewMode;
|
|
144
|
+
fieldMapping?: FieldMapping;
|
|
145
|
+
itemsPerPage?: number;
|
|
146
|
+
onResultClick?: (result: ResultItem, index: number) => void;
|
|
147
|
+
renderResult?: (result: ResultItem, index: number) => HTMLElement;
|
|
148
|
+
renderEmpty?: () => HTMLElement;
|
|
149
|
+
renderLoading?: () => HTMLElement;
|
|
150
|
+
renderError?: (error: Error) => HTMLElement;
|
|
151
|
+
}
|
|
152
|
+
declare class SearchResults {
|
|
153
|
+
private container;
|
|
154
|
+
private provider;
|
|
155
|
+
private options;
|
|
156
|
+
private unsubscribeStateManager;
|
|
157
|
+
constructor(provider: SearchProvider, options: SearchResultsOptions);
|
|
158
|
+
destroy(): void;
|
|
159
|
+
update(options: Partial<Pick<SearchResultsOptions, 'results' | 'loading' | 'error'>>): void;
|
|
160
|
+
private render;
|
|
161
|
+
private extractResults;
|
|
162
|
+
private extractFields;
|
|
163
|
+
private renderDefaultLoading;
|
|
164
|
+
private renderDefaultError;
|
|
165
|
+
private renderDefaultEmpty;
|
|
166
|
+
private renderDefaultResult;
|
|
167
|
+
private renderCardResult;
|
|
168
|
+
private renderListResult;
|
|
169
|
+
private get theme();
|
|
170
|
+
private getLoadingStyle;
|
|
171
|
+
private getErrorStyle;
|
|
172
|
+
private getEmptyStyle;
|
|
173
|
+
private getGridContainerStyle;
|
|
174
|
+
private getResultStyle;
|
|
175
|
+
private getImageContainerStyle;
|
|
176
|
+
private getImageStyle;
|
|
177
|
+
private getCardContentStyle;
|
|
178
|
+
private getListContentStyle;
|
|
179
|
+
private getListImageStyle;
|
|
180
|
+
private getTitleStyle;
|
|
181
|
+
private getDescriptionStyle;
|
|
182
|
+
private getPriceStyle;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Stats Component
|
|
187
|
+
*
|
|
188
|
+
* Displays search statistics (total results, processing time, etc.)
|
|
189
|
+
*/
|
|
190
|
+
|
|
191
|
+
interface StatsOptions {
|
|
192
|
+
container: HTMLElement | string;
|
|
193
|
+
results?: SearchResponse | null;
|
|
194
|
+
loading?: boolean;
|
|
195
|
+
showProcessingTime?: boolean;
|
|
196
|
+
labels?: {
|
|
197
|
+
resultsFound?: (count: number) => string;
|
|
198
|
+
processingTime?: (time: number) => string;
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
declare class Stats {
|
|
202
|
+
private container;
|
|
203
|
+
private provider;
|
|
204
|
+
private options;
|
|
205
|
+
private unsubscribeStateManager;
|
|
206
|
+
constructor(provider: SearchProvider, options: StatsOptions);
|
|
207
|
+
destroy(): void;
|
|
208
|
+
update(options: Partial<Pick<StatsOptions, 'results' | 'loading'>>): void;
|
|
209
|
+
private render;
|
|
210
|
+
private getTotalResults;
|
|
211
|
+
private getProcessingTime;
|
|
212
|
+
private getResultsLabel;
|
|
213
|
+
private getProcessingTimeLabel;
|
|
214
|
+
private get theme();
|
|
215
|
+
private getContainerStyle;
|
|
216
|
+
private getResultsStyle;
|
|
217
|
+
private getTimeStyle;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* Pagination Component
|
|
222
|
+
*
|
|
223
|
+
* Displays pagination controls for search results
|
|
224
|
+
*/
|
|
225
|
+
|
|
226
|
+
interface PaginationOptions {
|
|
227
|
+
container: HTMLElement | string;
|
|
228
|
+
results?: SearchResponse | null;
|
|
229
|
+
currentPage?: number;
|
|
230
|
+
itemsPerPage?: number;
|
|
231
|
+
showFirstLast?: boolean;
|
|
232
|
+
showPrevNext?: boolean;
|
|
233
|
+
onPageChange?: (page: number) => void;
|
|
234
|
+
}
|
|
235
|
+
declare class Pagination {
|
|
236
|
+
private container;
|
|
237
|
+
private provider;
|
|
238
|
+
private options;
|
|
239
|
+
private currentPage;
|
|
240
|
+
private unsubscribeStateManager;
|
|
241
|
+
constructor(provider: SearchProvider, options: PaginationOptions);
|
|
242
|
+
update(options: Partial<Pick<PaginationOptions, 'results' | 'currentPage'>>): void;
|
|
243
|
+
destroy(): void;
|
|
244
|
+
private render;
|
|
245
|
+
private getTotalPages;
|
|
246
|
+
private createButton;
|
|
247
|
+
private get theme();
|
|
248
|
+
private getContainerStyle;
|
|
249
|
+
private getButtonStyle;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* SortBy Component
|
|
254
|
+
*
|
|
255
|
+
* Displays sort options for search results
|
|
256
|
+
*/
|
|
257
|
+
|
|
258
|
+
interface SortOption {
|
|
259
|
+
value: string;
|
|
260
|
+
label: string;
|
|
261
|
+
}
|
|
262
|
+
interface SortByOptions {
|
|
263
|
+
container: HTMLElement | string;
|
|
264
|
+
options: SortOption[];
|
|
265
|
+
value?: string;
|
|
266
|
+
label?: string;
|
|
267
|
+
onSortChange?: (value: string) => void;
|
|
268
|
+
}
|
|
269
|
+
declare class SortBy {
|
|
270
|
+
private container;
|
|
271
|
+
private provider;
|
|
272
|
+
private options;
|
|
273
|
+
private currentValue;
|
|
274
|
+
private unsubscribeStateManager;
|
|
275
|
+
constructor(provider: SearchProvider, options: SortByOptions);
|
|
276
|
+
destroy(): void;
|
|
277
|
+
update(options: Partial<Pick<SortByOptions, 'value'>>): void;
|
|
278
|
+
private render;
|
|
279
|
+
private get theme();
|
|
280
|
+
private getContainerStyle;
|
|
281
|
+
private getLabelStyle;
|
|
282
|
+
private getSelectStyle;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Facets Component
|
|
287
|
+
*
|
|
288
|
+
* Displays facet filters for search results
|
|
289
|
+
*/
|
|
290
|
+
|
|
291
|
+
interface FacetItem {
|
|
292
|
+
value: string;
|
|
293
|
+
count: number;
|
|
294
|
+
selected?: boolean;
|
|
295
|
+
}
|
|
296
|
+
interface Facet {
|
|
297
|
+
field: string;
|
|
298
|
+
label?: string;
|
|
299
|
+
items: FacetItem[];
|
|
300
|
+
}
|
|
301
|
+
interface FacetsOptions {
|
|
302
|
+
container: HTMLElement | string;
|
|
303
|
+
results?: SearchResponse | null;
|
|
304
|
+
facets?: Facet[];
|
|
305
|
+
maxItems?: number;
|
|
306
|
+
showMore?: boolean;
|
|
307
|
+
onFacetChange?: (field: string, value: string, selected: boolean) => void;
|
|
308
|
+
}
|
|
309
|
+
declare class Facets {
|
|
310
|
+
private container;
|
|
311
|
+
private provider;
|
|
312
|
+
private options;
|
|
313
|
+
private expandedFacets;
|
|
314
|
+
private unsubscribeStateManager;
|
|
315
|
+
constructor(provider: SearchProvider, options: FacetsOptions);
|
|
316
|
+
update(options: Partial<Pick<FacetsOptions, 'results' | 'facets'>>): void;
|
|
317
|
+
private render;
|
|
318
|
+
private getFacets;
|
|
319
|
+
private get theme();
|
|
320
|
+
private getFacetStyle;
|
|
321
|
+
private getFacetHeaderStyle;
|
|
322
|
+
private getFacetListStyle;
|
|
323
|
+
private getFacetItemStyle;
|
|
324
|
+
private getFacetItemLabelStyle;
|
|
325
|
+
private getFacetItemCountStyle;
|
|
326
|
+
private getShowMoreStyle;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* CurrentRefinements Component
|
|
331
|
+
*
|
|
332
|
+
* Displays currently active filters/refinements with ability to clear them
|
|
333
|
+
*/
|
|
334
|
+
|
|
335
|
+
interface Refinement {
|
|
336
|
+
field: string;
|
|
337
|
+
label?: string;
|
|
338
|
+
value: string;
|
|
339
|
+
displayValue?: string;
|
|
340
|
+
}
|
|
341
|
+
interface CurrentRefinementsOptions {
|
|
342
|
+
container: HTMLElement | string;
|
|
343
|
+
refinements?: Refinement[];
|
|
344
|
+
showClearAll?: boolean;
|
|
345
|
+
onRefinementClear?: (field: string, value: string) => void;
|
|
346
|
+
onClearAll?: () => void;
|
|
347
|
+
}
|
|
348
|
+
declare class CurrentRefinements {
|
|
349
|
+
private container;
|
|
350
|
+
private provider;
|
|
351
|
+
private options;
|
|
352
|
+
private unsubscribeStateManager;
|
|
353
|
+
constructor(provider: SearchProvider, options: CurrentRefinementsOptions);
|
|
354
|
+
update(options: Partial<Pick<CurrentRefinementsOptions, 'refinements'>>): void;
|
|
355
|
+
private render;
|
|
356
|
+
private get theme();
|
|
357
|
+
private getContainerStyle;
|
|
358
|
+
private getItemStyle;
|
|
359
|
+
private getLabelStyle;
|
|
360
|
+
private getValueStyle;
|
|
361
|
+
private getClearButtonStyle;
|
|
362
|
+
private getClearAllButtonStyle;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* ClearRefinements Component
|
|
367
|
+
*
|
|
368
|
+
* A standalone button to clear all active refinements/filters
|
|
369
|
+
* Integrates with SearchStateManager for automatic state sync
|
|
370
|
+
*/
|
|
371
|
+
|
|
372
|
+
interface ClearRefinementsOptions {
|
|
373
|
+
container: HTMLElement | string;
|
|
374
|
+
/** Whether clicking should also clear the search query */
|
|
375
|
+
clearsQuery?: boolean;
|
|
376
|
+
/** Button text when there are refinements to clear */
|
|
377
|
+
resetLabel?: string;
|
|
378
|
+
/** Button text shown when there are no refinements */
|
|
379
|
+
disabledLabel?: string;
|
|
380
|
+
/** Fields to include (if not specified, all fields are included) */
|
|
381
|
+
includedFields?: string[];
|
|
382
|
+
/** Fields to exclude from clearing */
|
|
383
|
+
excludedFields?: string[];
|
|
384
|
+
/** Callback when refinements are cleared */
|
|
385
|
+
onClear?: () => void;
|
|
386
|
+
/** Whether to hide when there are no refinements */
|
|
387
|
+
hideWhenEmpty?: boolean;
|
|
388
|
+
}
|
|
389
|
+
declare class ClearRefinements {
|
|
390
|
+
private container;
|
|
391
|
+
private provider;
|
|
392
|
+
private options;
|
|
393
|
+
private unsubscribeStateManager;
|
|
394
|
+
constructor(provider: SearchProvider, options: ClearRefinementsOptions);
|
|
395
|
+
destroy(): void;
|
|
396
|
+
private getRelevantRefinements;
|
|
397
|
+
private canClear;
|
|
398
|
+
private handleClick;
|
|
399
|
+
private render;
|
|
400
|
+
private get theme();
|
|
401
|
+
private getButtonStyle;
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* RangeInput Component
|
|
406
|
+
*
|
|
407
|
+
* Displays a range input for filtering numeric values (e.g., price range)
|
|
408
|
+
*/
|
|
409
|
+
|
|
410
|
+
interface RangeInputOptions {
|
|
411
|
+
container: HTMLElement | string;
|
|
412
|
+
field: string;
|
|
413
|
+
label?: string;
|
|
414
|
+
min?: number;
|
|
415
|
+
max?: number;
|
|
416
|
+
step?: number;
|
|
417
|
+
currentMin?: number;
|
|
418
|
+
currentMax?: number;
|
|
419
|
+
showApplyButton?: boolean;
|
|
420
|
+
placeholder?: {
|
|
421
|
+
min?: string;
|
|
422
|
+
max?: string;
|
|
423
|
+
};
|
|
424
|
+
onRangeChange?: (min: number | undefined, max: number | undefined) => void;
|
|
425
|
+
}
|
|
426
|
+
declare class RangeInput {
|
|
427
|
+
private container;
|
|
428
|
+
private provider;
|
|
429
|
+
private options;
|
|
430
|
+
private internalMin?;
|
|
431
|
+
private internalMax?;
|
|
432
|
+
constructor(provider: SearchProvider, options: RangeInputOptions);
|
|
433
|
+
update(options: Partial<Pick<RangeInputOptions, 'currentMin' | 'currentMax'>>): void;
|
|
434
|
+
private render;
|
|
435
|
+
private hasValue;
|
|
436
|
+
private updateStateManager;
|
|
437
|
+
private get theme();
|
|
438
|
+
private getLabelStyle;
|
|
439
|
+
private getInputGroupStyle;
|
|
440
|
+
private getInputStyle;
|
|
441
|
+
private getSeparatorStyle;
|
|
442
|
+
private getApplyButtonStyle;
|
|
443
|
+
private getResetButtonStyle;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* HitsPerPage Component
|
|
448
|
+
*
|
|
449
|
+
* A dropdown to let users change the number of displayed hits per page
|
|
450
|
+
* Integrates with SearchStateManager for automatic state sync
|
|
451
|
+
*/
|
|
452
|
+
|
|
453
|
+
interface HitsPerPageItem {
|
|
454
|
+
value: number;
|
|
455
|
+
label: string;
|
|
456
|
+
default?: boolean;
|
|
457
|
+
}
|
|
458
|
+
interface HitsPerPageOptions {
|
|
459
|
+
container: HTMLElement | string;
|
|
460
|
+
/** Available items per page options */
|
|
461
|
+
items: HitsPerPageItem[];
|
|
462
|
+
/** Label text before the select */
|
|
463
|
+
label?: string;
|
|
464
|
+
/** Callback when hits per page changes */
|
|
465
|
+
onHitsPerPageChange?: (value: number) => void;
|
|
466
|
+
}
|
|
467
|
+
declare class HitsPerPage {
|
|
468
|
+
private container;
|
|
469
|
+
private provider;
|
|
470
|
+
private options;
|
|
471
|
+
private currentValue;
|
|
472
|
+
private unsubscribeStateManager;
|
|
473
|
+
constructor(provider: SearchProvider, options: HitsPerPageOptions);
|
|
474
|
+
destroy(): void;
|
|
475
|
+
update(options: Partial<Pick<HitsPerPageOptions, 'items'>>): void;
|
|
476
|
+
private render;
|
|
477
|
+
private get theme();
|
|
478
|
+
private getContainerStyle;
|
|
479
|
+
private getLabelStyle;
|
|
480
|
+
private getSelectStyle;
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* InfiniteHits Component
|
|
485
|
+
*
|
|
486
|
+
* Displays search results with infinite scroll or "Show More" button
|
|
487
|
+
* Accumulates results as user loads more pages
|
|
488
|
+
*/
|
|
489
|
+
|
|
490
|
+
interface InfiniteHitsOptions {
|
|
491
|
+
container: HTMLElement | string;
|
|
492
|
+
/** Custom render function for each hit */
|
|
493
|
+
renderHit?: (hit: ResultItem, index: number) => HTMLElement;
|
|
494
|
+
/** Custom render for empty state */
|
|
495
|
+
renderEmpty?: () => HTMLElement;
|
|
496
|
+
/** Custom render for loading state */
|
|
497
|
+
renderLoading?: () => HTMLElement;
|
|
498
|
+
/** Whether to show the "Show More" button (default: true) */
|
|
499
|
+
showMoreButton?: boolean;
|
|
500
|
+
/** Whether to use infinite scroll with IntersectionObserver (default: false) */
|
|
501
|
+
useInfiniteScroll?: boolean;
|
|
502
|
+
/** Threshold for IntersectionObserver (default: 0.1) */
|
|
503
|
+
scrollThreshold?: number;
|
|
504
|
+
/** Field mapping for extracting data from hits */
|
|
505
|
+
fieldMapping?: FieldMapping;
|
|
506
|
+
/** Text for "Show More" button */
|
|
507
|
+
showMoreLabel?: string;
|
|
508
|
+
/** Text for loading state */
|
|
509
|
+
loadingLabel?: string;
|
|
510
|
+
/** Callback when a hit is clicked */
|
|
511
|
+
onHitClick?: (hit: ResultItem, index: number) => void;
|
|
512
|
+
}
|
|
513
|
+
declare class InfiniteHits {
|
|
514
|
+
private container;
|
|
515
|
+
private provider;
|
|
516
|
+
private options;
|
|
517
|
+
private accumulatedHits;
|
|
518
|
+
private isLoadingMore;
|
|
519
|
+
private currentPage;
|
|
520
|
+
private observer;
|
|
521
|
+
private unsubscribeStateManager;
|
|
522
|
+
constructor(provider: SearchProvider, options: InfiniteHitsOptions);
|
|
523
|
+
destroy(): void;
|
|
524
|
+
private extractHits;
|
|
525
|
+
private get isLastPage();
|
|
526
|
+
private handleShowMore;
|
|
527
|
+
private render;
|
|
528
|
+
private setupIntersectionObserver;
|
|
529
|
+
private createDefaultHit;
|
|
530
|
+
private createDefaultEmpty;
|
|
531
|
+
private createDefaultLoading;
|
|
532
|
+
private createShowMoreButton;
|
|
533
|
+
private extractField;
|
|
534
|
+
private get theme();
|
|
535
|
+
private getHitStyle;
|
|
536
|
+
private getImageStyle;
|
|
537
|
+
private getTitleStyle;
|
|
538
|
+
private getDescriptionStyle;
|
|
539
|
+
private getPriceStyle;
|
|
540
|
+
private getShowMoreButtonStyle;
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* SearchLayout Component
|
|
545
|
+
*
|
|
546
|
+
* Provides a layout structure for search interfaces with sidebar and main content
|
|
547
|
+
*/
|
|
548
|
+
|
|
549
|
+
interface SearchLayoutOptions {
|
|
550
|
+
container: HTMLElement | string;
|
|
551
|
+
sidebar?: HTMLElement | string;
|
|
552
|
+
header?: HTMLElement | string;
|
|
553
|
+
footer?: HTMLElement | string;
|
|
554
|
+
sidebarWidth?: string;
|
|
555
|
+
showSidebarOnMobile?: boolean;
|
|
556
|
+
}
|
|
557
|
+
declare class SearchLayout {
|
|
558
|
+
private container;
|
|
559
|
+
private provider;
|
|
560
|
+
private options;
|
|
561
|
+
private headerEl?;
|
|
562
|
+
private sidebarEl?;
|
|
563
|
+
private mainEl?;
|
|
564
|
+
private footerEl?;
|
|
565
|
+
constructor(provider: SearchProvider, options: SearchLayoutOptions);
|
|
566
|
+
private render;
|
|
567
|
+
getMainElement(): HTMLElement | undefined;
|
|
568
|
+
private get theme();
|
|
569
|
+
private getContainerStyle;
|
|
570
|
+
private getHeaderStyle;
|
|
571
|
+
private getContentStyle;
|
|
572
|
+
private getSidebarStyle;
|
|
573
|
+
private getSidebarClass;
|
|
574
|
+
private getMainStyle;
|
|
575
|
+
private getFooterStyle;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/**
|
|
579
|
+
* QuerySuggestions Component
|
|
580
|
+
*
|
|
581
|
+
* Standalone component for displaying query suggestions
|
|
582
|
+
*/
|
|
583
|
+
|
|
584
|
+
interface QuerySuggestionsOptions {
|
|
585
|
+
container: HTMLElement | string;
|
|
586
|
+
query?: string;
|
|
587
|
+
maxSuggestions?: number;
|
|
588
|
+
debounceMs?: number;
|
|
589
|
+
minQueryLength?: number;
|
|
590
|
+
showTitle?: boolean;
|
|
591
|
+
title?: string;
|
|
592
|
+
onSuggestionClick?: (suggestion: string) => void;
|
|
593
|
+
}
|
|
594
|
+
declare class QuerySuggestions {
|
|
595
|
+
private container;
|
|
596
|
+
private provider;
|
|
597
|
+
private options;
|
|
598
|
+
private suggestions;
|
|
599
|
+
private loading;
|
|
600
|
+
private error;
|
|
601
|
+
private selectedIndex;
|
|
602
|
+
private debounceTimer;
|
|
603
|
+
constructor(provider: SearchProvider, options: QuerySuggestionsOptions);
|
|
604
|
+
update(options: Partial<Pick<QuerySuggestionsOptions, 'query'>>): void;
|
|
605
|
+
private loadSuggestions;
|
|
606
|
+
private render;
|
|
607
|
+
private get theme();
|
|
608
|
+
private getTitleStyle;
|
|
609
|
+
private getLoadingStyle;
|
|
610
|
+
private getEmptyStyle;
|
|
611
|
+
private getListStyle;
|
|
612
|
+
private getSuggestionStyle;
|
|
613
|
+
private getCountStyle;
|
|
614
|
+
destroy(): void;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* SearchManager
|
|
619
|
+
*
|
|
620
|
+
* Manages search state and operations for Vanilla JS
|
|
621
|
+
*/
|
|
622
|
+
|
|
623
|
+
interface SearchManagerConfig {
|
|
624
|
+
client: SeekoraClient;
|
|
625
|
+
theme?: Theme;
|
|
626
|
+
enableAnalytics?: boolean;
|
|
627
|
+
autoTrackSearch?: boolean;
|
|
628
|
+
}
|
|
629
|
+
interface SearchState {
|
|
630
|
+
results: SearchResponse | null;
|
|
631
|
+
loading: boolean;
|
|
632
|
+
error: Error | null;
|
|
633
|
+
}
|
|
634
|
+
declare class SearchManager {
|
|
635
|
+
private client;
|
|
636
|
+
private theme;
|
|
637
|
+
private state;
|
|
638
|
+
private listeners;
|
|
639
|
+
constructor(config: SearchManagerConfig);
|
|
640
|
+
search(options: SearchOptions): Promise<SearchResponse | null>;
|
|
641
|
+
clearResults(): void;
|
|
642
|
+
getState(): SearchState;
|
|
643
|
+
subscribe(listener: (state: SearchState) => void): () => void;
|
|
644
|
+
getTheme(): Theme;
|
|
645
|
+
private setState;
|
|
646
|
+
private getDefaultTheme;
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Default Theme
|
|
651
|
+
*/
|
|
652
|
+
|
|
653
|
+
declare const defaultTheme: Theme;
|
|
654
|
+
|
|
655
|
+
/**
|
|
656
|
+
* Dark Theme
|
|
657
|
+
*/
|
|
658
|
+
|
|
659
|
+
declare const darkTheme: Theme;
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* Minimal Theme
|
|
663
|
+
*/
|
|
664
|
+
|
|
665
|
+
declare const minimalTheme: Theme;
|
|
666
|
+
|
|
667
|
+
declare const createTheme: (config: ThemeConfig) => _seekora_ai_ui_sdk_types.Theme;
|
|
668
|
+
|
|
669
|
+
export { ClearRefinements, CurrentRefinements, Facets, HitsPerPage, InfiniteHits, Pagination, QuerySuggestions, RangeInput, SearchBar, SearchLayout, SearchManager, SearchProvider, SearchResults, SortBy, Stats, createTheme, darkTheme, defaultTheme, minimalTheme };
|
|
670
|
+
export type { ClearRefinementsOptions, CurrentRefinementsOptions, Facet, FacetItem, FacetsOptions, HitsPerPageItem, HitsPerPageOptions, InfiniteHitsOptions, PaginationOptions, QuerySuggestionsOptions, RangeInputOptions, Refinement, SearchBarOptions, SearchLayoutOptions, SearchManagerConfig, SearchProviderConfig, SearchResultsOptions, SearchState, SortByOptions, SortOption, StatsOptions };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAGlE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,YAAY,EACV,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,oBAAoB,GACrB,MAAM,8BAA8B,CAAC;AACtC,YAAY,EACV,oBAAoB,GACrB,MAAM,6BAA6B,CAAC;AACrC,YAAY,EACV,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,iBAAiB,GAClB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACV,aAAa,EACb,UAAU,GACX,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EACV,aAAa,EACb,KAAK,EACL,SAAS,GACV,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,yBAAyB,EACzB,UAAU,GACX,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EACV,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,iBAAiB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EACV,kBAAkB,EAClB,eAAe,GAChB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,mBAAmB,GACpB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EACV,uBAAuB,GACxB,MAAM,gCAAgC,CAAC;AACxC,YAAY,EACV,mBAAmB,EACnB,WAAW,GACZ,MAAM,wBAAwB,CAAC;AAGhC,YAAY,EACV,KAAK,EACL,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,EACR,cAAc,GACf,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGnD,OAAO,EACL,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,gBAAgB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC"}
|