@depict-ai/ui 1.0.14 → 1.0.15
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/README.md +3 -3
- package/dist/index.d.ts +542 -562
- package/dist/main.js +83 -169
- package/dist/module.js +86 -169
- package/locales/index.d.ts +89 -89
- package/locales/index.js +2 -2
- package/locales/require.js +2 -2
- package/package.json +11 -51
- package/styles.scss +1 -1
- package/ssr/client/main.js +0 -8813
- package/ssr/client/module.js +0 -8776
- package/ssr/index.d.ts +0 -562
- package/ssr/server/main.js +0 -7829
- package/ssr/server/module.js +0 -7792
package/dist/index.d.ts
CHANGED
|
@@ -1,562 +1,542 @@
|
|
|
1
|
-
import { Display, Elem, ColsAtSize, Node_Array } from "@depict-ai/utilishared";
|
|
2
|
-
import { JSX, Accessor, Setter, Signal } from "solid-js";
|
|
3
|
-
import { SearchResponse } from "@depict-ai/types/api/SearchResponse";
|
|
4
|
-
import { SearchRequest, SearchFilter } from "@depict-ai/types/api/SearchRequest";
|
|
5
|
-
import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
|
|
6
|
-
import { SearchSuggestionsResponse, CategorySuggestion } from "@depict-ai/types/api/SearchSuggestionsResponse";
|
|
7
|
-
import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
|
|
8
|
-
import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
|
|
9
|
-
import { ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
|
|
10
|
-
export const version = "1.0.
|
|
11
|
-
export type OnNavigation = ((options: {
|
|
12
|
-
is_replace: boolean;
|
|
13
|
-
new_url: URL;
|
|
14
|
-
}) => void) | "hard_navigation";
|
|
15
|
-
export type ExclusiveId = {
|
|
16
|
-
categoryId: string;
|
|
17
|
-
productId?: undefined;
|
|
18
|
-
productIds?: undefined;
|
|
19
|
-
} | {
|
|
20
|
-
categoryId?: undefined;
|
|
21
|
-
productId: string;
|
|
22
|
-
productIds?: undefined;
|
|
23
|
-
} | {
|
|
24
|
-
categoryId?: undefined;
|
|
25
|
-
productId?: undefined;
|
|
26
|
-
productIds: string[];
|
|
27
|
-
} | {
|
|
28
|
-
categoryId?: undefined;
|
|
29
|
-
productId?: undefined;
|
|
30
|
-
productIds?: undefined;
|
|
31
|
-
};
|
|
32
|
-
type RecsAPIWrapperOptions = {
|
|
33
|
-
type: string;
|
|
34
|
-
merchant: string;
|
|
35
|
-
market: string;
|
|
36
|
-
userId?: string;
|
|
37
|
-
sessionId?: string;
|
|
38
|
-
headers?: HeadersInit;
|
|
39
|
-
} & ExclusiveId;
|
|
40
|
-
/**
|
|
41
|
-
* Fetches recommendations from Depict's API.
|
|
42
|
-
* ## It is important that you make the correct choice out of: no id, `categoryId`, `productId` and `productIds` (choose ONE) so read the documentation carefully.
|
|
43
|
-
*
|
|
44
|
-
* @param merchant The name of the merchant (e.g. "acme")
|
|
45
|
-
* @param market The market to fetch recs for. Depict will provide this to you. (Example: "sv" or "sv-se".)
|
|
46
|
-
* @param type The type of the recommendations, e.g. `front_page`, `after_basket, `related`, etc. Ask Depict for this.
|
|
47
|
-
* @param categoryId When requesting recommendations for a category page, pass the id of the category page as `categoryId`.
|
|
48
|
-
* @param productId When requesting recommendations for a single product, e.g. on a product detail page, pass the id of the product as `productId`.
|
|
49
|
-
* @param productIds When requesting recommendations that should take multiple products into account, i.e. the contents of the basket/cart, pass an array of product ids as `productIds`
|
|
50
|
-
* @param userId Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
|
|
51
|
-
* @param sessionId Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
|
|
52
|
-
* @param headers Optional headers to send to the Depict API. This could be authentication for example. 99% of integrations can leave this unset.
|
|
53
|
-
* When no id is provided (none out of `categoryId`, `productId` and `productIds`) general recommendations will be fetched. This is for, for example, the frontpage where generally popular products get returned.
|
|
54
|
-
*
|
|
55
|
-
* @note If you only get recommendations when specifying the wrong id type (i.e. you only get basket recommendations if you provide a single product id while the recommendations should be based on everything in the basket) please ask Depict to re-configure the endpoint for you.
|
|
56
|
-
*
|
|
57
|
-
* @example Fetching frontpage recommendations
|
|
58
|
-
* ```
|
|
59
|
-
* const front_page_recs = await fetchDepictRecommendations({
|
|
60
|
-
* merchant: "oscarjacobson",
|
|
61
|
-
* market: "sv-se",
|
|
62
|
-
* type: "front_page",
|
|
63
|
-
* });
|
|
64
|
-
* ```
|
|
65
|
-
* @example Fetching recommendations for a product page
|
|
66
|
-
* ```
|
|
67
|
-
* const product_page_recs = await fetchDepictRecommendations({
|
|
68
|
-
* merchant: "stronger",
|
|
69
|
-
* market: "se",
|
|
70
|
-
* type: "product_normal",
|
|
71
|
-
* productId: "hero-sports-bra-luna",
|
|
72
|
-
* });
|
|
73
|
-
* ```
|
|
74
|
-
* @return This function is guaranteed to return an array of Displays. If anything fails, you will get an empty array.
|
|
75
|
-
*/
|
|
76
|
-
export function fetchDepictRecommendations<T extends Display = Display>({ merchant, market, headers, ...fetch_recs_options }: RecsAPIWrapperOptions): Promise<T[]>;
|
|
77
|
-
/**
|
|
78
|
-
* Like standard_price_format except that the price and the formatting are reactive accessors
|
|
79
|
-
*/
|
|
80
|
-
export function SolidFormatPrice(props: {
|
|
81
|
-
price_: number;
|
|
82
|
-
price_formatting_: {
|
|
83
|
-
pre_: string;
|
|
84
|
-
post_: string;
|
|
85
|
-
decimal_places_delimiter_: string;
|
|
86
|
-
thousands_delimiter_: string;
|
|
87
|
-
places_after_comma_: number | "auto";
|
|
88
|
-
};
|
|
89
|
-
}): JSX.Element;
|
|
90
|
-
/**
|
|
91
|
-
* PLP internationalisation shared between search and category listing
|
|
92
|
-
*/
|
|
93
|
-
type plp_shared_i18n = {
|
|
94
|
-
scroll_to_top_: string;
|
|
95
|
-
back_: string;
|
|
96
|
-
open_sorting_: string;
|
|
97
|
-
close_sorting_: string;
|
|
98
|
-
open_filters_: string;
|
|
99
|
-
close_filters_: string;
|
|
100
|
-
close_: string;
|
|
101
|
-
ok_: string;
|
|
102
|
-
filters_cleared_: string;
|
|
103
|
-
we_cleared_your_filters_: string;
|
|
104
|
-
restore_: string;
|
|
105
|
-
sorting_text_: string;
|
|
106
|
-
filter_text_: string;
|
|
107
|
-
selected_filters_title_: string;
|
|
108
|
-
filters_: string;
|
|
109
|
-
view_less_: string;
|
|
110
|
-
view_more_: string;
|
|
111
|
-
clear_all_from_filter_crumbs_: string;
|
|
112
|
-
clear_individual_filter_: string;
|
|
113
|
-
of_: string;
|
|
114
|
-
clear_all_filters_from_big_button_: string;
|
|
115
|
-
try_without_filters_: string;
|
|
116
|
-
range_filter_low_point_aria_label_: string;
|
|
117
|
-
range_filter_high_point_aria_label_: string;
|
|
118
|
-
morphing_sign_expanded_aria_label_: string;
|
|
119
|
-
morphing_sign_collapsed_aria_label_: string;
|
|
120
|
-
price_formatting_: {
|
|
121
|
-
pre_: string;
|
|
122
|
-
post_: string;
|
|
123
|
-
decimal_places_delimiter_: string;
|
|
124
|
-
thousands_delimiter_: string;
|
|
125
|
-
places_after_comma_: number | "auto";
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Search internationalisation
|
|
130
|
-
*/
|
|
131
|
-
interface search_i18n extends plp_shared_i18n {
|
|
132
|
-
placeholder_text_: string;
|
|
133
|
-
show_n_results_: (number_of_results: HTMLElement) => Elem[];
|
|
134
|
-
no_results_text_: string;
|
|
135
|
-
search_recs_title_: string;
|
|
136
|
-
clear_filters_query_sorting_after_submit_: string;
|
|
137
|
-
modal_view_all_results_: (number_of_results: HTMLElement) => Elem[];
|
|
138
|
-
modal_discover_more_: string;
|
|
139
|
-
get_showing_results_for_: (query: HTMLElement, number_of_results: HTMLElement) => Elem[];
|
|
140
|
-
previous_searches_text_: string;
|
|
141
|
-
category_: string;
|
|
142
|
-
suggestions_: string;
|
|
143
|
-
search_submit_button_aria_label_: string;
|
|
144
|
-
search_field_field_aria_label_: string;
|
|
145
|
-
previous_searches_delete_entry_from_history_: string;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Category internationalisation
|
|
149
|
-
*/
|
|
150
|
-
interface category_i18n extends plp_shared_i18n {
|
|
151
|
-
show_n_products_: (number_of_results: HTMLElement) => Elem[];
|
|
152
|
-
no_products_text_: string;
|
|
153
|
-
product_: string;
|
|
154
|
-
products_: string;
|
|
155
|
-
breadcrumbs_aria_label_: string;
|
|
156
|
-
quicklinks_aria_label_: string;
|
|
157
|
-
breadcrumbs_separator_: string;
|
|
158
|
-
}
|
|
159
|
-
export type InstantCard<T extends Display> = (display: T, context: {
|
|
160
|
-
index: number;
|
|
161
|
-
i18n: search_i18n;
|
|
162
|
-
merchant: string;
|
|
163
|
-
market: string;
|
|
164
|
-
}) => JSX.Element;
|
|
165
|
-
interface DepictAPIConstructorOptions {
|
|
166
|
-
get_metadata?: () => Promise<{
|
|
167
|
-
[k: string]: string;
|
|
168
|
-
} | undefined>;
|
|
169
|
-
get_user_id?: () => string | undefined;
|
|
170
|
-
get_session_id?: () => string | undefined;
|
|
171
|
-
}
|
|
172
|
-
export class DepictAPI {
|
|
173
|
-
#private;
|
|
174
|
-
constructor({ get_metadata, get_user_id, get_session_id }?: DepictAPIConstructorOptions);
|
|
175
|
-
suggest(input_req: SearchSuggestionsRequest): Promise<SearchSuggestionsResponse & {
|
|
176
|
-
failed?: true;
|
|
177
|
-
}>;
|
|
178
|
-
query(input_req: SearchRequest): Promise<SearchResponse & {
|
|
179
|
-
failed?: true;
|
|
180
|
-
}>;
|
|
181
|
-
list(input_req: ProductListingRequest): Promise<ProductListingResponse & {
|
|
182
|
-
failed?: true;
|
|
183
|
-
}>;
|
|
184
|
-
get_recommended<D extends Display>(input_req: BaseSearchRequest): Promise<{
|
|
185
|
-
displays: D[];
|
|
186
|
-
}>;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Use `javascript_media_query` but return a reactive accessor instead of taking a callback function
|
|
190
|
-
*/
|
|
191
|
-
export function media_query_to_accessor(media_query: string): import("solid-js").Accessor<boolean>;
|
|
192
|
-
export type SDKGridSpacing = string | {
|
|
193
|
-
horizontal: string;
|
|
194
|
-
vertical: string;
|
|
195
|
-
};
|
|
196
|
-
export type WithRequired<T, K extends keyof T> = T & {
|
|
197
|
-
[P in K]-?: T[P];
|
|
198
|
-
};
|
|
199
|
-
export interface SDKRenderingInfo {
|
|
200
|
-
set_on_index_change: (fn: (index: number) => void) => void;
|
|
201
|
-
merchant: string;
|
|
202
|
-
market: string;
|
|
203
|
-
}
|
|
204
|
-
export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
|
|
205
|
-
export function show_toast({ children, on_close_, close_after_, ...more_attributes }: {
|
|
206
|
-
children?: JSX.Element;
|
|
207
|
-
close_after_: number;
|
|
208
|
-
on_close_?: VoidFunction;
|
|
209
|
-
} & JSX.HTMLAttributes<HTMLDivElement>): {
|
|
210
|
-
close_toast_: VoidFunction;
|
|
211
|
-
};
|
|
212
|
-
declare class SDKError extends Error {
|
|
213
|
-
}
|
|
214
|
-
export class ProductCardError extends SDKError {
|
|
215
|
-
constructor(templateError: Error);
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
*
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
}
|
|
305
|
-
export
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
};
|
|
316
|
-
type
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
export function
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
export
|
|
418
|
-
/**
|
|
419
|
-
*
|
|
420
|
-
* @
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
*
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
*
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
*
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
*
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
*
|
|
450
|
-
* @default
|
|
451
|
-
*/
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
*
|
|
465
|
-
*
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
*
|
|
516
|
-
* @
|
|
517
|
-
*/
|
|
518
|
-
export
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
*
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
export
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
get open_(): boolean;
|
|
544
|
-
/**
|
|
545
|
-
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
546
|
-
*/
|
|
547
|
-
destroy_(): void;
|
|
548
|
-
constructor({ is_spa_, ...options }: Omit<PageReplacer, "destroy_" | "addEventListener" | "removeEventListener" | "dispatchEvent" | "open_"> & {
|
|
549
|
-
is_spa_?: boolean;
|
|
550
|
-
});
|
|
551
|
-
}
|
|
552
|
-
/**
|
|
553
|
-
* makes so that links to the previous page close the search instead of closing the search and reloading the page (to be used with non-spas)
|
|
554
|
-
*/
|
|
555
|
-
export function setup_fast_leave(pr: PageReplacer): void;
|
|
556
|
-
export const defaultColsAtSize: SDKColsAtSize;
|
|
557
|
-
export const defaultGridSpacing = "2%";
|
|
558
|
-
export const defaultCategoryTitlePlugin: ({ category_title_, product_count_, }: {
|
|
559
|
-
category_title_: import("solid-js").Accessor<string | undefined>;
|
|
560
|
-
product_count_: import("solid-js").JSX.Element;
|
|
561
|
-
}) => import("solid-js").JSX.Element;
|
|
562
|
-
export type { SearchFilter } from "@depict-ai/types/api/SearchRequest";
|
|
1
|
+
import { Display, Elem, ColsAtSize, Node_Array } from "@depict-ai/utilishared";
|
|
2
|
+
import { JSX, Accessor, Setter, Signal } from "solid-js";
|
|
3
|
+
import { SearchResponse } from "@depict-ai/types/api/SearchResponse";
|
|
4
|
+
import { SearchRequest, SearchFilter } from "@depict-ai/types/api/SearchRequest";
|
|
5
|
+
import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
|
|
6
|
+
import { SearchSuggestionsResponse, CategorySuggestion } from "@depict-ai/types/api/SearchSuggestionsResponse";
|
|
7
|
+
import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
|
|
8
|
+
import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
|
|
9
|
+
import { ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
|
|
10
|
+
export const version = "1.0.15";
|
|
11
|
+
export type OnNavigation = ((options: {
|
|
12
|
+
is_replace: boolean;
|
|
13
|
+
new_url: URL;
|
|
14
|
+
}) => void) | "hard_navigation";
|
|
15
|
+
export type ExclusiveId = {
|
|
16
|
+
categoryId: string;
|
|
17
|
+
productId?: undefined;
|
|
18
|
+
productIds?: undefined;
|
|
19
|
+
} | {
|
|
20
|
+
categoryId?: undefined;
|
|
21
|
+
productId: string;
|
|
22
|
+
productIds?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
categoryId?: undefined;
|
|
25
|
+
productId?: undefined;
|
|
26
|
+
productIds: string[];
|
|
27
|
+
} | {
|
|
28
|
+
categoryId?: undefined;
|
|
29
|
+
productId?: undefined;
|
|
30
|
+
productIds?: undefined;
|
|
31
|
+
};
|
|
32
|
+
type RecsAPIWrapperOptions = {
|
|
33
|
+
type: string;
|
|
34
|
+
merchant: string;
|
|
35
|
+
market: string;
|
|
36
|
+
userId?: string;
|
|
37
|
+
sessionId?: string;
|
|
38
|
+
headers?: HeadersInit;
|
|
39
|
+
} & ExclusiveId;
|
|
40
|
+
/**
|
|
41
|
+
* Fetches recommendations from Depict's API.
|
|
42
|
+
* ## It is important that you make the correct choice out of: no id, `categoryId`, `productId` and `productIds` (choose ONE) so read the documentation carefully.
|
|
43
|
+
*
|
|
44
|
+
* @param merchant The name of the merchant (e.g. "acme")
|
|
45
|
+
* @param market The market to fetch recs for. Depict will provide this to you. (Example: "sv" or "sv-se".)
|
|
46
|
+
* @param type The type of the recommendations, e.g. `front_page`, `after_basket, `related`, etc. Ask Depict for this.
|
|
47
|
+
* @param categoryId When requesting recommendations for a category page, pass the id of the category page as `categoryId`.
|
|
48
|
+
* @param productId When requesting recommendations for a single product, e.g. on a product detail page, pass the id of the product as `productId`.
|
|
49
|
+
* @param productIds When requesting recommendations that should take multiple products into account, i.e. the contents of the basket/cart, pass an array of product ids as `productIds`
|
|
50
|
+
* @param userId Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
|
|
51
|
+
* @param sessionId Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
|
|
52
|
+
* @param headers Optional headers to send to the Depict API. This could be authentication for example. 99% of integrations can leave this unset.
|
|
53
|
+
* When no id is provided (none out of `categoryId`, `productId` and `productIds`) general recommendations will be fetched. This is for, for example, the frontpage where generally popular products get returned.
|
|
54
|
+
*
|
|
55
|
+
* @note If you only get recommendations when specifying the wrong id type (i.e. you only get basket recommendations if you provide a single product id while the recommendations should be based on everything in the basket) please ask Depict to re-configure the endpoint for you.
|
|
56
|
+
*
|
|
57
|
+
* @example Fetching frontpage recommendations
|
|
58
|
+
* ```
|
|
59
|
+
* const front_page_recs = await fetchDepictRecommendations({
|
|
60
|
+
* merchant: "oscarjacobson",
|
|
61
|
+
* market: "sv-se",
|
|
62
|
+
* type: "front_page",
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
* @example Fetching recommendations for a product page
|
|
66
|
+
* ```
|
|
67
|
+
* const product_page_recs = await fetchDepictRecommendations({
|
|
68
|
+
* merchant: "stronger",
|
|
69
|
+
* market: "se",
|
|
70
|
+
* type: "product_normal",
|
|
71
|
+
* productId: "hero-sports-bra-luna",
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
* @return This function is guaranteed to return an array of Displays. If anything fails, you will get an empty array.
|
|
75
|
+
*/
|
|
76
|
+
export function fetchDepictRecommendations<T extends Display = Display>({ merchant, market, headers, ...fetch_recs_options }: RecsAPIWrapperOptions): Promise<T[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Like standard_price_format except that the price and the formatting are reactive accessors
|
|
79
|
+
*/
|
|
80
|
+
export function SolidFormatPrice(props: {
|
|
81
|
+
price_: number;
|
|
82
|
+
price_formatting_: {
|
|
83
|
+
pre_: string;
|
|
84
|
+
post_: string;
|
|
85
|
+
decimal_places_delimiter_: string;
|
|
86
|
+
thousands_delimiter_: string;
|
|
87
|
+
places_after_comma_: number | "auto";
|
|
88
|
+
};
|
|
89
|
+
}): JSX.Element;
|
|
90
|
+
/**
|
|
91
|
+
* PLP internationalisation shared between search and category listing
|
|
92
|
+
*/
|
|
93
|
+
type plp_shared_i18n = {
|
|
94
|
+
scroll_to_top_: string;
|
|
95
|
+
back_: string;
|
|
96
|
+
open_sorting_: string;
|
|
97
|
+
close_sorting_: string;
|
|
98
|
+
open_filters_: string;
|
|
99
|
+
close_filters_: string;
|
|
100
|
+
close_: string;
|
|
101
|
+
ok_: string;
|
|
102
|
+
filters_cleared_: string;
|
|
103
|
+
we_cleared_your_filters_: string;
|
|
104
|
+
restore_: string;
|
|
105
|
+
sorting_text_: string;
|
|
106
|
+
filter_text_: string;
|
|
107
|
+
selected_filters_title_: string;
|
|
108
|
+
filters_: string;
|
|
109
|
+
view_less_: string;
|
|
110
|
+
view_more_: string;
|
|
111
|
+
clear_all_from_filter_crumbs_: string;
|
|
112
|
+
clear_individual_filter_: string;
|
|
113
|
+
of_: string;
|
|
114
|
+
clear_all_filters_from_big_button_: string;
|
|
115
|
+
try_without_filters_: string;
|
|
116
|
+
range_filter_low_point_aria_label_: string;
|
|
117
|
+
range_filter_high_point_aria_label_: string;
|
|
118
|
+
morphing_sign_expanded_aria_label_: string;
|
|
119
|
+
morphing_sign_collapsed_aria_label_: string;
|
|
120
|
+
price_formatting_: {
|
|
121
|
+
pre_: string;
|
|
122
|
+
post_: string;
|
|
123
|
+
decimal_places_delimiter_: string;
|
|
124
|
+
thousands_delimiter_: string;
|
|
125
|
+
places_after_comma_: number | "auto";
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Search internationalisation
|
|
130
|
+
*/
|
|
131
|
+
interface search_i18n extends plp_shared_i18n {
|
|
132
|
+
placeholder_text_: string;
|
|
133
|
+
show_n_results_: (number_of_results: HTMLElement) => Elem[];
|
|
134
|
+
no_results_text_: string;
|
|
135
|
+
search_recs_title_: string;
|
|
136
|
+
clear_filters_query_sorting_after_submit_: string;
|
|
137
|
+
modal_view_all_results_: (number_of_results: HTMLElement) => Elem[];
|
|
138
|
+
modal_discover_more_: string;
|
|
139
|
+
get_showing_results_for_: (query: HTMLElement, number_of_results: HTMLElement) => Elem[];
|
|
140
|
+
previous_searches_text_: string;
|
|
141
|
+
category_: string;
|
|
142
|
+
suggestions_: string;
|
|
143
|
+
search_submit_button_aria_label_: string;
|
|
144
|
+
search_field_field_aria_label_: string;
|
|
145
|
+
previous_searches_delete_entry_from_history_: string;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Category internationalisation
|
|
149
|
+
*/
|
|
150
|
+
interface category_i18n extends plp_shared_i18n {
|
|
151
|
+
show_n_products_: (number_of_results: HTMLElement) => Elem[];
|
|
152
|
+
no_products_text_: string;
|
|
153
|
+
product_: string;
|
|
154
|
+
products_: string;
|
|
155
|
+
breadcrumbs_aria_label_: string;
|
|
156
|
+
quicklinks_aria_label_: string;
|
|
157
|
+
breadcrumbs_separator_: string;
|
|
158
|
+
}
|
|
159
|
+
export type InstantCard<T extends Display> = (display: T, context: {
|
|
160
|
+
index: number;
|
|
161
|
+
i18n: search_i18n;
|
|
162
|
+
merchant: string;
|
|
163
|
+
market: string;
|
|
164
|
+
}) => JSX.Element;
|
|
165
|
+
interface DepictAPIConstructorOptions {
|
|
166
|
+
get_metadata?: () => Promise<{
|
|
167
|
+
[k: string]: string;
|
|
168
|
+
} | undefined>;
|
|
169
|
+
get_user_id?: () => string | undefined;
|
|
170
|
+
get_session_id?: () => string | undefined;
|
|
171
|
+
}
|
|
172
|
+
export class DepictAPI {
|
|
173
|
+
#private;
|
|
174
|
+
constructor({ get_metadata, get_user_id, get_session_id }?: DepictAPIConstructorOptions);
|
|
175
|
+
suggest(input_req: SearchSuggestionsRequest): Promise<SearchSuggestionsResponse & {
|
|
176
|
+
failed?: true;
|
|
177
|
+
}>;
|
|
178
|
+
query(input_req: SearchRequest): Promise<SearchResponse & {
|
|
179
|
+
failed?: true;
|
|
180
|
+
}>;
|
|
181
|
+
list(input_req: ProductListingRequest): Promise<ProductListingResponse & {
|
|
182
|
+
failed?: true;
|
|
183
|
+
}>;
|
|
184
|
+
get_recommended<D extends Display>(input_req: BaseSearchRequest): Promise<{
|
|
185
|
+
displays: D[];
|
|
186
|
+
}>;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Use `javascript_media_query` but return a reactive accessor instead of taking a callback function
|
|
190
|
+
*/
|
|
191
|
+
export function media_query_to_accessor(media_query: string): import("solid-js").Accessor<boolean>;
|
|
192
|
+
export type SDKGridSpacing = string | {
|
|
193
|
+
horizontal: string;
|
|
194
|
+
vertical: string;
|
|
195
|
+
};
|
|
196
|
+
export type WithRequired<T, K extends keyof T> = T & {
|
|
197
|
+
[P in K]-?: T[P];
|
|
198
|
+
};
|
|
199
|
+
export interface SDKRenderingInfo {
|
|
200
|
+
set_on_index_change: (fn: (index: number) => void) => void;
|
|
201
|
+
merchant: string;
|
|
202
|
+
market: string;
|
|
203
|
+
}
|
|
204
|
+
export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
|
|
205
|
+
export function show_toast({ children, on_close_, close_after_, ...more_attributes }: {
|
|
206
|
+
children?: JSX.Element;
|
|
207
|
+
close_after_: number;
|
|
208
|
+
on_close_?: VoidFunction;
|
|
209
|
+
} & JSX.HTMLAttributes<HTMLDivElement>): {
|
|
210
|
+
close_toast_: VoidFunction;
|
|
211
|
+
};
|
|
212
|
+
declare class SDKError extends Error {
|
|
213
|
+
}
|
|
214
|
+
export class ProductCardError extends SDKError {
|
|
215
|
+
constructor(templateError: Error);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Disables scrolling until the solidjs reactive scoped is disposed (onCleanup)
|
|
219
|
+
* @returns A cleanup function to manually re-enable scrolling.
|
|
220
|
+
*/
|
|
221
|
+
export function disable_scrolling(): () => void;
|
|
222
|
+
export const CategoryTitle: ({ category_title_, product_count_, }: {
|
|
223
|
+
category_title_: Accessor<string | undefined>;
|
|
224
|
+
product_count_: JSX.Element;
|
|
225
|
+
}) => HTMLElement;
|
|
226
|
+
/**
|
|
227
|
+
* Embeds number of products between sort and filter buttons on mobile if possible, only supported for category pages right now. Pass it as category_title_ to Category.
|
|
228
|
+
* Note: this will add an invisible element as first element in depict-search-page which will confuse the flex-gap SCSS mixin a bit so you'll get some extra spacing at the beginning of the search page
|
|
229
|
+
* If you see “ResizeObserver loop limit exceeded”, this is probably doing it. More context here: https://depictaiworkspace.slack.com/archives/C02KVDZ8YHZ/p1667315647758829
|
|
230
|
+
*/
|
|
231
|
+
export const embedded_num_products: ({ make_product_count_, set_observed_results_filters_elements_, is_slim_, sort_and_filter_element_, extra_sort_and_filter_args_, }: {
|
|
232
|
+
make_product_count_: () => JSX.Element;
|
|
233
|
+
set_observed_results_filters_elements_: Setter<JSX.Element>;
|
|
234
|
+
sort_and_filter_element_: Accessor<HTMLDivElement | undefined>;
|
|
235
|
+
is_slim_: Accessor<boolean>;
|
|
236
|
+
extra_sort_and_filter_args_: {
|
|
237
|
+
get_extra_sorting_button_?: ((extra_button: JSX.Element) => unknown) | undefined;
|
|
238
|
+
get_extra_filters_button_?: ((extra_button: JSX.Element) => unknown) | undefined;
|
|
239
|
+
sort_button_width_?: Accessor<number | undefined> | undefined;
|
|
240
|
+
filter_button_width_?: Accessor<number | undefined> | undefined;
|
|
241
|
+
};
|
|
242
|
+
}) => {
|
|
243
|
+
only_show_filters_opener_: Accessor<boolean>;
|
|
244
|
+
middle_elements_: Accessor<JSX.Element>;
|
|
245
|
+
on_filters_constructed_: () => void;
|
|
246
|
+
};
|
|
247
|
+
export type SDKColsAtSize = [number, number?][];
|
|
248
|
+
/**
|
|
249
|
+
* Transform SDK ColsAtSize into valid Layout ColsAtSize
|
|
250
|
+
* @param cols_at_size [nbCol, maxWidth]
|
|
251
|
+
* @returns
|
|
252
|
+
*/
|
|
253
|
+
export const convert_sdk_cols_at_size_to_layout: (cols_at_size: SDKColsAtSize) => ColsAtSize;
|
|
254
|
+
type DepictCategoryConstructorOptions = {
|
|
255
|
+
market: string;
|
|
256
|
+
merchant: string;
|
|
257
|
+
localization: category_i18n;
|
|
258
|
+
on_navigation?: OnNavigation;
|
|
259
|
+
api?: DepictAPI;
|
|
260
|
+
};
|
|
261
|
+
export class DepictCategory {
|
|
262
|
+
#private;
|
|
263
|
+
get localization(): category_i18n;
|
|
264
|
+
set localization(locale_obj: category_i18n);
|
|
265
|
+
get category_id(): string;
|
|
266
|
+
set category_id(id: string);
|
|
267
|
+
get merchant(): string;
|
|
268
|
+
set merchant(merchant: string);
|
|
269
|
+
get market(): string;
|
|
270
|
+
set market(market: string);
|
|
271
|
+
get on_navigation(): OnNavigation;
|
|
272
|
+
set on_navigation(new_function: OnNavigation);
|
|
273
|
+
constructor({ api, on_navigation, ...props_on_class }: DepictCategoryConstructorOptions);
|
|
274
|
+
}
|
|
275
|
+
export function CategoryPage<T extends Display>({ depict_category, grid_spacing, cols_at_size, product_card_template, show_breadcrumbs, show_quicklinks, category_title, }: {
|
|
276
|
+
depict_category: DepictCategory;
|
|
277
|
+
grid_spacing: SDKGridSpacing;
|
|
278
|
+
cols_at_size: SDKColsAtSize;
|
|
279
|
+
product_card_template: ProductCardTemplate<T>;
|
|
280
|
+
show_quicklinks?: boolean;
|
|
281
|
+
show_breadcrumbs?: boolean;
|
|
282
|
+
category_title: typeof CategoryTitle | typeof embedded_num_products;
|
|
283
|
+
}): import("@depict-ai/utilishared").Node_Array;
|
|
284
|
+
export function BreadCrumbs({ depict_category }: {
|
|
285
|
+
depict_category: DepictCategory;
|
|
286
|
+
}): HTMLElement;
|
|
287
|
+
export function QuickLinks({ depict_category }: {
|
|
288
|
+
depict_category: DepictCategory;
|
|
289
|
+
}): HTMLElement;
|
|
290
|
+
export function get_categories(tenant: string, market: string): Promise<string[]>;
|
|
291
|
+
export function DefaultInstantCardPlaceholder(): HTMLDivElement;
|
|
292
|
+
/**
|
|
293
|
+
* Useful for aligning the search modal to an element, like an existing input field
|
|
294
|
+
* @param modal_body_style a signal containing the style properties that will be applied to the modal body. You provide it to open_modal_ as `style_props_` when using SearchModal
|
|
295
|
+
* @param input_field the element to align to.
|
|
296
|
+
* @param width_transformer A function that gets to change the width value before it is being applied
|
|
297
|
+
* @param includeScroll Should the aligner offset with scrolling? Useful to set to false when using position: fixed
|
|
298
|
+
* @param one_axies_only Usually align_field will align on top and left positioning and set the width. With one_axies_only it can be chosen to apart from setting width only align on top/left axis
|
|
299
|
+
* @returns a function that can be called any time to re-run the alignment routine in case that the elements have gone out of alignment
|
|
300
|
+
*/
|
|
301
|
+
export function align_field(modal_body_style: Signal<JSX.CSSProperties>, input_field: HTMLElement, width_transformer?: (arg0: number) => number, includeScroll?: boolean, one_axies_only?: "top" | "left"): () => void;
|
|
302
|
+
interface Styles {
|
|
303
|
+
[selector: string]: JSX.CSSProperties;
|
|
304
|
+
}
|
|
305
|
+
export const styles_to_valid_css_string: (styles: Styles) => string;
|
|
306
|
+
/** A function that renders category suggestion cards. Set to false to disable category suggestions. */
|
|
307
|
+
export type RenderCategorySuggestion = (category_suggestion: Accessor<CategorySuggestion>, index: number) => JSX.Element;
|
|
308
|
+
/**
|
|
309
|
+
* Connects the height of the search field to the height of the aligner.
|
|
310
|
+
* @param aligner
|
|
311
|
+
* @returns
|
|
312
|
+
*/
|
|
313
|
+
export function connect_search_field_height_to_aligner_height(aligner: HTMLElement): {
|
|
314
|
+
cleanup: () => void;
|
|
315
|
+
};
|
|
316
|
+
type ConstructorOptions<T extends Display> = {
|
|
317
|
+
search_query_url_param_name?: string;
|
|
318
|
+
market: string;
|
|
319
|
+
merchant: string;
|
|
320
|
+
localization: search_i18n;
|
|
321
|
+
on_navigation?: OnNavigation;
|
|
322
|
+
url_transformer?: (url_object: URL) => unknown;
|
|
323
|
+
enable_category_suggestions?: boolean;
|
|
324
|
+
disable_scrolling_during_modal?: boolean;
|
|
325
|
+
api?: DepictAPI;
|
|
326
|
+
bottom_distance_under_modal?: Accessor<number | undefined>;
|
|
327
|
+
render_instant_card?: InstantCard<T>;
|
|
328
|
+
};
|
|
329
|
+
export type OpenModalArguments = [
|
|
330
|
+
options_for_modal?: {
|
|
331
|
+
style_props_?: Signal<JSX.CSSProperties>;
|
|
332
|
+
closing_animation_?: () => Promise<any>;
|
|
333
|
+
class_list_?: Accessor<Record<string, boolean>>;
|
|
334
|
+
selected_text_range_?: readonly [number | null, number | null] | [number | null, number | null];
|
|
335
|
+
dont_sync_search_field_value_except_on_submit_?: boolean;
|
|
336
|
+
},
|
|
337
|
+
on_dispose?: VoidFunction
|
|
338
|
+
];
|
|
339
|
+
export const get_search_query_updating_blocked_signal: (depict_search: DepictSearch<any>) => Signal<boolean> | undefined;
|
|
340
|
+
export class DepictSearch<T extends Display> {
|
|
341
|
+
#private;
|
|
342
|
+
constructor({ search_query_url_param_name: search_query_url_param_name_, url_transformer, on_navigation, enable_category_suggestions, disable_scrolling_during_modal, api, bottom_distance_under_modal, render_instant_card, ...props_on_class }: ConstructorOptions<T>);
|
|
343
|
+
get on_navigation(): OnNavigation;
|
|
344
|
+
set on_navigation(new_function: OnNavigation);
|
|
345
|
+
get localization(): search_i18n;
|
|
346
|
+
set localization(locale_obj: search_i18n);
|
|
347
|
+
get modal_open(): OpenModalArguments | boolean;
|
|
348
|
+
set modal_open(new_state: OpenModalArguments | boolean);
|
|
349
|
+
get merchant(): string;
|
|
350
|
+
set merchant(tenant: string);
|
|
351
|
+
get market(): string;
|
|
352
|
+
set market(market: string);
|
|
353
|
+
fetchSearchResults(query: string, filters?: SearchFilter[], maxResults?: number): Promise<T[]>;
|
|
354
|
+
}
|
|
355
|
+
export function SearchPage<T extends Display>({ depict_search, include_input_field, grid_spacing, cols_at_size, product_card_template, extra_depict_options, }: {
|
|
356
|
+
depict_search: DepictSearch<T>;
|
|
357
|
+
include_input_field?: boolean | {
|
|
358
|
+
on_open_?: VoidFunction;
|
|
359
|
+
on_close_?: VoidFunction;
|
|
360
|
+
};
|
|
361
|
+
grid_spacing: SDKGridSpacing;
|
|
362
|
+
cols_at_size: SDKColsAtSize;
|
|
363
|
+
product_card_template: ProductCardTemplate<T>;
|
|
364
|
+
extra_depict_options?: {
|
|
365
|
+
recommendations_cols_at_size?: SDKColsAtSize;
|
|
366
|
+
};
|
|
367
|
+
}): import("@depict-ai/utilishared").Node_Array;
|
|
368
|
+
interface SearchFieldParams {
|
|
369
|
+
depict_search: DepictSearch<any>;
|
|
370
|
+
modal_dispose_handler?: VoidFunction;
|
|
371
|
+
click_handler?: (this: HTMLDivElement, ev: MouseEvent) => any;
|
|
372
|
+
aligner_ref?: HTMLElement | null;
|
|
373
|
+
}
|
|
374
|
+
export function SearchField({ depict_search, modal_dispose_handler, click_handler, aligner_ref, }: SearchFieldParams): import("@depict-ai/utilishared").Node_Array;
|
|
375
|
+
export type BaseProviderConfig = {
|
|
376
|
+
/**
|
|
377
|
+
* The merchant to use for the search.
|
|
378
|
+
* @example "YOUR_MERCHANT", "stronger"
|
|
379
|
+
*/
|
|
380
|
+
merchant: string;
|
|
381
|
+
/**
|
|
382
|
+
* The market to use for the search.
|
|
383
|
+
* @example "YOUR_MARKET", "no", "en-de"
|
|
384
|
+
*/
|
|
385
|
+
market: string;
|
|
386
|
+
/**
|
|
387
|
+
* Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
|
|
388
|
+
*/
|
|
389
|
+
userId?: string;
|
|
390
|
+
/**
|
|
391
|
+
* Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
|
|
392
|
+
*/
|
|
393
|
+
sessionId?: string;
|
|
394
|
+
/**
|
|
395
|
+
* Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
|
|
396
|
+
*/
|
|
397
|
+
metaData?: Record<string, string>;
|
|
398
|
+
};
|
|
399
|
+
export type BaseSearchProviderConfig = {
|
|
400
|
+
/**
|
|
401
|
+
* The path to the search page.
|
|
402
|
+
* @example "/search", "/sok"
|
|
403
|
+
*/
|
|
404
|
+
searchPagePath: string;
|
|
405
|
+
/**
|
|
406
|
+
* The name of the url parameter that will be used for the search query.
|
|
407
|
+
* @example "q", "search_query", "query"
|
|
408
|
+
* @default "query"
|
|
409
|
+
*/
|
|
410
|
+
urlParamName?: string;
|
|
411
|
+
/**
|
|
412
|
+
* Whether to enable category suggestions in the search modal and search page.
|
|
413
|
+
* @default false
|
|
414
|
+
*/
|
|
415
|
+
enableCategorySuggestions?: boolean;
|
|
416
|
+
};
|
|
417
|
+
export interface BaseProductListingConfig {
|
|
418
|
+
/**
|
|
419
|
+
* How many columns to show at each media size.
|
|
420
|
+
* @default
|
|
421
|
+
* [[2, 901], [3, 1024], [4]]
|
|
422
|
+
* @example
|
|
423
|
+
* [[2, 901], [3, 1024], [4]]
|
|
424
|
+
* means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.
|
|
425
|
+
*/
|
|
426
|
+
columnsAtSize?: SDKColsAtSize;
|
|
427
|
+
/**
|
|
428
|
+
* The spacing between products.
|
|
429
|
+
* @default "2%"
|
|
430
|
+
* @example
|
|
431
|
+
* "2%", "10px", "1rem", {horizontal: "1%", vertical: "5px"}
|
|
432
|
+
*/
|
|
433
|
+
gridSpacing?: SDKGridSpacing;
|
|
434
|
+
}
|
|
435
|
+
export interface BaseSearchPageConfig extends BaseProductListingConfig {
|
|
436
|
+
/**
|
|
437
|
+
* Whether to show the search input field in the search page.
|
|
438
|
+
* @default true
|
|
439
|
+
*/
|
|
440
|
+
includeInputField?: boolean;
|
|
441
|
+
}
|
|
442
|
+
export interface BaseCategoryPageConfig extends BaseProductListingConfig {
|
|
443
|
+
/**
|
|
444
|
+
* Whether to show the breadcrumbs in the category page.
|
|
445
|
+
* @default true
|
|
446
|
+
*/
|
|
447
|
+
showBreadcrumbs?: boolean;
|
|
448
|
+
/**
|
|
449
|
+
* Whether to show the quicklinks in the category page.
|
|
450
|
+
* @default true
|
|
451
|
+
*/
|
|
452
|
+
showQuicklinks?: boolean;
|
|
453
|
+
}
|
|
454
|
+
/**
|
|
455
|
+
* Props for the TextPlaceholder component.
|
|
456
|
+
*/
|
|
457
|
+
export interface TextPlaceholderProps {
|
|
458
|
+
/**
|
|
459
|
+
* The height of the text, including a unit.
|
|
460
|
+
* @example "1em"
|
|
461
|
+
*/
|
|
462
|
+
height: string;
|
|
463
|
+
/**
|
|
464
|
+
* The width of the text.
|
|
465
|
+
* @example "60px", "10em"
|
|
466
|
+
*/
|
|
467
|
+
width: string;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Props for the ImagePlaceholder component.
|
|
471
|
+
*/
|
|
472
|
+
export interface ImagePlaceholderProps {
|
|
473
|
+
/** The aspect ratio of the image that will be displayed. */
|
|
474
|
+
aspectRatio: number;
|
|
475
|
+
}
|
|
476
|
+
type CenteredLocation = {
|
|
477
|
+
location?: "centered";
|
|
478
|
+
};
|
|
479
|
+
type AlignedLocation = {
|
|
480
|
+
location: "aligned";
|
|
481
|
+
element: HTMLElement;
|
|
482
|
+
};
|
|
483
|
+
/**
|
|
484
|
+
* How the modal should be opened.
|
|
485
|
+
*/
|
|
486
|
+
type ModalLocation = AlignedLocation | CenteredLocation;
|
|
487
|
+
type OpenModalParams<T extends Display> = ModalLocation & {
|
|
488
|
+
search: DepictSearch<T>;
|
|
489
|
+
/**
|
|
490
|
+
* If true, the search field in the modal opened will be empty and de-coupled from the other SearchFields.
|
|
491
|
+
*/
|
|
492
|
+
makesNewSearch?: boolean;
|
|
493
|
+
};
|
|
494
|
+
/**
|
|
495
|
+
* Open the modal with support for alignment.
|
|
496
|
+
* @returns {void}
|
|
497
|
+
*/
|
|
498
|
+
export const open_modal_with_alignment: <T extends Display>(openModalParams: OpenModalParams<T>) => void;
|
|
499
|
+
export function open_search_with_shift_slash(open_search: VoidFunction): () => void;
|
|
500
|
+
export interface PageReplacer {
|
|
501
|
+
readonly render_: () => Node_Array;
|
|
502
|
+
readonly is_page_: (url: URL) => boolean;
|
|
503
|
+
readonly title_?: string;
|
|
504
|
+
readonly selector_: string;
|
|
505
|
+
readonly append_instead_of_replace_?: boolean;
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* PageReplacer is a class that can be used to layer an SPA (single page application) on top of a non-SPA, for certain pages.
|
|
509
|
+
* An example use case is that we want to make it absolutely instant to go to a search page or to go from one search query to the next (so basically one can navigate to pages without reloading the page).
|
|
510
|
+
* PageReplacer works by, when something has changed the URL (using history.pushState) to the page where it should take effect, replacing a specified element with another element.
|
|
511
|
+
* The element that is replaced is specified by a CSS selector and usually represents the element containing "main content" of the page. The "replacement" works by setting `display: none` on the original page and then adding the "new page"-element after it in the DOM:
|
|
512
|
+
* @param render_ A function that returns the elements which replace the "page" when is_page_ returns true.
|
|
513
|
+
* @param title_ The title that document.title should be changed to when is_page_ returns true (the replacement page is open).
|
|
514
|
+
* @param is_page_ A function that returns true if the provided URL is the page where the replacement should take effect.
|
|
515
|
+
* @param selector_ A CSS selector that selects the element that should be replaced.
|
|
516
|
+
* @param append_instead_of_replace_ If true, the replacement element will be appended to the element that is found by selector_ instead of replacing it. This is useful if one doesn't actually want it to replace the element because one has other logic.
|
|
517
|
+
*/
|
|
518
|
+
export class PageReplacer extends EventTarget {
|
|
519
|
+
#private;
|
|
520
|
+
/**
|
|
521
|
+
* Returns if the "replacement page" is currently open
|
|
522
|
+
*/
|
|
523
|
+
get open_(): boolean;
|
|
524
|
+
/**
|
|
525
|
+
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
526
|
+
*/
|
|
527
|
+
destroy_(): void;
|
|
528
|
+
constructor({ is_spa_, ...options }: Omit<PageReplacer, "destroy_" | "addEventListener" | "removeEventListener" | "dispatchEvent" | "open_"> & {
|
|
529
|
+
is_spa_?: boolean;
|
|
530
|
+
});
|
|
531
|
+
}
|
|
532
|
+
/**
|
|
533
|
+
* makes so that links to the previous page close the search instead of closing the search and reloading the page (to be used with non-spas)
|
|
534
|
+
*/
|
|
535
|
+
export function setup_fast_leave(pr: PageReplacer): void;
|
|
536
|
+
export const defaultColsAtSize: SDKColsAtSize;
|
|
537
|
+
export const defaultGridSpacing = "2%";
|
|
538
|
+
export const defaultCategoryTitlePlugin: ({ category_title_, product_count_, }: {
|
|
539
|
+
category_title_: import("solid-js").Accessor<string | undefined>;
|
|
540
|
+
product_count_: import("solid-js").JSX.Element;
|
|
541
|
+
}) => HTMLElement;
|
|
542
|
+
export type { SearchFilter } from "@depict-ai/types/api/SearchRequest";
|