@depict-ai/ui 1.4.3 → 1.4.4
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/ES10/index.cjs +10286 -0
- package/{dist → ES10}/index.d.ts +501 -460
- package/ES10/index.js +10235 -0
- package/latest/index.cjs +9482 -0
- package/latest/index.d.ts +844 -0
- package/latest/index.js +9434 -0
- package/locales/ES10/index.cjs +867 -0
- package/locales/ES10/index.d.ts +89 -0
- package/locales/ES10/index.js +846 -0
- package/locales/index.cjs +1 -0
- package/locales/index.js +1 -1150
- package/locales/latest/index.cjs +867 -0
- package/locales/latest/index.d.ts +89 -0
- package/locales/latest/index.js +846 -0
- package/multi_import_deduplicator.cjs +31 -0
- package/multi_import_deduplicator.mjs +31 -0
- package/package.json +155 -41
- package/server/ES10/index.cjs +8462 -0
- package/server/ES10/index.d.ts +844 -0
- package/server/ES10/index.js +8411 -0
- package/server/latest/index.cjs +7715 -0
- package/server/latest/index.d.ts +844 -0
- package/server/latest/index.js +7667 -0
- package/dist/client/main.cjs +0 -9060
- package/dist/client/module.js +0 -9014
- package/dist/server/main.cjs +0 -8206
- package/dist/server/module.js +0 -8160
- package/locales/index.d.ts +0 -90
- package/locales/require.cjs +0 -1167
|
@@ -0,0 +1,844 @@
|
|
|
1
|
+
import { JSX, Signal, Accessor, Setter } from "solid-js";
|
|
2
|
+
import { Elem, Display, ColsAtSize, ModernDisplay, Node_Array } from "@depict-ai/utilishared/ES10";
|
|
3
|
+
import { SearchFilter, SearchRequest } from "@depict-ai/types/api/SearchRequest";
|
|
4
|
+
import { SearchFilter as _SearchFilter1, SearchResponse } from "@depict-ai/types/api/SearchResponse";
|
|
5
|
+
import { BaseCategoryDisplay, ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
|
|
6
|
+
import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/api/SearchSuggestionsResponse";
|
|
7
|
+
import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
|
|
8
|
+
import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
|
|
9
|
+
import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
|
|
10
|
+
export const version = "1.4.4";
|
|
11
|
+
export function ExpandingDetails(props: {
|
|
12
|
+
details_: HTMLDetailsElement;
|
|
13
|
+
summary_: HTMLElement;
|
|
14
|
+
children: JSX.Element | (() => JSX.Element);
|
|
15
|
+
is_open_: Signal<boolean>;
|
|
16
|
+
duration_?: number;
|
|
17
|
+
delay_?: number;
|
|
18
|
+
dont_animate_if_instant_open_?: boolean;
|
|
19
|
+
}): HTMLDetailsElement;
|
|
20
|
+
export function accessor_of_object_to_object_with_accessor_values<O extends Record<string | symbol, any>>(obj: Accessor<O>): { [K in keyof O]: Accessor<O[K]> };
|
|
21
|
+
/**
|
|
22
|
+
* Like standard_price_format except that the price and the formatting are reactive accessors
|
|
23
|
+
*/
|
|
24
|
+
export function SolidFormatPrice(props: {
|
|
25
|
+
price_: number;
|
|
26
|
+
price_formatting_: {
|
|
27
|
+
pre_: string;
|
|
28
|
+
post_: string;
|
|
29
|
+
decimal_places_delimiter_: string;
|
|
30
|
+
thousands_delimiter_: string;
|
|
31
|
+
places_after_comma_: number | "auto";
|
|
32
|
+
};
|
|
33
|
+
}): JSX.Element;
|
|
34
|
+
/**
|
|
35
|
+
* PLP internationalisation shared between search and category listing
|
|
36
|
+
*/
|
|
37
|
+
type plp_shared_i18n = {
|
|
38
|
+
scroll_to_top_: string;
|
|
39
|
+
back_: string;
|
|
40
|
+
open_sorting_: string;
|
|
41
|
+
close_sorting_: string;
|
|
42
|
+
open_filters_: string;
|
|
43
|
+
close_filters_: string;
|
|
44
|
+
close_: string;
|
|
45
|
+
ok_: string;
|
|
46
|
+
filters_cleared_: string;
|
|
47
|
+
we_cleared_your_filters_: string;
|
|
48
|
+
restore_: string;
|
|
49
|
+
sorting_text_: string;
|
|
50
|
+
filter_text_: string;
|
|
51
|
+
selected_filters_title_: string;
|
|
52
|
+
filters_: string;
|
|
53
|
+
view_less_: string;
|
|
54
|
+
view_more_: string;
|
|
55
|
+
clear_all_from_filter_crumbs_: string;
|
|
56
|
+
clear_individual_filter_: string;
|
|
57
|
+
of_: string;
|
|
58
|
+
clear_all_filters_from_big_button_: string;
|
|
59
|
+
try_without_filters_: string;
|
|
60
|
+
range_filter_low_point_aria_label_: string;
|
|
61
|
+
range_filter_high_point_aria_label_: string;
|
|
62
|
+
morphing_sign_expanded_aria_label_: string;
|
|
63
|
+
morphing_sign_collapsed_aria_label_: string;
|
|
64
|
+
price_formatting_: {
|
|
65
|
+
pre_: string;
|
|
66
|
+
post_: string;
|
|
67
|
+
decimal_places_delimiter_: string;
|
|
68
|
+
thousands_delimiter_: string;
|
|
69
|
+
places_after_comma_: number | "auto";
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Search internationalisation
|
|
74
|
+
*/
|
|
75
|
+
interface search_i18n extends plp_shared_i18n {
|
|
76
|
+
placeholder_text_: string;
|
|
77
|
+
show_n_results_: (number_of_results: HTMLElement) => Elem[];
|
|
78
|
+
no_results_text_: string;
|
|
79
|
+
search_recs_title_: string;
|
|
80
|
+
clear_filters_query_sorting_after_submit_: string;
|
|
81
|
+
modal_view_all_results_: (number_of_results: HTMLElement) => Elem[];
|
|
82
|
+
modal_discover_more_: string;
|
|
83
|
+
get_showing_results_for_: (query: HTMLElement, number_of_results: HTMLElement) => Elem[];
|
|
84
|
+
previous_searches_text_: string;
|
|
85
|
+
category_: string;
|
|
86
|
+
brand_: string;
|
|
87
|
+
suggestions_: string;
|
|
88
|
+
search_submit_button_aria_label_: string;
|
|
89
|
+
search_field_field_aria_label_: string;
|
|
90
|
+
previous_searches_delete_entry_from_history_: string;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Category internationalisation
|
|
94
|
+
*/
|
|
95
|
+
interface category_i18n extends plp_shared_i18n {
|
|
96
|
+
show_n_products_: (number_of_results: HTMLElement) => Elem[];
|
|
97
|
+
no_products_text_: string;
|
|
98
|
+
product_: string;
|
|
99
|
+
products_: string;
|
|
100
|
+
breadcrumbs_aria_label_: string;
|
|
101
|
+
quicklinks_aria_label_: string;
|
|
102
|
+
breadcrumbs_separator_: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* For anything that is not exposed and only used internally we can use solid signals to get more performant rendering.
|
|
106
|
+
* For anything that can be used outside of solid, like Product Cards and InstantCards these types should not be used.
|
|
107
|
+
*
|
|
108
|
+
* Any solid_ type below should not be exposed outside of this library, as the accessors can be confusing and unnecessary.
|
|
109
|
+
*/
|
|
110
|
+
/** For internal components using i18n that gets wrapped in solid's Accessors */
|
|
111
|
+
type solid_plp_shared_i18n = { [K in keyof plp_shared_i18n]: Accessor<plp_shared_i18n[K]> };
|
|
112
|
+
/** @jsxImportSource solid-js */
|
|
113
|
+
export function GenericSliderArrowButton(props?: {
|
|
114
|
+
width_?: number;
|
|
115
|
+
height_?: number;
|
|
116
|
+
}): SVGElement;
|
|
117
|
+
export function show_toast({
|
|
118
|
+
children,
|
|
119
|
+
on_close_,
|
|
120
|
+
close_after_,
|
|
121
|
+
...more_attributes
|
|
122
|
+
}: {
|
|
123
|
+
children?: JSX.Element;
|
|
124
|
+
close_after_: number;
|
|
125
|
+
on_close_?: VoidFunction;
|
|
126
|
+
} & JSX.HTMLAttributes<HTMLDivElement>): {
|
|
127
|
+
close_toast_: VoidFunction;
|
|
128
|
+
};
|
|
129
|
+
export type SDKGridSpacing = string | {
|
|
130
|
+
horizontal: string;
|
|
131
|
+
vertical: string;
|
|
132
|
+
};
|
|
133
|
+
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
134
|
+
type FilterWithData = WithRequired<SearchFilter, "data">;
|
|
135
|
+
export interface SDKRenderingInfo {
|
|
136
|
+
set_on_index_change: (fn: (index: number) => void) => void;
|
|
137
|
+
merchant: string;
|
|
138
|
+
market: string;
|
|
139
|
+
}
|
|
140
|
+
export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
|
|
141
|
+
/**
|
|
142
|
+
* Will be sent to backend to indicate whether the query_id_ is for a collection or category.
|
|
143
|
+
* Backend defaults to category if not specified.
|
|
144
|
+
*/
|
|
145
|
+
export type ListingType = "collection" | "category";
|
|
146
|
+
type AddActualFieldToArray<T> = T extends Array<infer U> ? (U & {
|
|
147
|
+
actual_field?: string;
|
|
148
|
+
})[] : never;
|
|
149
|
+
type AddActualFieldToFilters<T extends SearchFilter[] | undefined> = T extends undefined ? undefined : AddActualFieldToArray<T>;
|
|
150
|
+
export function CrossIcon(props?: JSX.SvgSVGAttributes<SVGSVGElement>): SVGElement;
|
|
151
|
+
export function SelectedFilters({
|
|
152
|
+
number_of_rendered_selected_filters_items_,
|
|
153
|
+
i18n_,
|
|
154
|
+
selected_filters_,
|
|
155
|
+
local_filter_cache_: [read_local_filter_cache],
|
|
156
|
+
get_search_filters_open_,
|
|
157
|
+
get_search_sorting_open_,
|
|
158
|
+
local_filter_cache_,
|
|
159
|
+
expanded_hierarchical_filters_
|
|
160
|
+
}: {
|
|
161
|
+
get_search_filters_open_: Accessor<boolean>;
|
|
162
|
+
get_search_sorting_open_: Accessor<boolean>;
|
|
163
|
+
expanded_hierarchical_filters_: Signal<{
|
|
164
|
+
value_: string[];
|
|
165
|
+
expanded_: boolean;
|
|
166
|
+
}[]>;
|
|
167
|
+
number_of_rendered_selected_filters_items_: Signal<number>;
|
|
168
|
+
i18n_: solid_plp_shared_i18n;
|
|
169
|
+
selected_filters_: Signal<FilterWithData[]>;
|
|
170
|
+
local_filter_cache_: Signal<SearchFilter[]>;
|
|
171
|
+
}): HTMLDivElement;
|
|
172
|
+
/**
|
|
173
|
+
* Use `javascript_media_query` but return a reactive accessor instead of taking a callback function
|
|
174
|
+
*/
|
|
175
|
+
export function media_query_to_accessor(media_query: string): import("solid-js").Accessor<boolean>;
|
|
176
|
+
declare class SDKError extends Error {}
|
|
177
|
+
export class ProductCardError extends SDKError {
|
|
178
|
+
constructor(templateError: Error);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Base placeholder component used by ImagePlaceholder and TextPlaceholder
|
|
182
|
+
*/
|
|
183
|
+
export function BasePlaceholder(props: {
|
|
184
|
+
style: JSX.CSSProperties;
|
|
185
|
+
class?: string;
|
|
186
|
+
}): JSX.Element;
|
|
187
|
+
/**
|
|
188
|
+
* A Placeholder to use instead of some text, while it's loading. This is the inline version, meant to be embedded into sentences (or exist instead of them), etc.
|
|
189
|
+
* If you want a block version, use `ImagePlaceholder` with `width`and `height` set instead.
|
|
190
|
+
* @property height height of the placeholder. Set to `1em` by default.
|
|
191
|
+
* @property width width of the placeholder. For specific number of characters use `ch`, ex: `width="7ch"`
|
|
192
|
+
* @property class extra classes to add to the placeholder
|
|
193
|
+
* @property style extra styles to add to the placeholder
|
|
194
|
+
*/
|
|
195
|
+
export function TextPlaceholder(props: {
|
|
196
|
+
style?: JSX.CSSProperties;
|
|
197
|
+
height: string;
|
|
198
|
+
width: string;
|
|
199
|
+
class?: string;
|
|
200
|
+
}): JSX.Element;
|
|
201
|
+
interface FilterBodyProps {
|
|
202
|
+
available_filters_: Accessor<_SearchFilter1[] | undefined>;
|
|
203
|
+
expanded_filters_: Signal<{
|
|
204
|
+
section_: string;
|
|
205
|
+
expanded_: boolean;
|
|
206
|
+
}[]>;
|
|
207
|
+
selected_filters_: Signal<{
|
|
208
|
+
field: string;
|
|
209
|
+
op: _SearchFilter1["op"];
|
|
210
|
+
data: any;
|
|
211
|
+
}[]>;
|
|
212
|
+
local_filter_cache_: Signal<_SearchFilter1[]>;
|
|
213
|
+
i18n_: solid_plp_shared_i18n;
|
|
214
|
+
expanded_hierarchical_filters_: Signal<{
|
|
215
|
+
value_: string[];
|
|
216
|
+
expanded_: boolean;
|
|
217
|
+
}[]>;
|
|
218
|
+
are_in_modal_?: boolean;
|
|
219
|
+
}
|
|
220
|
+
export function FilterBody(props: FilterBodyProps): JSX.Element;
|
|
221
|
+
export function create_modified_filters({
|
|
222
|
+
available_filters_,
|
|
223
|
+
local_filter_cache_: [read_local_cache, write_local_cache],
|
|
224
|
+
selected_filters_: [read_selected_filters]
|
|
225
|
+
}: {
|
|
226
|
+
available_filters_: Accessor<_SearchFilter1[] | undefined>;
|
|
227
|
+
selected_filters_: Signal<{
|
|
228
|
+
field: string;
|
|
229
|
+
op: _SearchFilter1["op"];
|
|
230
|
+
data: any;
|
|
231
|
+
}[]>;
|
|
232
|
+
local_filter_cache_: Signal<_SearchFilter1[]>;
|
|
233
|
+
}): void;
|
|
234
|
+
export type SolidLayoutOptions = {
|
|
235
|
+
cols_at_size: ColsAtSize;
|
|
236
|
+
grid_spacing: string;
|
|
237
|
+
rows: {
|
|
238
|
+
start_rows?: number;
|
|
239
|
+
rows_per_click?: number;
|
|
240
|
+
currently_visible?: Signal<number>;
|
|
241
|
+
max_rows?: number;
|
|
242
|
+
button?: JSX.Element;
|
|
243
|
+
} | "all";
|
|
244
|
+
layout: "slider" | "grid";
|
|
245
|
+
disable_partial_rows?: boolean;
|
|
246
|
+
override_vertical_spacing?: string;
|
|
247
|
+
children: JSX.Element;
|
|
248
|
+
element_attributes: JSX.HTMLAttributes<HTMLDivElement>;
|
|
249
|
+
};
|
|
250
|
+
/**
|
|
251
|
+
* Grid: Calculates CSS for a grid with a certain spacing and certain number of columns at certain screen sizes, including a view more button. All properties are reactive.
|
|
252
|
+
* @property rows if set to 'all': Just generate grid styling without any viewing/hiding functionality. If an object: start_rows is the number of rows at the beginning. rows_per_click is the amount of rows to view on each view more button click. button is the view more button to display. currently_visible is a signal that you can use to get and set the number of currently viewed rows
|
|
253
|
+
* @property cols_at_size An array with sub arrays looking like this: `[n_cols, min_width_media_query, max_width_media_query, grid_spacing_for_size]`, everything after `[n_cols, min_width]` is optional. falsey value for `min_width = no min_width`
|
|
254
|
+
* @property grid_spacing spacing to use if none is specified for the specific size in `cols_at_size`
|
|
255
|
+
* @property disable_partial_rows If set to `true`, will not let user press "show more" if next row is a partial row. Example of partial row: `cols_at_size` says we should have 4 recs in the next row, but we only have 2 left, so the row just gets 2 instead of 4, meaning it doesn't "fill out".
|
|
256
|
+
* @property override_vertical_spacing by default, the grid_spacing is used both horizontally and vertically, with this you can specify a separate spacing
|
|
257
|
+
* @return An accessor containing a CSS string
|
|
258
|
+
*/
|
|
259
|
+
export function SolidLayout(props: SolidLayoutOptions): JSX.Element;
|
|
260
|
+
type PageURLCreatorAlwaysThereData = {
|
|
261
|
+
merchant: string;
|
|
262
|
+
market: string;
|
|
263
|
+
};
|
|
264
|
+
type PageURLCreatorCategoryData = {
|
|
265
|
+
type: "categories";
|
|
266
|
+
data: (BaseCategoryDisplay | CategorySuggestion)[];
|
|
267
|
+
};
|
|
268
|
+
type PageURLCreatorProductData<T extends ModernDisplay> = {
|
|
269
|
+
displays: T[];
|
|
270
|
+
type: "products";
|
|
271
|
+
};
|
|
272
|
+
type CanBePromiseWrapped<T> = T | Promise<T>;
|
|
273
|
+
export type ModernDisplayWithPageUrl<T extends ModernDisplay> = { [K in keyof T]: K extends "variant_displays" ? (T[K][number] & {
|
|
274
|
+
page_url: string;
|
|
275
|
+
})[] : T[K] };
|
|
276
|
+
type PageURLCreatorOptions<InputDisplay extends ModernDisplay> = PageURLCreatorAlwaysThereData & (PageURLCreatorCategoryData | PageURLCreatorProductData<InputDisplay>);
|
|
277
|
+
/**
|
|
278
|
+
* PageUrlCreator is, in its most basic form, a function that takes in a list of categories or products and returns a list of page_urls for the provided categories or products.
|
|
279
|
+
* It's main use case is to allow for the creation of links to the product or category pages on the merchant's site.
|
|
280
|
+
* It can also be used for the depict customers which already have links to change those links (i.e. for staging sites).
|
|
281
|
+
* Also, it can be used to enrich the data for each product card in a batched way, which is why it can be an async function and return a whole display in the case of products.
|
|
282
|
+
*/
|
|
283
|
+
export type PageURLCreator<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = (options: PageURLCreatorOptions<InputDisplay>) => (typeof options)["type"] extends "categories" ? CanBePromiseWrapped<{
|
|
284
|
+
page_url: string;
|
|
285
|
+
}[]> : CanBePromiseWrapped<{
|
|
286
|
+
page_url: string;
|
|
287
|
+
}[]> | CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
|
|
288
|
+
export type SomethingTakingAPageURLCreator<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
289
|
+
page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
|
|
290
|
+
} : {
|
|
291
|
+
page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
|
|
292
|
+
} : {
|
|
293
|
+
page_url_creator?: never;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* Basically allows you to use SearchModal
|
|
297
|
+
* So the idea is to have a modal. It should either be rendered and exist, in which case it is in the foreground and open, or it's completely gone. This makes things easier.
|
|
298
|
+
* @param search_modal a function which returns an array of nodes that get appended into <body>. This function will run in its own solid-js root which will call onCleanup and cleanup all reactive things inside it when the modal is closed. This function will get the arguments passed to open_modal_ and the modal_fn_opts merged together, along with register_closing_animation_ where an async function that resolves once the animation is finished can be provided to animate the closing of the modal
|
|
299
|
+
* @param modal_fn_opts static options for the modal that won't change on a per-opening basis
|
|
300
|
+
@returns a function to open and close the modal. When calling the open_modal_ function additional parameters can be passed to the modal
|
|
301
|
+
*/
|
|
302
|
+
export function general_modal_abstraction<StaticOptions extends {
|
|
303
|
+
[key: string]: any;
|
|
304
|
+
}, ExtraOptionsProvidedOnOpen extends {
|
|
305
|
+
[key: string]: any;
|
|
306
|
+
}>(search_modal: (options: StaticOptions & ExtraOptionsProvidedOnOpen & {
|
|
307
|
+
close_modal_: VoidFunction;
|
|
308
|
+
open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
|
|
309
|
+
register_closing_animation_: (animation: () => Promise<any>) => void;
|
|
310
|
+
}) => Node_Array, modal_fn_opts: StaticOptions): Promise<{
|
|
311
|
+
open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
|
|
312
|
+
close_modal_: () => void;
|
|
313
|
+
}>;
|
|
314
|
+
export type OnNavigation = ((options: {
|
|
315
|
+
is_replace: boolean;
|
|
316
|
+
new_url: URL;
|
|
317
|
+
scroll: boolean;
|
|
318
|
+
}) => void) | "hard_navigation";
|
|
319
|
+
export type ExclusiveId = {
|
|
320
|
+
categoryId: string;
|
|
321
|
+
productId?: undefined;
|
|
322
|
+
productIds?: undefined;
|
|
323
|
+
} | {
|
|
324
|
+
categoryId?: undefined;
|
|
325
|
+
productId: string;
|
|
326
|
+
productIds?: undefined;
|
|
327
|
+
} | {
|
|
328
|
+
categoryId?: undefined;
|
|
329
|
+
productId?: undefined;
|
|
330
|
+
productIds: string[];
|
|
331
|
+
} | {
|
|
332
|
+
categoryId?: undefined;
|
|
333
|
+
productId?: undefined;
|
|
334
|
+
productIds?: undefined;
|
|
335
|
+
};
|
|
336
|
+
type RecsAPIWrapperOptions = {
|
|
337
|
+
type: string;
|
|
338
|
+
merchant: string;
|
|
339
|
+
market: string;
|
|
340
|
+
userId?: string;
|
|
341
|
+
sessionId?: string;
|
|
342
|
+
headers?: HeadersInit;
|
|
343
|
+
} & ExclusiveId;
|
|
344
|
+
/**
|
|
345
|
+
* Fetches recommendations from Depict's API.
|
|
346
|
+
* ## It is important that you make the correct choice out of: no id, `categoryId`, `productId` and `productIds` (choose ONE) so read the documentation carefully.
|
|
347
|
+
*
|
|
348
|
+
* @param merchant The name of the merchant (e.g. "acme")
|
|
349
|
+
* @param market The market to fetch recs for. Depict will provide this to you. (Example: "sv" or "sv-se".)
|
|
350
|
+
* @param type The type of the recommendations, e.g. `front_page`, `after_basket, `related`, etc. Ask Depict for this.
|
|
351
|
+
* @param categoryId When requesting recommendations for a category page, pass the id of the category page as `categoryId`.
|
|
352
|
+
* @param productId When requesting recommendations for a single product, e.g. on a product detail page, pass the id of the product as `productId`.
|
|
353
|
+
* @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`
|
|
354
|
+
* @param userId Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
|
|
355
|
+
* @param sessionId Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
|
|
356
|
+
* @param headers Optional headers to send to the Depict API. This could be authentication for example. 99% of integrations can leave this unset.
|
|
357
|
+
* 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.
|
|
358
|
+
*
|
|
359
|
+
* @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.
|
|
360
|
+
*
|
|
361
|
+
* @example Fetching frontpage recommendations
|
|
362
|
+
* ```
|
|
363
|
+
* const front_page_recs = await fetchDepictRecommendations({
|
|
364
|
+
* merchant: "oscarjacobson",
|
|
365
|
+
* market: "sv-se",
|
|
366
|
+
* type: "front_page",
|
|
367
|
+
* });
|
|
368
|
+
* ```
|
|
369
|
+
* @example Fetching recommendations for a product page
|
|
370
|
+
* ```
|
|
371
|
+
* const product_page_recs = await fetchDepictRecommendations({
|
|
372
|
+
* merchant: "stronger",
|
|
373
|
+
* market: "se",
|
|
374
|
+
* type: "product_normal",
|
|
375
|
+
* productId: "hero-sports-bra-luna",
|
|
376
|
+
* });
|
|
377
|
+
* ```
|
|
378
|
+
* @return This function is guaranteed to return an array of Displays. If anything fails, you will get an empty array.
|
|
379
|
+
*/
|
|
380
|
+
export function fetchDepictRecommendations<T extends Display = Display>({
|
|
381
|
+
merchant,
|
|
382
|
+
market,
|
|
383
|
+
headers,
|
|
384
|
+
...fetch_recs_options
|
|
385
|
+
}: RecsAPIWrapperOptions): Promise<T[]>;
|
|
386
|
+
export type InstantCard<T extends Display> = (display: T, context: {
|
|
387
|
+
index: number;
|
|
388
|
+
i18n: search_i18n;
|
|
389
|
+
merchant: string;
|
|
390
|
+
market: string;
|
|
391
|
+
}) => JSX.Element;
|
|
392
|
+
type CategorySuggestionAfterURLCreator = CategorySuggestion & {
|
|
393
|
+
page_url: string;
|
|
394
|
+
};
|
|
395
|
+
type ReplaceCategorySuggestion<T> = T extends CategorySuggestion ? CategorySuggestionAfterURLCreator : T extends CategorySuggestion[] ? CategorySuggestionAfterURLCreator[] : T;
|
|
396
|
+
type SearchSuggestionsResponseAfterURLCreator = { [K in keyof SearchSuggestionsResponse]: ReplaceCategorySuggestion<SearchSuggestionsResponse[K]> };
|
|
397
|
+
type AddPageUrlToDisplay<T extends any[]> = (T[number] & {
|
|
398
|
+
page_url: string;
|
|
399
|
+
})[];
|
|
400
|
+
type SearchResponseAfterURLCreator = { [K in keyof SearchResponse]: K extends "displays" ? AddPageUrlToDisplay<SearchResponse[K]> : K extends "filters" ? AddActualFieldToFilters<SearchResponse[K]> : SearchResponse[K] };
|
|
401
|
+
type BaseCategoryDisplayAfterURLCreator = BaseCategoryDisplay & {
|
|
402
|
+
page_url: string;
|
|
403
|
+
};
|
|
404
|
+
type ReplaceBaseCategoryDisplay<T> = T extends BaseCategoryDisplay ? BaseCategoryDisplayAfterURLCreator : T extends BaseCategoryDisplay[] ? BaseCategoryDisplayAfterURLCreator[] : T;
|
|
405
|
+
type _AddPageUrlToDisplay1<T extends any[]> = (T[number] & {
|
|
406
|
+
page_url: string;
|
|
407
|
+
})[];
|
|
408
|
+
type ProductListingResponseAfterURLCreator = { [K in keyof ProductListingResponse]: K extends "displays" ? _AddPageUrlToDisplay1<ProductListingResponse[K]> : K extends "breadcrumb" | "quick_links" ? ReplaceBaseCategoryDisplay<ProductListingResponse[K]> : K extends "filters" ? AddActualFieldToFilters<ProductListingResponse[K]> : ProductListingResponse[K] };
|
|
409
|
+
type DepictAPIConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = {
|
|
410
|
+
get_metadata?: () => Promise<{
|
|
411
|
+
[k: string]: string;
|
|
412
|
+
} | undefined>;
|
|
413
|
+
get_user_id?: () => string | undefined;
|
|
414
|
+
get_session_id?: () => string | undefined;
|
|
415
|
+
} & SomethingTakingAPageURLCreator<InputDisplay, OutputDisplay>;
|
|
416
|
+
/**
|
|
417
|
+
* Class that handles all communication done in PLP code with the Depict API. (Notably not for recommendations currently).
|
|
418
|
+
* It handles caching, retries and errors and is the only place that should be making requests to the Depict API.
|
|
419
|
+
*/
|
|
420
|
+
export class DepictAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
|
|
421
|
+
#private;
|
|
422
|
+
page_url_creator: PageURLCreator<ModernDisplay, OutputDisplay> | undefined;
|
|
423
|
+
constructor(options: DepictAPIConstructorOptions<InputDisplay, OutputDisplay>);
|
|
424
|
+
suggest(input_req: SearchSuggestionsRequest): Promise<SearchSuggestionsResponseAfterURLCreator & {
|
|
425
|
+
failed?: true;
|
|
426
|
+
}>;
|
|
427
|
+
query(input_req: SearchRequest): Promise<SearchResponseAfterURLCreator & {
|
|
428
|
+
failed?: true;
|
|
429
|
+
}>;
|
|
430
|
+
list(input_req: ProductListingRequest): Promise<ProductListingResponseAfterURLCreator & {
|
|
431
|
+
failed?: true;
|
|
432
|
+
}>;
|
|
433
|
+
get_recommended<T extends Display>(input_req: BaseSearchRequest): Promise<{
|
|
434
|
+
displays: T[];
|
|
435
|
+
} & {
|
|
436
|
+
failed?: true | undefined;
|
|
437
|
+
}>;
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* Disables scrolling until the solidjs reactive scoped is disposed (onCleanup)
|
|
441
|
+
* @returns A cleanup function to manually re-enable scrolling.
|
|
442
|
+
*/
|
|
443
|
+
export function disable_scrolling(): () => void;
|
|
444
|
+
export const CategoryTitle: ({
|
|
445
|
+
category_title_,
|
|
446
|
+
product_count_
|
|
447
|
+
}: {
|
|
448
|
+
category_title_: Accessor<string | undefined>;
|
|
449
|
+
product_count_: JSX.Element;
|
|
450
|
+
}) => JSX.Element;
|
|
451
|
+
/**
|
|
452
|
+
* 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.
|
|
453
|
+
* 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
|
|
454
|
+
* If you see “ResizeObserver loop limit exceeded”, this is probably doing it. More context here: https://depictaiworkspace.slack.com/archives/C02KVDZ8YHZ/p1667315647758829
|
|
455
|
+
*/
|
|
456
|
+
export const embedded_num_products: ({
|
|
457
|
+
make_product_count_,
|
|
458
|
+
set_observed_results_filters_elements_,
|
|
459
|
+
is_slim_,
|
|
460
|
+
sort_and_filter_element_,
|
|
461
|
+
extra_sort_and_filter_args_
|
|
462
|
+
}: {
|
|
463
|
+
make_product_count_: () => JSX.Element;
|
|
464
|
+
set_observed_results_filters_elements_: Setter<JSX.Element>;
|
|
465
|
+
sort_and_filter_element_: Accessor<HTMLDivElement | undefined>;
|
|
466
|
+
is_slim_: Accessor<boolean>;
|
|
467
|
+
extra_sort_and_filter_args_: {
|
|
468
|
+
get_extra_sorting_button_?: ((extra_button: JSX.Element) => unknown) | undefined;
|
|
469
|
+
get_extra_filters_button_?: ((extra_button: JSX.Element) => unknown) | undefined;
|
|
470
|
+
sort_button_width_?: Accessor<number | undefined> | undefined;
|
|
471
|
+
filter_button_width_?: Accessor<number | undefined> | undefined;
|
|
472
|
+
};
|
|
473
|
+
}) => {
|
|
474
|
+
only_show_filters_opener_: Accessor<boolean>;
|
|
475
|
+
middle_elements_: Accessor<JSX.Element>;
|
|
476
|
+
on_filters_constructed_: () => void;
|
|
477
|
+
};
|
|
478
|
+
export type SDKColsAtSize = [number, number?][];
|
|
479
|
+
/**
|
|
480
|
+
* Transform SDK ColsAtSize into valid Layout ColsAtSize
|
|
481
|
+
* @param cols_at_size [nbCol, maxWidth]
|
|
482
|
+
* @returns
|
|
483
|
+
*/
|
|
484
|
+
export const convert_sdk_cols_at_size_to_layout: (cols_at_size: SDKColsAtSize) => ColsAtSize;
|
|
485
|
+
type GeneralCategoryListingOptions = {
|
|
486
|
+
market: string;
|
|
487
|
+
merchant: string;
|
|
488
|
+
localization: category_i18n;
|
|
489
|
+
unique_instance_key_for_state?: string;
|
|
490
|
+
on_navigation?: OnNavigation;
|
|
491
|
+
query_id_state_key?: string;
|
|
492
|
+
};
|
|
493
|
+
type CategoryConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
|
|
494
|
+
api: DepictAPI<InputDisplay, OutputDisplay>;
|
|
495
|
+
} & {
|
|
496
|
+
page_url_creator?: never;
|
|
497
|
+
};
|
|
498
|
+
type CategoryConstructorOptionsWithoutApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
|
|
499
|
+
api?: never;
|
|
500
|
+
} & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
501
|
+
page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
|
|
502
|
+
} : {
|
|
503
|
+
page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
|
|
504
|
+
} : {
|
|
505
|
+
page_url_creator?: never;
|
|
506
|
+
});
|
|
507
|
+
type DepictCategoryConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = CategoryConstructorOptionsWithApi<InputDisplay, OutputDisplay> | CategoryConstructorOptionsWithoutApi<InputDisplay, OutputDisplay>;
|
|
508
|
+
export class DepictCategory<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
|
|
509
|
+
#private;
|
|
510
|
+
get localization(): category_i18n;
|
|
511
|
+
set localization(locale_obj: category_i18n);
|
|
512
|
+
get category_id(): string;
|
|
513
|
+
set category_id(id: string);
|
|
514
|
+
get merchant(): string;
|
|
515
|
+
set merchant(merchant: string);
|
|
516
|
+
get market(): string;
|
|
517
|
+
set market(market: string);
|
|
518
|
+
get listing_type(): ListingType | undefined;
|
|
519
|
+
set listing_type(listing_type: ListingType | undefined);
|
|
520
|
+
get on_navigation(): OnNavigation;
|
|
521
|
+
set on_navigation(new_function: OnNavigation);
|
|
522
|
+
constructor({
|
|
523
|
+
api,
|
|
524
|
+
on_navigation,
|
|
525
|
+
page_url_creator,
|
|
526
|
+
unique_instance_key_for_state,
|
|
527
|
+
query_id_state_key,
|
|
528
|
+
...props_on_class
|
|
529
|
+
}: DepictCategoryConstructorOptions<InputDisplay, OutputDisplay>);
|
|
530
|
+
}
|
|
531
|
+
export function CategoryPage<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never>(props: {
|
|
532
|
+
depict_category: DepictCategory<OriginalDisplay, OutputDisplay>;
|
|
533
|
+
grid_spacing: SDKGridSpacing;
|
|
534
|
+
cols_at_size: SDKColsAtSize;
|
|
535
|
+
product_card_template: ProductCardTemplate<[OutputDisplay] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<OutputDisplay>>;
|
|
536
|
+
show_quicklinks?: boolean;
|
|
537
|
+
show_breadcrumbs?: boolean;
|
|
538
|
+
category_title: typeof CategoryTitle | typeof embedded_num_products;
|
|
539
|
+
}): import("@depict-ai/utilishared").Node_Array;
|
|
540
|
+
export function BreadCrumbs<T extends Display>({
|
|
541
|
+
depict_category
|
|
542
|
+
}: {
|
|
543
|
+
depict_category: DepictCategory<T>;
|
|
544
|
+
}): HTMLElement;
|
|
545
|
+
export function QuickLinks<T extends Display>({
|
|
546
|
+
depict_category
|
|
547
|
+
}: {
|
|
548
|
+
depict_category: DepictCategory<T>;
|
|
549
|
+
}): HTMLElement;
|
|
550
|
+
/**
|
|
551
|
+
* Gets available categories/collections (query_ids for the product-listing endpoint) for a merchant
|
|
552
|
+
* @param tenant
|
|
553
|
+
* @param market
|
|
554
|
+
* @param type - optional, currently only setting this to "collection" will return collections instead of categories
|
|
555
|
+
*/
|
|
556
|
+
export function get_categories(tenant: string, market: string, type?: string): Promise<string[]>;
|
|
557
|
+
type ImagePlaceholderBaseOptions = {
|
|
558
|
+
style?: JSX.CSSProperties;
|
|
559
|
+
class?: string;
|
|
560
|
+
};
|
|
561
|
+
type ImagePlaceholderBlockOptions = {
|
|
562
|
+
width: string;
|
|
563
|
+
height: string;
|
|
564
|
+
};
|
|
565
|
+
type ImagePlaceholderImageOptions = {
|
|
566
|
+
aspectRatio: number;
|
|
567
|
+
};
|
|
568
|
+
/**
|
|
569
|
+
* A placeholder that can be used instead of an image or other block of content while it's loading.
|
|
570
|
+
* The placeholder has `display:block`, meaning it will create a new "row" in the layout for itself. Can be used either for images with a defined aspect ratio (ContainedImage) or blocks.
|
|
571
|
+
* @property aspectRatio if aspectRatio is defined the placeholder will be in "image mode" and fill out the available width and then adjust the height according to the aspectRatio
|
|
572
|
+
* @property width If width and height is set, the defined width and height will be used.
|
|
573
|
+
* @property height If width and height is set, the defined width and height will be used.
|
|
574
|
+
* @property class extra classes to add to the placeholder
|
|
575
|
+
* @property style extra styles to add to the placeholder
|
|
576
|
+
*/
|
|
577
|
+
export function ImagePlaceholder(props: ImagePlaceholderBaseOptions & (ImagePlaceholderBlockOptions | ImagePlaceholderImageOptions)): JSX.Element;
|
|
578
|
+
export function DefaultInstantCardPlaceholder(): HTMLDivElement;
|
|
579
|
+
/**
|
|
580
|
+
* Useful for aligning the search modal to an element, like an existing input field
|
|
581
|
+
* @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
|
|
582
|
+
* @param input_field the element to align to.
|
|
583
|
+
* @param width_transformer A function that gets to change the width value before it is being applied
|
|
584
|
+
* @param includeScroll Should the aligner offset with scrolling? Useful to set to false when using position: fixed
|
|
585
|
+
* @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
|
|
586
|
+
* @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
|
|
587
|
+
*/
|
|
588
|
+
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;
|
|
589
|
+
interface Styles {
|
|
590
|
+
[selector: string]: JSX.CSSProperties;
|
|
591
|
+
}
|
|
592
|
+
export const styles_to_valid_css_string: (styles: Styles) => string;
|
|
593
|
+
/** A function that renders category suggestion cards. Set to false to disable category suggestions. */
|
|
594
|
+
export type RenderCategorySuggestion = (category_suggestion: Accessor<CategorySuggestionAfterURLCreator>, index: number) => JSX.Element;
|
|
595
|
+
/**
|
|
596
|
+
* Connects the height of the search field to the height of the aligner.
|
|
597
|
+
* @param aligner
|
|
598
|
+
* @returns
|
|
599
|
+
*/
|
|
600
|
+
export function connect_search_field_height_to_aligner_height(aligner: HTMLElement): {
|
|
601
|
+
cleanup: () => void;
|
|
602
|
+
};
|
|
603
|
+
type GeneralConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = {
|
|
604
|
+
search_query_url_param_name?: string;
|
|
605
|
+
market: string;
|
|
606
|
+
merchant: string;
|
|
607
|
+
localization: search_i18n;
|
|
608
|
+
on_navigation?: OnNavigation;
|
|
609
|
+
url_transformer?: (url_object: URL) => unknown;
|
|
610
|
+
enable_category_suggestions?: boolean;
|
|
611
|
+
unique_instance_key_for_state?: string;
|
|
612
|
+
disable_scrolling_during_modal?: boolean;
|
|
613
|
+
bottom_distance_under_modal?: Accessor<number | undefined>;
|
|
614
|
+
render_instant_card?: InstantCard<OutputDisplay extends ModernDisplay ? OutputDisplay : InputDisplay>;
|
|
615
|
+
};
|
|
616
|
+
type ConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralConstructorOptions<InputDisplay, OutputDisplay> & {
|
|
617
|
+
api: DepictAPI<InputDisplay, OutputDisplay>;
|
|
618
|
+
} & {
|
|
619
|
+
page_url_creator?: never;
|
|
620
|
+
};
|
|
621
|
+
type ConstructorOptionsWithoutAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralConstructorOptions<InputDisplay, OutputDisplay> & {
|
|
622
|
+
api?: never;
|
|
623
|
+
} & SomethingTakingAPageURLCreator<InputDisplay, OutputDisplay>;
|
|
624
|
+
type ConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = ConstructorOptionsWithApi<InputDisplay, OutputDisplay> | ConstructorOptionsWithoutAPI<InputDisplay, OutputDisplay>;
|
|
625
|
+
export type OpenModalArguments = [options_for_modal?: {
|
|
626
|
+
style_props_?: Signal<JSX.CSSProperties>;
|
|
627
|
+
closing_animation_?: () => Promise<any>;
|
|
628
|
+
class_list_?: Accessor<Record<string, boolean>>;
|
|
629
|
+
selected_text_range_?: readonly [number | null, number | null] | [number | null, number | null];
|
|
630
|
+
dont_sync_search_field_value_except_on_submit_?: boolean;
|
|
631
|
+
}, on_dispose?: VoidFunction];
|
|
632
|
+
export const get_search_query_updating_blocked_signal: (depict_search: DepictSearch<any>) => Signal<boolean> | undefined;
|
|
633
|
+
export class DepictSearch<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
|
|
634
|
+
#private;
|
|
635
|
+
constructor({
|
|
636
|
+
unique_instance_key_for_state,
|
|
637
|
+
search_query_url_param_name: search_query_url_param_name_,
|
|
638
|
+
url_transformer,
|
|
639
|
+
on_navigation,
|
|
640
|
+
enable_category_suggestions,
|
|
641
|
+
page_url_creator,
|
|
642
|
+
disable_scrolling_during_modal,
|
|
643
|
+
api,
|
|
644
|
+
bottom_distance_under_modal,
|
|
645
|
+
render_instant_card,
|
|
646
|
+
...props_on_class
|
|
647
|
+
}: ConstructorOptions<InputDisplay, OutputDisplay>);
|
|
648
|
+
get on_navigation(): OnNavigation;
|
|
649
|
+
set on_navigation(new_function: OnNavigation);
|
|
650
|
+
get localization(): search_i18n;
|
|
651
|
+
set localization(locale_obj: search_i18n);
|
|
652
|
+
get modal_open(): OpenModalArguments | boolean;
|
|
653
|
+
set modal_open(new_state: OpenModalArguments | boolean);
|
|
654
|
+
get merchant(): string;
|
|
655
|
+
set merchant(tenant: string);
|
|
656
|
+
get market(): string;
|
|
657
|
+
set market(market: string);
|
|
658
|
+
fetchSearchResults(query: string, filters?: SearchFilter[], maxResults?: number): Promise<([OutputDisplay] extends [never] ? InputDisplay : ModernDisplayWithPageUrl<OutputDisplay>)[]>;
|
|
659
|
+
}
|
|
660
|
+
export function SearchPage<OriginalDisplay extends Display, TransformedDisplay extends never | ModernDisplay>(props: {
|
|
661
|
+
depict_search: DepictSearch<OriginalDisplay, TransformedDisplay>;
|
|
662
|
+
include_input_field?: boolean | {
|
|
663
|
+
on_open_?: VoidFunction;
|
|
664
|
+
on_close_?: VoidFunction;
|
|
665
|
+
};
|
|
666
|
+
grid_spacing: SDKGridSpacing;
|
|
667
|
+
cols_at_size: SDKColsAtSize;
|
|
668
|
+
product_card_template: ProductCardTemplate<[TransformedDisplay] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<TransformedDisplay>>;
|
|
669
|
+
extra_depict_options?: {
|
|
670
|
+
recommendations_cols_at_size?: SDKColsAtSize;
|
|
671
|
+
};
|
|
672
|
+
}): import("@depict-ai/utilishared").Node_Array;
|
|
673
|
+
interface SearchFieldParams {
|
|
674
|
+
depict_search: DepictSearch<any>;
|
|
675
|
+
modal_dispose_handler?: VoidFunction;
|
|
676
|
+
click_handler?: (this: HTMLDivElement, ev: MouseEvent) => any;
|
|
677
|
+
aligner_ref?: HTMLElement | null;
|
|
678
|
+
}
|
|
679
|
+
export function SearchField(props: SearchFieldParams): import("@depict-ai/utilishared").Node_Array;
|
|
680
|
+
export type BaseProviderConfig<InputDisplay extends Display, PossibleTransformedDisplay extends ModernDisplay | never> = {
|
|
681
|
+
/**
|
|
682
|
+
* The merchant to use for the search.
|
|
683
|
+
* @example "YOUR_MERCHANT", "stronger"
|
|
684
|
+
*/
|
|
685
|
+
merchant: string;
|
|
686
|
+
/**
|
|
687
|
+
* The market to use for the search.
|
|
688
|
+
* @example "YOUR_MARKET", "no", "en-de"
|
|
689
|
+
*/
|
|
690
|
+
market: string;
|
|
691
|
+
/**
|
|
692
|
+
* Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
|
|
693
|
+
*/
|
|
694
|
+
userId?: string;
|
|
695
|
+
/**
|
|
696
|
+
* Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
|
|
697
|
+
*/
|
|
698
|
+
sessionId?: string;
|
|
699
|
+
/**
|
|
700
|
+
* Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
|
|
701
|
+
*/
|
|
702
|
+
metaData?: Record<string, string>;
|
|
703
|
+
/**
|
|
704
|
+
* You can't have more than one instance of the same provider on the same page, unless you specify a unique instance key for each one.
|
|
705
|
+
* This is because there's state in the URL and history.state and the state of the different instances would collide.
|
|
706
|
+
* By setting this property, you can specify a unique key for each instance, so that the state of each instance is kept separate.
|
|
707
|
+
* We recommend to just use an incrementing number for this, e.g. "1", "2", "3", ...
|
|
708
|
+
*/
|
|
709
|
+
uniqueInstanceKeyForState?: string;
|
|
710
|
+
} & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
|
|
711
|
+
pageURLCreator?: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
|
|
712
|
+
} : {
|
|
713
|
+
pageURLCreator: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
|
|
714
|
+
} : {
|
|
715
|
+
pageURLCreator?: never;
|
|
716
|
+
});
|
|
717
|
+
export type BaseSearchProviderConfig = {
|
|
718
|
+
/**
|
|
719
|
+
* The path to the search page.
|
|
720
|
+
* @example "/search", "/sok"
|
|
721
|
+
*/
|
|
722
|
+
searchPagePath: string;
|
|
723
|
+
/**
|
|
724
|
+
* The name of the url parameter that will be used for the search query.
|
|
725
|
+
* @example "q", "search_query", "query"
|
|
726
|
+
* @default "query"
|
|
727
|
+
*/
|
|
728
|
+
urlParamName?: string;
|
|
729
|
+
/**
|
|
730
|
+
* Whether to enable category suggestions in the search modal and search page.
|
|
731
|
+
* @default false
|
|
732
|
+
*/
|
|
733
|
+
enableCategorySuggestions?: boolean;
|
|
734
|
+
};
|
|
735
|
+
export interface BaseProductListingConfig {
|
|
736
|
+
/**
|
|
737
|
+
* How many columns to show at each media size.
|
|
738
|
+
* @default
|
|
739
|
+
* [[2, 901], [3, 1024], [4]]
|
|
740
|
+
* @example
|
|
741
|
+
* [[2, 901], [3, 1024], [4]]
|
|
742
|
+
* means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.
|
|
743
|
+
*/
|
|
744
|
+
columnsAtSize?: SDKColsAtSize;
|
|
745
|
+
/**
|
|
746
|
+
* The spacing between products.
|
|
747
|
+
* @default "2%"
|
|
748
|
+
* @example
|
|
749
|
+
* "2%", "10px", "1rem", {horizontal: "1%", vertical: "5px"}
|
|
750
|
+
*/
|
|
751
|
+
gridSpacing?: SDKGridSpacing;
|
|
752
|
+
}
|
|
753
|
+
export interface BaseSearchPageConfig extends BaseProductListingConfig {
|
|
754
|
+
/**
|
|
755
|
+
* Whether to show the search input field in the search page.
|
|
756
|
+
* @default true
|
|
757
|
+
*/
|
|
758
|
+
includeInputField?: boolean;
|
|
759
|
+
}
|
|
760
|
+
export interface BaseCategoryPageConfig extends BaseProductListingConfig {
|
|
761
|
+
/**
|
|
762
|
+
* Whether to show the breadcrumbs in the category page.
|
|
763
|
+
* @default true
|
|
764
|
+
*/
|
|
765
|
+
showBreadcrumbs?: boolean;
|
|
766
|
+
/**
|
|
767
|
+
* Whether to show the quicklinks in the category page.
|
|
768
|
+
* @default true
|
|
769
|
+
*/
|
|
770
|
+
showQuicklinks?: boolean;
|
|
771
|
+
}
|
|
772
|
+
type CenteredLocation = {
|
|
773
|
+
location?: "centered";
|
|
774
|
+
};
|
|
775
|
+
type AlignedLocation = {
|
|
776
|
+
location: "aligned";
|
|
777
|
+
element: HTMLElement;
|
|
778
|
+
};
|
|
779
|
+
/**
|
|
780
|
+
* How the modal should be opened.
|
|
781
|
+
*/
|
|
782
|
+
type ModalLocation = AlignedLocation | CenteredLocation;
|
|
783
|
+
type OpenModalParams<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never> = ModalLocation & {
|
|
784
|
+
search: DepictSearch<OriginalDisplay, OutputDisplay>;
|
|
785
|
+
/**
|
|
786
|
+
* If true, the search field in the modal opened will be empty and de-coupled from the other SearchFields.
|
|
787
|
+
*/
|
|
788
|
+
makesNewSearch?: boolean;
|
|
789
|
+
};
|
|
790
|
+
/**
|
|
791
|
+
* Open the modal with support for alignment.
|
|
792
|
+
* @returns {void}
|
|
793
|
+
*/
|
|
794
|
+
export const open_modal_with_alignment: <OriginalDisplay extends Display, OutputDisplay extends ModernDisplay>(openModalParams: OpenModalParams<OriginalDisplay, OutputDisplay>) => void;
|
|
795
|
+
export function open_search_with_shift_slash(open_search: VoidFunction): () => void;
|
|
796
|
+
export interface PageReplacer {
|
|
797
|
+
readonly render_: () => Node_Array;
|
|
798
|
+
readonly is_page_: (url: URL) => boolean;
|
|
799
|
+
readonly title_?: string;
|
|
800
|
+
readonly selector_: string;
|
|
801
|
+
readonly append_instead_of_replace_?: boolean;
|
|
802
|
+
}
|
|
803
|
+
/**
|
|
804
|
+
* PageReplacer is a class that can be used to layer an SPA (single page application) on top of a non-SPA, for certain pages.
|
|
805
|
+
* 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).
|
|
806
|
+
* 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.
|
|
807
|
+
* 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:
|
|
808
|
+
* @param render_ A function that returns the elements which replace the "page" when is_page_ returns true.
|
|
809
|
+
* @param title_ The title that document.title should be changed to when is_page_ returns true (the replacement page is open).
|
|
810
|
+
* @param is_page_ A function that returns true if the provided URL is the page where the replacement should take effect.
|
|
811
|
+
* @param selector_ A CSS selector that selects the element that should be replaced.
|
|
812
|
+
* @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.
|
|
813
|
+
*/
|
|
814
|
+
export class PageReplacer extends EventTarget {
|
|
815
|
+
#private;
|
|
816
|
+
/**
|
|
817
|
+
* Returns if the "replacement page" is currently open
|
|
818
|
+
*/
|
|
819
|
+
get open_(): boolean;
|
|
820
|
+
/**
|
|
821
|
+
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
822
|
+
*/
|
|
823
|
+
destroy_(): void;
|
|
824
|
+
constructor({
|
|
825
|
+
is_spa_,
|
|
826
|
+
...options
|
|
827
|
+
}: Omit<PageReplacer, "destroy_" | "addEventListener" | "removeEventListener" | "dispatchEvent" | "open_"> & {
|
|
828
|
+
is_spa_?: boolean;
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
/**
|
|
832
|
+
* 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)
|
|
833
|
+
*/
|
|
834
|
+
export function setup_fast_leave(pr: PageReplacer): void;
|
|
835
|
+
export const defaultColsAtSize: SDKColsAtSize;
|
|
836
|
+
export const defaultGridSpacing = "2%";
|
|
837
|
+
export const defaultCategoryTitlePlugin: ({
|
|
838
|
+
category_title_,
|
|
839
|
+
product_count_
|
|
840
|
+
}: {
|
|
841
|
+
category_title_: import("solid-js").Accessor<string | undefined>;
|
|
842
|
+
product_count_: import("solid-js").JSX.Element;
|
|
843
|
+
}) => import("solid-js").JSX.Element;
|
|
844
|
+
export type { SearchFilter } from "@depict-ai/types/api/SearchRequest";
|