@depict-ai/ui 1.4.3 → 1.4.5

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.
@@ -1,105 +1,108 @@
1
1
  import { JSX, Signal, Accessor, Setter } from "solid-js";
2
- import { Elem, Display, ColsAtSize, ModernDisplay, Node_Array } from "@depict-ai/utilishared";
2
+ import { Elem, Display, ColsAtSize, ModernDisplay, Node_Array } from "@depict-ai/utilishared/ES10";
3
3
  import { SearchFilter, SearchRequest } from "@depict-ai/types/api/SearchRequest";
4
- import { SearchFilter as _SearchFilter1, SearchResponse } from "@depict-ai/types/api/SearchResponse";
4
+ import { SearchFilter as _SearchFilter1, ContentLink, SearchResponse } from "@depict-ai/types/api/SearchResponse";
5
5
  import { BaseCategoryDisplay, ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
6
6
  import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/api/SearchSuggestionsResponse";
7
7
  import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
8
8
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
9
9
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
10
- export const version = "1.4.3";
10
+ export const version = "1.4.5";
11
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;
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
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]>; };
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
21
  /**
22
22
  * Like standard_price_format except that the price and the formatting are reactive accessors
23
23
  */
24
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
- };
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
33
  }): JSX.Element;
34
34
  /**
35
35
  * PLP internationalisation shared between search and category listing
36
36
  */
37
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
- };
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
71
  };
72
72
  /**
73
73
  * Search internationalisation
74
74
  */
75
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;
76
+ placeholder_text_: string;
77
+ show_n_results_: (number_of_results: HTMLElement) => Elem[];
78
+ no_results_text_: string;
79
+ no_products_: string;
80
+ search_recs_title_: string;
81
+ clear_filters_query_sorting_after_submit_: string;
82
+ modal_view_all_results_: (number_of_results: HTMLElement) => Elem[];
83
+ modal_discover_more_: string;
84
+ get_showing_results_for_: (query: HTMLElement, number_of_results_element: HTMLElement, has_query: boolean, number_of_results: number | undefined) => Elem[];
85
+ get_showing_pages_for_: (query: HTMLElement, number_of_results_element: HTMLElement, has_query: boolean, number_of_results: number | undefined) => Elem[];
86
+ previous_searches_text_: string;
87
+ category_: string;
88
+ brand_: string;
89
+ suggestions_: string;
90
+ search_submit_button_aria_label_: string;
91
+ search_field_field_aria_label_: string;
92
+ previous_searches_delete_entry_from_history_: string;
93
+ content_: string;
91
94
  }
92
95
  /**
93
96
  * Category internationalisation
94
97
  */
95
98
  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;
99
+ show_n_products_: (number_of_results: HTMLElement) => Elem[];
100
+ no_products_text_: string;
101
+ product_: string;
102
+ products_: string;
103
+ breadcrumbs_aria_label_: string;
104
+ quicklinks_aria_label_: string;
105
+ breadcrumbs_separator_: string;
103
106
  }
104
107
  /**
105
108
  * For anything that is not exposed and only used internally we can use solid signals to get more performant rendering.
@@ -108,33 +111,34 @@ interface category_i18n extends plp_shared_i18n {
108
111
  * Any solid_ type below should not be exposed outside of this library, as the accessors can be confusing and unnecessary.
109
112
  */
110
113
  /** For internal components using i18n that gets wrapped in solid's Accessors */
111
- type solid_plp_shared_i18n = {
112
- [K in keyof plp_shared_i18n]: Accessor<plp_shared_i18n[K]>;
113
- };
114
+ type solid_plp_shared_i18n = { [K in keyof plp_shared_i18n]: Accessor<plp_shared_i18n[K]> };
114
115
  /** @jsxImportSource solid-js */
115
116
  export function GenericSliderArrowButton(props?: {
116
- width_?: number;
117
- height_?: number;
117
+ width_?: number;
118
+ height_?: number;
118
119
  }): SVGElement;
119
- export function show_toast({ children, on_close_, close_after_, ...more_attributes }: {
120
- children?: JSX.Element;
121
- close_after_: number;
122
- on_close_?: VoidFunction;
120
+ export function show_toast({
121
+ children,
122
+ on_close_,
123
+ close_after_,
124
+ ...more_attributes
125
+ }: {
126
+ children?: JSX.Element;
127
+ close_after_: number;
128
+ on_close_?: VoidFunction;
123
129
  } & JSX.HTMLAttributes<HTMLDivElement>): {
124
- close_toast_: VoidFunction;
130
+ close_toast_: VoidFunction;
125
131
  };
126
132
  export type SDKGridSpacing = string | {
127
- horizontal: string;
128
- vertical: string;
129
- };
130
- export type WithRequired<T, K extends keyof T> = T & {
131
- [P in K]-?: T[P];
133
+ horizontal: string;
134
+ vertical: string;
132
135
  };
136
+ export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
133
137
  type FilterWithData = WithRequired<SearchFilter, "data">;
134
138
  export interface SDKRenderingInfo {
135
- set_on_index_change: (fn: (index: number) => void) => void;
136
- merchant: string;
137
- market: string;
139
+ set_on_index_change: (fn: (index: number) => void) => void;
140
+ merchant: string;
141
+ market: string;
138
142
  }
139
143
  export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
140
144
  /**
@@ -143,37 +147,45 @@ export type ProductCardTemplate<T extends Display> = (display: T | null, info?:
143
147
  */
144
148
  export type ListingType = "collection" | "category";
145
149
  type AddActualFieldToArray<T> = T extends Array<infer U> ? (U & {
146
- actual_field?: string;
150
+ actual_field?: string;
147
151
  })[] : never;
148
152
  type AddActualFieldToFilters<T extends SearchFilter[] | undefined> = T extends undefined ? undefined : AddActualFieldToArray<T>;
149
153
  export function CrossIcon(props?: JSX.SvgSVGAttributes<SVGSVGElement>): SVGElement;
150
- export function SelectedFilters({ number_of_rendered_selected_filters_items_, i18n_, selected_filters_, local_filter_cache_: [read_local_filter_cache], get_search_filters_open_, get_search_sorting_open_, local_filter_cache_, expanded_hierarchical_filters_, }: {
151
- get_search_filters_open_: Accessor<boolean>;
152
- get_search_sorting_open_: Accessor<boolean>;
153
- expanded_hierarchical_filters_: Signal<{
154
- value_: string[];
155
- expanded_: boolean;
156
- }[]>;
157
- number_of_rendered_selected_filters_items_: Signal<number>;
158
- i18n_: solid_plp_shared_i18n;
159
- selected_filters_: Signal<FilterWithData[]>;
160
- local_filter_cache_: Signal<SearchFilter[]>;
154
+ export function SelectedFilters({
155
+ number_of_rendered_selected_filters_items_,
156
+ i18n_,
157
+ selected_filters_,
158
+ local_filter_cache_: [read_local_filter_cache],
159
+ get_search_filters_open_,
160
+ get_search_sorting_open_,
161
+ local_filter_cache_,
162
+ expanded_hierarchical_filters_
163
+ }: {
164
+ get_search_filters_open_: Accessor<boolean>;
165
+ get_search_sorting_open_: Accessor<boolean>;
166
+ expanded_hierarchical_filters_: Signal<{
167
+ value_: string[];
168
+ expanded_: boolean;
169
+ }[]>;
170
+ number_of_rendered_selected_filters_items_: Signal<number>;
171
+ i18n_: solid_plp_shared_i18n;
172
+ selected_filters_: Signal<FilterWithData[]>;
173
+ local_filter_cache_: Signal<SearchFilter[]>;
161
174
  }): HTMLDivElement;
162
175
  /**
163
176
  * Use `javascript_media_query` but return a reactive accessor instead of taking a callback function
164
177
  */
165
178
  export function media_query_to_accessor(media_query: string): import("solid-js").Accessor<boolean>;
166
- declare class SDKError extends Error {
167
- }
179
+ declare class SDKError extends Error {}
168
180
  export class ProductCardError extends SDKError {
169
- constructor(templateError: Error);
181
+ constructor(templateError: Error);
170
182
  }
171
183
  /**
172
184
  * Base placeholder component used by ImagePlaceholder and TextPlaceholder
173
185
  */
174
186
  export function BasePlaceholder(props: {
175
- style: JSX.CSSProperties;
176
- class?: string;
187
+ style: JSX.CSSProperties;
188
+ class?: string;
177
189
  }): JSX.Element;
178
190
  /**
179
191
  * 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.
@@ -184,55 +196,60 @@ export function BasePlaceholder(props: {
184
196
  * @property style extra styles to add to the placeholder
185
197
  */
186
198
  export function TextPlaceholder(props: {
187
- style?: JSX.CSSProperties;
188
- height: string;
189
- width: string;
190
- class?: string;
199
+ style?: JSX.CSSProperties;
200
+ height: string;
201
+ width: string;
202
+ class?: string;
191
203
  }): JSX.Element;
192
204
  interface FilterBodyProps {
193
- available_filters_: Accessor<_SearchFilter1[] | undefined>;
194
- expanded_filters_: Signal<{
195
- section_: string;
196
- expanded_: boolean;
197
- }[]>;
198
- selected_filters_: Signal<{
199
- field: string;
200
- op: _SearchFilter1["op"];
201
- data: any;
202
- }[]>;
203
- local_filter_cache_: Signal<_SearchFilter1[]>;
204
- i18n_: solid_plp_shared_i18n;
205
- expanded_hierarchical_filters_: Signal<{
206
- value_: string[];
207
- expanded_: boolean;
208
- }[]>;
209
- are_in_modal_?: boolean;
205
+ available_filters_: Accessor<_SearchFilter1[] | undefined>;
206
+ expanded_filters_: Signal<{
207
+ section_: string;
208
+ expanded_: boolean;
209
+ }[]>;
210
+ selected_filters_: Signal<{
211
+ field: string;
212
+ op: _SearchFilter1["op"];
213
+ data: any;
214
+ }[]>;
215
+ local_filter_cache_: Signal<_SearchFilter1[]>;
216
+ i18n_: solid_plp_shared_i18n;
217
+ expanded_hierarchical_filters_: Signal<{
218
+ value_: string[];
219
+ expanded_: boolean;
220
+ }[]>;
221
+ are_in_modal_?: boolean;
210
222
  }
211
223
  export function FilterBody(props: FilterBodyProps): JSX.Element;
212
- export function create_modified_filters({ available_filters_, local_filter_cache_: [read_local_cache, write_local_cache], selected_filters_: [read_selected_filters], }: {
213
- available_filters_: Accessor<_SearchFilter1[] | undefined>;
214
- selected_filters_: Signal<{
215
- field: string;
216
- op: _SearchFilter1["op"];
217
- data: any;
218
- }[]>;
219
- local_filter_cache_: Signal<_SearchFilter1[]>;
224
+ export function create_modified_filters({
225
+ available_filters_,
226
+ local_filter_cache_: [read_local_cache, write_local_cache],
227
+ selected_filters_: [read_selected_filters]
228
+ }: {
229
+ available_filters_: Accessor<_SearchFilter1[] | undefined>;
230
+ selected_filters_: Signal<{
231
+ field: string;
232
+ op: _SearchFilter1["op"];
233
+ data: any;
234
+ }[]>;
235
+ local_filter_cache_: Signal<_SearchFilter1[]>;
220
236
  }): void;
221
237
  export type SolidLayoutOptions = {
222
- cols_at_size: ColsAtSize;
223
- grid_spacing: string;
224
- rows: {
225
- start_rows?: number;
226
- rows_per_click?: number;
227
- currently_visible?: Signal<number>;
228
- max_rows?: number;
229
- button?: JSX.Element;
230
- } | "all";
231
- layout: "slider" | "grid";
232
- disable_partial_rows?: boolean;
233
- override_vertical_spacing?: string;
234
- children: JSX.Element;
235
- element_attributes: JSX.HTMLAttributes<HTMLDivElement>;
238
+ cols_at_size: ColsAtSize;
239
+ grid_spacing: string;
240
+ rows: {
241
+ start_rows?: number;
242
+ rows_per_click?: number;
243
+ currently_visible?: Signal<number>;
244
+ max_rows?: number;
245
+ button?: JSX.Element;
246
+ view_less_button?: JSX.Element;
247
+ } | "all";
248
+ layout: "slider" | "grid";
249
+ disable_partial_rows?: boolean;
250
+ override_vertical_spacing?: string;
251
+ children: JSX.Element;
252
+ element_attributes: JSX.HTMLAttributes<HTMLDivElement>;
236
253
  };
237
254
  /**
238
255
  * 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.
@@ -244,43 +261,72 @@ export type SolidLayoutOptions = {
244
261
  * @return An accessor containing a CSS string
245
262
  */
246
263
  export function SolidLayout(props: SolidLayoutOptions): JSX.Element;
264
+ type DisplayTransformerAlwaysThereData = {
265
+ merchant: string;
266
+ market: string;
267
+ };
268
+ type CanBePromiseWrapped<T> = T | Promise<T>;
269
+ export type ModernDisplayWithPageUrl<T extends ModernDisplay> = { [K in keyof T]: K extends "variant_displays" ? (T[K][number] & {
270
+ page_url: string;
271
+ })[] : T[K] };
272
+ /**
273
+ * DisplayTransformers supersede pageURLCreator
274
+ * DisplayTransformers are functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
275
+ */
276
+ export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = {
277
+ products?: (options: DisplayTransformerAlwaysThereData & {
278
+ displays: InputDisplay[];
279
+ }) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
280
+ categories?: (options: DisplayTransformerAlwaysThereData & {
281
+ data: (BaseCategoryDisplay | CategorySuggestion)[];
282
+ }) => CanBePromiseWrapped<{
283
+ page_url: string;
284
+ }[]>;
285
+ contentResults?: (options: DisplayTransformerAlwaysThereData & {
286
+ data: ContentLink[];
287
+ }) => CanBePromiseWrapped<ContentLink[]>;
288
+ };
289
+ export type SomethingTakingAPageURLCreatorOrDisplayTransformers<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
290
+ page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
291
+ display_transformers?: never;
292
+ } | {
293
+ page_url_creator?: never;
294
+ display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
295
+ } : {
296
+ page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
297
+ display_transformers?: never;
298
+ } | {
299
+ display_transformers: DisplayTransformers<InputDisplay, OutputDisplay>;
300
+ page_url_creator?: never;
301
+ } : {
302
+ page_url_creator?: never;
303
+ display_transformers?: never;
304
+ };
247
305
  type PageURLCreatorAlwaysThereData = {
248
- merchant: string;
249
- market: string;
306
+ merchant: string;
307
+ market: string;
250
308
  };
251
309
  type PageURLCreatorCategoryData = {
252
- type: "categories";
253
- data: (BaseCategoryDisplay | CategorySuggestion)[];
310
+ type: "categories";
311
+ data: (BaseCategoryDisplay | CategorySuggestion)[];
254
312
  };
255
313
  type PageURLCreatorProductData<T extends ModernDisplay> = {
256
- displays: T[];
257
- type: "products";
258
- };
259
- type CanBePromiseWrapped<T> = T | Promise<T>;
260
- export type ModernDisplayWithPageUrl<T extends ModernDisplay> = {
261
- [K in keyof T]: K extends "variant_displays" ? (T[K][number] & {
262
- page_url: string;
263
- })[] : T[K];
314
+ displays: T[];
315
+ type: "products";
264
316
  };
265
317
  type PageURLCreatorOptions<InputDisplay extends ModernDisplay> = PageURLCreatorAlwaysThereData & (PageURLCreatorCategoryData | PageURLCreatorProductData<InputDisplay>);
266
318
  /**
319
+ * @deprecated use DisplayTransformers instead
267
320
  * 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.
268
321
  * It's main use case is to allow for the creation of links to the product or category pages on the merchant's site.
269
322
  * It can also be used for the depict customers which already have links to change those links (i.e. for staging sites).
270
323
  * 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.
271
324
  */
272
325
  export type PageURLCreator<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = (options: PageURLCreatorOptions<InputDisplay>) => (typeof options)["type"] extends "categories" ? CanBePromiseWrapped<{
273
- page_url: string;
326
+ page_url: string;
274
327
  }[]> : CanBePromiseWrapped<{
275
- page_url: string;
328
+ page_url: string;
276
329
  }[]> | CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
277
- export type SomethingTakingAPageURLCreator<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
278
- page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
279
- } : {
280
- page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
281
- } : {
282
- page_url_creator?: never;
283
- };
284
330
  /**
285
331
  * Basically allows you to use SearchModal
286
332
  * 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.
@@ -289,46 +335,46 @@ export type SomethingTakingAPageURLCreator<InputDisplay extends Display, OutputD
289
335
  @returns a function to open and close the modal. When calling the open_modal_ function additional parameters can be passed to the modal
290
336
  */
291
337
  export function general_modal_abstraction<StaticOptions extends {
292
- [key: string]: any;
338
+ [key: string]: any;
293
339
  }, ExtraOptionsProvidedOnOpen extends {
294
- [key: string]: any;
340
+ [key: string]: any;
295
341
  }>(search_modal: (options: StaticOptions & ExtraOptionsProvidedOnOpen & {
296
- close_modal_: VoidFunction;
297
- open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
298
- register_closing_animation_: (animation: () => Promise<any>) => void;
342
+ close_modal_: VoidFunction;
343
+ open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
344
+ register_closing_animation_: (animation: () => Promise<any>) => void;
299
345
  }) => Node_Array, modal_fn_opts: StaticOptions): Promise<{
300
- open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
301
- close_modal_: () => void;
346
+ open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
347
+ close_modal_: () => void;
302
348
  }>;
303
349
  export type OnNavigation = ((options: {
304
- is_replace: boolean;
305
- new_url: URL;
306
- scroll: boolean;
350
+ is_replace: boolean;
351
+ new_url: URL;
352
+ scroll: boolean;
307
353
  }) => void) | "hard_navigation";
308
354
  export type ExclusiveId = {
309
- categoryId: string;
310
- productId?: undefined;
311
- productIds?: undefined;
355
+ categoryId: string;
356
+ productId?: undefined;
357
+ productIds?: undefined;
312
358
  } | {
313
- categoryId?: undefined;
314
- productId: string;
315
- productIds?: undefined;
359
+ categoryId?: undefined;
360
+ productId: string;
361
+ productIds?: undefined;
316
362
  } | {
317
- categoryId?: undefined;
318
- productId?: undefined;
319
- productIds: string[];
363
+ categoryId?: undefined;
364
+ productId?: undefined;
365
+ productIds: string[];
320
366
  } | {
321
- categoryId?: undefined;
322
- productId?: undefined;
323
- productIds?: undefined;
367
+ categoryId?: undefined;
368
+ productId?: undefined;
369
+ productIds?: undefined;
324
370
  };
325
371
  type RecsAPIWrapperOptions = {
326
- type: string;
327
- merchant: string;
328
- market: string;
329
- userId?: string;
330
- sessionId?: string;
331
- headers?: HeadersInit;
372
+ type: string;
373
+ merchant: string;
374
+ market: string;
375
+ userId?: string;
376
+ sessionId?: string;
377
+ headers?: HeadersInit;
332
378
  } & ExclusiveId;
333
379
  /**
334
380
  * Fetches recommendations from Depict's API.
@@ -366,95 +412,104 @@ type RecsAPIWrapperOptions = {
366
412
  * ```
367
413
  * @return This function is guaranteed to return an array of Displays. If anything fails, you will get an empty array.
368
414
  */
369
- export function fetchDepictRecommendations<T extends Display = Display>({ merchant, market, headers, ...fetch_recs_options }: RecsAPIWrapperOptions): Promise<T[]>;
415
+ export function fetchDepictRecommendations<T extends Display = Display>({
416
+ merchant,
417
+ market,
418
+ headers,
419
+ ...fetch_recs_options
420
+ }: RecsAPIWrapperOptions): Promise<T[]>;
370
421
  export type InstantCard<T extends Display> = (display: T, context: {
371
- index: number;
372
- i18n: search_i18n;
373
- merchant: string;
374
- market: string;
422
+ index: number;
423
+ i18n: search_i18n;
424
+ merchant: string;
425
+ market: string;
375
426
  }) => JSX.Element;
376
427
  type CategorySuggestionAfterURLCreator = CategorySuggestion & {
377
- page_url: string;
428
+ page_url: string;
378
429
  };
379
430
  type ReplaceCategorySuggestion<T> = T extends CategorySuggestion ? CategorySuggestionAfterURLCreator : T extends CategorySuggestion[] ? CategorySuggestionAfterURLCreator[] : T;
380
- type SearchSuggestionsResponseAfterURLCreator = {
381
- [K in keyof SearchSuggestionsResponse]: ReplaceCategorySuggestion<SearchSuggestionsResponse[K]>;
382
- };
431
+ type SearchSuggestionsResponseAfterURLCreator = { [K in keyof SearchSuggestionsResponse]: ReplaceCategorySuggestion<SearchSuggestionsResponse[K]> };
383
432
  type AddPageUrlToDisplay<T extends any[]> = (T[number] & {
384
- page_url: string;
433
+ page_url: string;
385
434
  })[];
386
- type SearchResponseAfterURLCreator = {
387
- [K in keyof SearchResponse]: K extends "displays" ? AddPageUrlToDisplay<SearchResponse[K]> : K extends "filters" ? AddActualFieldToFilters<SearchResponse[K]> : SearchResponse[K];
388
- };
435
+ type SearchResponseAfterURLCreator = { [K in keyof SearchResponse]: K extends "displays" ? AddPageUrlToDisplay<SearchResponse[K]> : K extends "filters" ? AddActualFieldToFilters<SearchResponse[K]> : SearchResponse[K] };
389
436
  type BaseCategoryDisplayAfterURLCreator = BaseCategoryDisplay & {
390
- page_url: string;
437
+ page_url: string;
391
438
  };
392
439
  type ReplaceBaseCategoryDisplay<T> = T extends BaseCategoryDisplay ? BaseCategoryDisplayAfterURLCreator : T extends BaseCategoryDisplay[] ? BaseCategoryDisplayAfterURLCreator[] : T;
393
440
  type _AddPageUrlToDisplay1<T extends any[]> = (T[number] & {
394
- page_url: string;
441
+ page_url: string;
395
442
  })[];
396
- type ProductListingResponseAfterURLCreator = {
397
- [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];
398
- };
443
+ 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] };
399
444
  type DepictAPIConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = {
400
- get_metadata?: () => Promise<{
401
- [k: string]: string;
402
- } | undefined>;
403
- get_user_id?: () => string | undefined;
404
- get_session_id?: () => string | undefined;
405
- } & SomethingTakingAPageURLCreator<InputDisplay, OutputDisplay>;
445
+ get_metadata?: () => Promise<{
446
+ [k: string]: string;
447
+ } | undefined>;
448
+ get_user_id?: () => string | undefined;
449
+ get_session_id?: () => string | undefined;
450
+ } & SomethingTakingAPageURLCreatorOrDisplayTransformers<InputDisplay, OutputDisplay>;
406
451
  /**
407
452
  * Class that handles all communication done in PLP code with the Depict API. (Notably not for recommendations currently).
408
453
  * It handles caching, retries and errors and is the only place that should be making requests to the Depict API.
409
454
  */
410
455
  export class DepictAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
411
- #private;
412
- page_url_creator: PageURLCreator<ModernDisplay, OutputDisplay> | undefined;
413
- constructor(options: DepictAPIConstructorOptions<InputDisplay, OutputDisplay>);
414
- suggest(input_req: SearchSuggestionsRequest): Promise<SearchSuggestionsResponseAfterURLCreator & {
415
- failed?: true;
416
- }>;
417
- query(input_req: SearchRequest): Promise<SearchResponseAfterURLCreator & {
418
- failed?: true;
419
- }>;
420
- list(input_req: ProductListingRequest): Promise<ProductListingResponseAfterURLCreator & {
421
- failed?: true;
422
- }>;
423
- get_recommended<T extends Display>(input_req: BaseSearchRequest): Promise<{
424
- displays: T[];
425
- } & {
426
- failed?: true | undefined;
427
- }>;
456
+ #private;
457
+ page_url_creator: PageURLCreator<ModernDisplay, OutputDisplay> | undefined;
458
+ display_transformers: DisplayTransformers<ModernDisplay, OutputDisplay> | undefined;
459
+ constructor(options: DepictAPIConstructorOptions<InputDisplay, OutputDisplay>);
460
+ suggest(input_req: SearchSuggestionsRequest): Promise<SearchSuggestionsResponseAfterURLCreator & {
461
+ failed?: true;
462
+ }>;
463
+ query(input_req: SearchRequest): Promise<SearchResponseAfterURLCreator & {
464
+ failed?: true;
465
+ }>;
466
+ list(input_req: ProductListingRequest): Promise<ProductListingResponseAfterURLCreator & {
467
+ failed?: true;
468
+ }>;
469
+ get_recommended<T extends Display>(input_req: BaseSearchRequest): Promise<{
470
+ displays: T[];
471
+ } & {
472
+ failed?: true | undefined;
473
+ }>;
428
474
  }
429
475
  /**
430
476
  * Disables scrolling until the solidjs reactive scoped is disposed (onCleanup)
431
477
  * @returns A cleanup function to manually re-enable scrolling.
432
478
  */
433
479
  export function disable_scrolling(): () => void;
434
- export const CategoryTitle: ({ category_title_, product_count_, }: {
435
- category_title_: Accessor<string | undefined>;
436
- product_count_: JSX.Element;
480
+ export const CategoryTitle: ({
481
+ category_title_,
482
+ product_count_
483
+ }: {
484
+ category_title_: Accessor<string | undefined>;
485
+ product_count_: JSX.Element;
437
486
  }) => JSX.Element;
438
487
  /**
439
488
  * 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.
440
489
  * 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
441
490
  * If you see “ResizeObserver loop limit exceeded”, this is probably doing it. More context here: https://depictaiworkspace.slack.com/archives/C02KVDZ8YHZ/p1667315647758829
442
491
  */
443
- export const embedded_num_products: ({ make_product_count_, set_observed_results_filters_elements_, is_slim_, sort_and_filter_element_, extra_sort_and_filter_args_, }: {
444
- make_product_count_: () => JSX.Element;
445
- set_observed_results_filters_elements_: Setter<JSX.Element>;
446
- sort_and_filter_element_: Accessor<HTMLDivElement | undefined>;
447
- is_slim_: Accessor<boolean>;
448
- extra_sort_and_filter_args_: {
449
- get_extra_sorting_button_?: ((extra_button: JSX.Element) => unknown) | undefined;
450
- get_extra_filters_button_?: ((extra_button: JSX.Element) => unknown) | undefined;
451
- sort_button_width_?: Accessor<number | undefined> | undefined;
452
- filter_button_width_?: Accessor<number | undefined> | undefined;
453
- };
492
+ export const embedded_num_products: ({
493
+ make_product_count_,
494
+ set_observed_results_filters_elements_,
495
+ is_slim_,
496
+ sort_and_filter_element_,
497
+ extra_sort_and_filter_args_
498
+ }: {
499
+ make_product_count_: () => JSX.Element;
500
+ set_observed_results_filters_elements_: Setter<JSX.Element>;
501
+ sort_and_filter_element_: Accessor<HTMLDivElement | undefined>;
502
+ is_slim_: Accessor<boolean>;
503
+ extra_sort_and_filter_args_: {
504
+ get_extra_sorting_button_?: ((extra_button: JSX.Element) => unknown) | undefined;
505
+ get_extra_filters_button_?: ((extra_button: JSX.Element) => unknown) | undefined;
506
+ sort_button_width_?: Accessor<number | undefined> | undefined;
507
+ filter_button_width_?: Accessor<number | undefined> | undefined;
508
+ };
454
509
  }) => {
455
- only_show_filters_opener_: Accessor<boolean>;
456
- middle_elements_: Accessor<JSX.Element>;
457
- on_filters_constructed_: () => void;
510
+ only_show_filters_opener_: Accessor<boolean>;
511
+ middle_elements_: Accessor<JSX.Element>;
512
+ on_filters_constructed_: () => void;
458
513
  };
459
514
  export type SDKColsAtSize = [number, number?][];
460
515
  /**
@@ -464,60 +519,65 @@ export type SDKColsAtSize = [number, number?][];
464
519
  */
465
520
  export const convert_sdk_cols_at_size_to_layout: (cols_at_size: SDKColsAtSize) => ColsAtSize;
466
521
  type GeneralCategoryListingOptions = {
467
- market: string;
468
- merchant: string;
469
- localization: category_i18n;
470
- unique_instance_key_for_state?: string;
471
- on_navigation?: OnNavigation;
472
- query_id_state_key?: string;
522
+ market: string;
523
+ merchant: string;
524
+ localization: category_i18n;
525
+ unique_instance_key_for_state?: string;
526
+ on_navigation?: OnNavigation;
527
+ query_id_state_key?: string;
473
528
  };
474
529
  type CategoryConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
475
- api: DepictAPI<InputDisplay, OutputDisplay>;
530
+ api: DepictAPI<InputDisplay, OutputDisplay>;
476
531
  } & {
477
- page_url_creator?: never;
532
+ page_url_creator?: never;
533
+ display_transformers?: never;
478
534
  };
479
535
  type CategoryConstructorOptionsWithoutApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
480
- api?: never;
481
- } & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
482
- page_url_creator?: PageURLCreator<InputDisplay, OutputDisplay>;
483
- } : {
484
- page_url_creator: PageURLCreator<InputDisplay, OutputDisplay>;
485
- } : {
486
- page_url_creator?: never;
487
- });
536
+ api?: never;
537
+ } & SomethingTakingAPageURLCreatorOrDisplayTransformers<InputDisplay, OutputDisplay>;
488
538
  type DepictCategoryConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = CategoryConstructorOptionsWithApi<InputDisplay, OutputDisplay> | CategoryConstructorOptionsWithoutApi<InputDisplay, OutputDisplay>;
489
539
  export class DepictCategory<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
490
- #private;
491
- get localization(): category_i18n;
492
- set localization(locale_obj: category_i18n);
493
- get category_id(): string;
494
- set category_id(id: string);
495
- get merchant(): string;
496
- set merchant(merchant: string);
497
- get market(): string;
498
- set market(market: string);
499
- get listing_type(): ListingType | undefined;
500
- set listing_type(listing_type: ListingType | undefined);
501
- get on_navigation(): OnNavigation;
502
- set on_navigation(new_function: OnNavigation);
503
- constructor({ api, on_navigation, page_url_creator, unique_instance_key_for_state, query_id_state_key, ...props_on_class }: DepictCategoryConstructorOptions<InputDisplay, OutputDisplay>);
540
+ #private;
541
+ get localization(): category_i18n;
542
+ set localization(locale_obj: category_i18n);
543
+ get category_id(): string;
544
+ set category_id(id: string);
545
+ get merchant(): string;
546
+ set merchant(merchant: string);
547
+ get market(): string;
548
+ set market(market: string);
549
+ get listing_type(): ListingType | undefined;
550
+ set listing_type(listing_type: ListingType | undefined);
551
+ get on_navigation(): OnNavigation;
552
+ set on_navigation(new_function: OnNavigation);
553
+ constructor({
554
+ api,
555
+ on_navigation,
556
+ page_url_creator,
557
+ display_transformers,
558
+ unique_instance_key_for_state,
559
+ query_id_state_key,
560
+ ...props_on_class
561
+ }: DepictCategoryConstructorOptions<InputDisplay, OutputDisplay>);
504
562
  }
505
563
  export function CategoryPage<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never>(props: {
506
- depict_category: DepictCategory<OriginalDisplay, OutputDisplay>;
507
- grid_spacing: SDKGridSpacing;
508
- cols_at_size: SDKColsAtSize;
509
- product_card_template: ProductCardTemplate<[
510
- OutputDisplay
511
- ] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<OutputDisplay>>;
512
- show_quicklinks?: boolean;
513
- show_breadcrumbs?: boolean;
514
- category_title: typeof CategoryTitle | typeof embedded_num_products;
564
+ depict_category: DepictCategory<OriginalDisplay, OutputDisplay>;
565
+ grid_spacing: SDKGridSpacing;
566
+ cols_at_size: SDKColsAtSize;
567
+ product_card_template: ProductCardTemplate<[OutputDisplay] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<OutputDisplay>>;
568
+ show_quicklinks?: boolean;
569
+ show_breadcrumbs?: boolean;
570
+ category_title: typeof CategoryTitle | typeof embedded_num_products;
515
571
  }): import("@depict-ai/utilishared").Node_Array;
516
- export function BreadCrumbs<T extends Display>({ depict_category }: {
517
- depict_category: DepictCategory<T>;
572
+ export function BreadCrumbs<T extends Display>({
573
+ depict_category
574
+ }: {
575
+ depict_category: DepictCategory<T>;
518
576
  }): HTMLElement;
519
- export function QuickLinks<T extends Display>({ depict_category }: {
520
- depict_category: DepictCategory<T>;
577
+ export function QuickLinks<T extends Display>({
578
+ depict_category
579
+ }: {
580
+ depict_category: DepictCategory<T>;
521
581
  }): HTMLElement;
522
582
  /**
523
583
  * Gets available categories/collections (query_ids for the product-listing endpoint) for a merchant
@@ -527,15 +587,15 @@ export function QuickLinks<T extends Display>({ depict_category }: {
527
587
  */
528
588
  export function get_categories(tenant: string, market: string, type?: string): Promise<string[]>;
529
589
  type ImagePlaceholderBaseOptions = {
530
- style?: JSX.CSSProperties;
531
- class?: string;
590
+ style?: JSX.CSSProperties;
591
+ class?: string;
532
592
  };
533
593
  type ImagePlaceholderBlockOptions = {
534
- width: string;
535
- height: string;
594
+ width: string;
595
+ height: string;
536
596
  };
537
597
  type ImagePlaceholderImageOptions = {
538
- aspectRatio: number;
598
+ aspectRatio: number;
539
599
  };
540
600
  /**
541
601
  * A placeholder that can be used instead of an image or other block of content while it's loading.
@@ -559,7 +619,7 @@ export function DefaultInstantCardPlaceholder(): HTMLDivElement;
559
619
  */
560
620
  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;
561
621
  interface Styles {
562
- [selector: string]: JSX.CSSProperties;
622
+ [selector: string]: JSX.CSSProperties;
563
623
  }
564
624
  export const styles_to_valid_css_string: (styles: Styles) => string;
565
625
  /** A function that renders category suggestion cards. Set to false to disable category suggestions. */
@@ -570,187 +630,243 @@ export type RenderCategorySuggestion = (category_suggestion: Accessor<CategorySu
570
630
  * @returns
571
631
  */
572
632
  export function connect_search_field_height_to_aligner_height(aligner: HTMLElement): {
573
- cleanup: () => void;
633
+ cleanup: () => void;
574
634
  };
575
635
  type GeneralConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = {
576
- search_query_url_param_name?: string;
577
- market: string;
578
- merchant: string;
579
- localization: search_i18n;
580
- on_navigation?: OnNavigation;
581
- url_transformer?: (url_object: URL) => unknown;
582
- enable_category_suggestions?: boolean;
583
- unique_instance_key_for_state?: string;
584
- disable_scrolling_during_modal?: boolean;
585
- bottom_distance_under_modal?: Accessor<number | undefined>;
586
- render_instant_card?: InstantCard<OutputDisplay extends ModernDisplay ? OutputDisplay : InputDisplay>;
636
+ search_query_url_param_name?: string;
637
+ market: string;
638
+ merchant: string;
639
+ localization: search_i18n;
640
+ on_navigation?: OnNavigation;
641
+ url_transformer?: (url_object: URL) => unknown;
642
+ enable_category_suggestions?: boolean;
643
+ enable_content_search?: boolean;
644
+ unique_instance_key_for_state?: string;
645
+ disable_scrolling_during_modal?: boolean;
646
+ bottom_distance_under_modal?: Accessor<number | undefined>;
647
+ render_instant_card?: InstantCard<OutputDisplay extends ModernDisplay ? OutputDisplay : InputDisplay>;
587
648
  };
588
649
  type ConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralConstructorOptions<InputDisplay, OutputDisplay> & {
589
- api: DepictAPI<InputDisplay, OutputDisplay>;
650
+ api: DepictAPI<InputDisplay, OutputDisplay>;
590
651
  } & {
591
- page_url_creator?: never;
652
+ page_url_creator?: never;
653
+ display_transformers?: never;
592
654
  };
593
655
  type ConstructorOptionsWithoutAPI<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralConstructorOptions<InputDisplay, OutputDisplay> & {
594
- api?: never;
595
- } & SomethingTakingAPageURLCreator<InputDisplay, OutputDisplay>;
656
+ api?: never;
657
+ } & SomethingTakingAPageURLCreatorOrDisplayTransformers<InputDisplay, OutputDisplay>;
596
658
  type ConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay> = ConstructorOptionsWithApi<InputDisplay, OutputDisplay> | ConstructorOptionsWithoutAPI<InputDisplay, OutputDisplay>;
597
- export type OpenModalArguments = [
598
- options_for_modal?: {
599
- style_props_?: Signal<JSX.CSSProperties>;
600
- closing_animation_?: () => Promise<any>;
601
- class_list_?: Accessor<Record<string, boolean>>;
602
- selected_text_range_?: readonly [number | null, number | null] | [number | null, number | null];
603
- dont_sync_search_field_value_except_on_submit_?: boolean;
604
- },
605
- on_dispose?: VoidFunction
606
- ];
659
+ export type OpenModalArguments = [options_for_modal?: {
660
+ style_props_?: Signal<JSX.CSSProperties>;
661
+ closing_animation_?: () => Promise<any>;
662
+ class_list_?: Accessor<Record<string, boolean>>;
663
+ selected_text_range_?: readonly [number | null, number | null] | [number | null, number | null];
664
+ dont_sync_search_field_value_except_on_submit_?: boolean;
665
+ }, on_dispose?: VoidFunction];
607
666
  export const get_search_query_updating_blocked_signal: (depict_search: DepictSearch<any>) => Signal<boolean> | undefined;
608
667
  export class DepictSearch<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never> {
609
- #private;
610
- constructor({ unique_instance_key_for_state, search_query_url_param_name: search_query_url_param_name_, url_transformer, on_navigation, enable_category_suggestions, page_url_creator, disable_scrolling_during_modal, api, bottom_distance_under_modal, render_instant_card, ...props_on_class }: ConstructorOptions<InputDisplay, OutputDisplay>);
611
- get on_navigation(): OnNavigation;
612
- set on_navigation(new_function: OnNavigation);
613
- get localization(): search_i18n;
614
- set localization(locale_obj: search_i18n);
615
- get modal_open(): OpenModalArguments | boolean;
616
- set modal_open(new_state: OpenModalArguments | boolean);
617
- get merchant(): string;
618
- set merchant(tenant: string);
619
- get market(): string;
620
- set market(market: string);
621
- fetchSearchResults(query: string, filters?: SearchFilter[], maxResults?: number): Promise<([OutputDisplay] extends [never] ? InputDisplay : ModernDisplayWithPageUrl<OutputDisplay>)[]>;
668
+ #private;
669
+ constructor({
670
+ unique_instance_key_for_state,
671
+ search_query_url_param_name: search_query_url_param_name_,
672
+ url_transformer,
673
+ on_navigation,
674
+ enable_category_suggestions,
675
+ page_url_creator,
676
+ display_transformers,
677
+ api,
678
+ disable_scrolling_during_modal,
679
+ bottom_distance_under_modal,
680
+ render_instant_card,
681
+ ...props_on_class
682
+ }: ConstructorOptions<InputDisplay, OutputDisplay>);
683
+ get enable_content_search(): boolean | undefined;
684
+ set enable_content_search(new_state: boolean | undefined);
685
+ get on_navigation(): OnNavigation;
686
+ set on_navigation(new_function: OnNavigation);
687
+ get localization(): search_i18n;
688
+ set localization(locale_obj: search_i18n);
689
+ get modal_open(): OpenModalArguments | boolean;
690
+ set modal_open(new_state: OpenModalArguments | boolean);
691
+ get merchant(): string;
692
+ set merchant(tenant: string);
693
+ get market(): string;
694
+ set market(market: string);
695
+ fetchSearchResults(query: string, filters?: SearchFilter[], maxResults?: number): Promise<([OutputDisplay] extends [never] ? InputDisplay : ModernDisplayWithPageUrl<OutputDisplay>)[]>;
622
696
  }
623
697
  export function SearchPage<OriginalDisplay extends Display, TransformedDisplay extends never | ModernDisplay>(props: {
624
- depict_search: DepictSearch<OriginalDisplay, TransformedDisplay>;
625
- include_input_field?: boolean | {
626
- on_open_?: VoidFunction;
627
- on_close_?: VoidFunction;
628
- };
629
- grid_spacing: SDKGridSpacing;
630
- cols_at_size: SDKColsAtSize;
631
- product_card_template: ProductCardTemplate<[
632
- TransformedDisplay
633
- ] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<TransformedDisplay>>;
634
- extra_depict_options?: {
635
- recommendations_cols_at_size?: SDKColsAtSize;
636
- };
698
+ depict_search: DepictSearch<OriginalDisplay, TransformedDisplay>;
699
+ include_input_field?: boolean | {
700
+ on_open_?: VoidFunction;
701
+ on_close_?: VoidFunction;
702
+ };
703
+ grid_spacing: SDKGridSpacing;
704
+ cols_at_size: SDKColsAtSize;
705
+ product_card_template: ProductCardTemplate<[TransformedDisplay] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<TransformedDisplay>>;
706
+ extra_depict_options?: {
707
+ recommendations_cols_at_size?: SDKColsAtSize;
708
+ };
637
709
  }): import("@depict-ai/utilishared").Node_Array;
638
710
  interface SearchFieldParams {
639
- depict_search: DepictSearch<any>;
640
- modal_dispose_handler?: VoidFunction;
641
- click_handler?: (this: HTMLDivElement, ev: MouseEvent) => any;
642
- aligner_ref?: HTMLElement | null;
711
+ depict_search: DepictSearch<any>;
712
+ modal_dispose_handler?: VoidFunction;
713
+ click_handler?: (this: HTMLDivElement, ev: MouseEvent) => any;
714
+ aligner_ref?: HTMLElement | null;
643
715
  }
644
716
  export function SearchField(props: SearchFieldParams): import("@depict-ai/utilishared").Node_Array;
645
717
  export type BaseProviderConfig<InputDisplay extends Display, PossibleTransformedDisplay extends ModernDisplay | never> = {
646
- /**
647
- * The merchant to use for the search.
648
- * @example "YOUR_MERCHANT", "stronger"
649
- */
650
- merchant: string;
651
- /**
652
- * The market to use for the search.
653
- * @example "YOUR_MARKET", "no", "en-de"
654
- */
655
- market: string;
656
- /**
657
- * Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
658
- */
659
- userId?: string;
660
- /**
661
- * Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
662
- */
663
- sessionId?: string;
664
- /**
665
- * Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
666
- */
667
- metaData?: Record<string, string>;
668
- /**
669
- * 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.
670
- * This is because there's state in the URL and history.state and the state of the different instances would collide.
671
- * By setting this property, you can specify a unique key for each instance, so that the state of each instance is kept separate.
672
- * We recommend to just use an incrementing number for this, e.g. "1", "2", "3", ...
673
- */
674
- uniqueInstanceKeyForState?: string;
718
+ /**
719
+ * The merchant to use for the search.
720
+ * @example "YOUR_MERCHANT", "stronger"
721
+ */
722
+ merchant: string;
723
+ /**
724
+ * The market to use for the search.
725
+ * @example "YOUR_MARKET", "no", "en-de"
726
+ */
727
+ market: string;
728
+ /**
729
+ * Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
730
+ */
731
+ userId?: string;
732
+ /**
733
+ * Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
734
+ */
735
+ sessionId?: string;
736
+ /**
737
+ * Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
738
+ */
739
+ metaData?: Record<string, string>;
740
+ /**
741
+ * 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.
742
+ * This is because there's state in the URL and history.state and the state of the different instances would collide.
743
+ * By setting this property, you can specify a unique key for each instance, so that the state of each instance is kept separate.
744
+ * We recommend to just use an incrementing number for this, e.g. "1", "2", "3", ...
745
+ */
746
+ uniqueInstanceKeyForState?: string;
675
747
  } & (InputDisplay extends ModernDisplay ? "page_url" extends keyof InputDisplay["variant_displays"][number] ? {
676
- pageURLCreator?: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
748
+ /**
749
+ * @deprecated use displayTransformers instead
750
+ */
751
+ pageURLCreator?: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
752
+ /**
753
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
754
+ */
755
+ displayTransformers?: never;
756
+ } | {
757
+ /**
758
+ * @deprecated use displayTransformers instead
759
+ */
760
+ pageURLCreator?: never;
761
+ /**
762
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
763
+ */
764
+ displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
677
765
  } : {
678
- pageURLCreator: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
766
+ /**
767
+ * @deprecated use displayTransformers instead
768
+ */
769
+ pageURLCreator: PageURLCreator<InputDisplay, PossibleTransformedDisplay>;
770
+ /**
771
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
772
+ */
773
+ displayTransformers?: never;
774
+ } | {
775
+ /**
776
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
777
+ */
778
+ displayTransformers: DisplayTransformers<InputDisplay, PossibleTransformedDisplay>;
779
+ /**
780
+ * @deprecated use displayTransformers instead
781
+ */
782
+ pageURLCreator?: never;
679
783
  } : {
680
- pageURLCreator?: never;
784
+ /**
785
+ * @deprecated use displayTransformers instead
786
+ */
787
+ pageURLCreator?: never;
788
+ /**
789
+ * Functions that take in a list of categories, content search results or products and then can transform or enrich the data for each category, content search result or product card in a batched way.
790
+ */
791
+ displayTransformers?: never;
681
792
  });
682
793
  export type BaseSearchProviderConfig = {
683
- /**
684
- * The path to the search page.
685
- * @example "/search", "/sok"
686
- */
687
- searchPagePath: string;
688
- /**
689
- * The name of the url parameter that will be used for the search query.
690
- * @example "q", "search_query", "query"
691
- * @default "query"
692
- */
693
- urlParamName?: string;
694
- /**
695
- * Whether to enable category suggestions in the search modal and search page.
696
- * @default false
697
- */
698
- enableCategorySuggestions?: boolean;
794
+ /**
795
+ * The path to the search page.
796
+ * @example "/search", "/sok"
797
+ */
798
+ searchPagePath: string;
799
+ /**
800
+ * The name of the url parameter that will be used for the search query.
801
+ * @example "q", "search_query", "query"
802
+ * @default "query"
803
+ */
804
+ urlParamName?: string;
805
+ /**
806
+ * Whether to enable category suggestions in the search modal and search page.
807
+ * @default false
808
+ */
809
+ enableCategorySuggestions?: boolean;
810
+ /**
811
+ * Whether to enable content search in the search modal and search page.
812
+ * @default false
813
+ */
814
+ enableContentSearch?: boolean;
699
815
  };
700
816
  export interface BaseProductListingConfig {
701
- /**
702
- * How many columns to show at each media size.
703
- * @default
704
- * [[2, 901], [3, 1024], [4]]
705
- * @example
706
- * [[2, 901], [3, 1024], [4]]
707
- * means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.
708
- */
709
- columnsAtSize?: SDKColsAtSize;
710
- /**
711
- * The spacing between products.
712
- * @default "2%"
713
- * @example
714
- * "2%", "10px", "1rem", {horizontal: "1%", vertical: "5px"}
715
- */
716
- gridSpacing?: SDKGridSpacing;
817
+ /**
818
+ * How many columns to show at each media size.
819
+ * @default
820
+ * [[2, 901], [3, 1024], [4]]
821
+ * @example
822
+ * [[2, 901], [3, 1024], [4]]
823
+ * means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.
824
+ */
825
+ columnsAtSize?: SDKColsAtSize;
826
+ /**
827
+ * The spacing between products.
828
+ * @default "2%"
829
+ * @example
830
+ * "2%", "10px", "1rem", {horizontal: "1%", vertical: "5px"}
831
+ */
832
+ gridSpacing?: SDKGridSpacing;
717
833
  }
718
834
  export interface BaseSearchPageConfig extends BaseProductListingConfig {
719
- /**
720
- * Whether to show the search input field in the search page.
721
- * @default true
722
- */
723
- includeInputField?: boolean;
835
+ /**
836
+ * Whether to show the search input field in the search page.
837
+ * @default true
838
+ */
839
+ includeInputField?: boolean;
724
840
  }
725
841
  export interface BaseCategoryPageConfig extends BaseProductListingConfig {
726
- /**
727
- * Whether to show the breadcrumbs in the category page.
728
- * @default true
729
- */
730
- showBreadcrumbs?: boolean;
731
- /**
732
- * Whether to show the quicklinks in the category page.
733
- * @default true
734
- */
735
- showQuicklinks?: boolean;
842
+ /**
843
+ * Whether to show the breadcrumbs in the category page.
844
+ * @default true
845
+ */
846
+ showBreadcrumbs?: boolean;
847
+ /**
848
+ * Whether to show the quicklinks in the category page.
849
+ * @default true
850
+ */
851
+ showQuicklinks?: boolean;
736
852
  }
737
853
  type CenteredLocation = {
738
- location?: "centered";
854
+ location?: "centered";
739
855
  };
740
856
  type AlignedLocation = {
741
- location: "aligned";
742
- element: HTMLElement;
857
+ location: "aligned";
858
+ element: HTMLElement;
743
859
  };
744
860
  /**
745
861
  * How the modal should be opened.
746
862
  */
747
863
  type ModalLocation = AlignedLocation | CenteredLocation;
748
864
  type OpenModalParams<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never> = ModalLocation & {
749
- search: DepictSearch<OriginalDisplay, OutputDisplay>;
750
- /**
751
- * If true, the search field in the modal opened will be empty and de-coupled from the other SearchFields.
752
- */
753
- makesNewSearch?: boolean;
865
+ search: DepictSearch<OriginalDisplay, OutputDisplay>;
866
+ /**
867
+ * If true, the search field in the modal opened will be empty and de-coupled from the other SearchFields.
868
+ */
869
+ makesNewSearch?: boolean;
754
870
  };
755
871
  /**
756
872
  * Open the modal with support for alignment.
@@ -759,11 +875,11 @@ type OpenModalParams<OriginalDisplay extends Display, OutputDisplay extends Mode
759
875
  export const open_modal_with_alignment: <OriginalDisplay extends Display, OutputDisplay extends ModernDisplay>(openModalParams: OpenModalParams<OriginalDisplay, OutputDisplay>) => void;
760
876
  export function open_search_with_shift_slash(open_search: VoidFunction): () => void;
761
877
  export interface PageReplacer {
762
- readonly render_: () => Node_Array;
763
- readonly is_page_: (url: URL) => boolean;
764
- readonly title_?: string;
765
- readonly selector_: string;
766
- readonly append_instead_of_replace_?: boolean;
878
+ readonly render_: () => Node_Array;
879
+ readonly is_page_: (url: URL) => boolean;
880
+ readonly title_?: string;
881
+ readonly selector_: string;
882
+ readonly append_instead_of_replace_?: boolean;
767
883
  }
768
884
  /**
769
885
  * PageReplacer is a class that can be used to layer an SPA (single page application) on top of a non-SPA, for certain pages.
@@ -777,18 +893,21 @@ export interface PageReplacer {
777
893
  * @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.
778
894
  */
779
895
  export class PageReplacer extends EventTarget {
780
- #private;
781
- /**
782
- * Returns if the "replacement page" is currently open
783
- */
784
- get open_(): boolean;
785
- /**
786
- * Stops listening to URL changes and closes the page (if it is currently open)
787
- */
788
- destroy_(): void;
789
- constructor({ is_spa_, ...options }: Omit<PageReplacer, "destroy_" | "addEventListener" | "removeEventListener" | "dispatchEvent" | "open_"> & {
790
- is_spa_?: boolean;
791
- });
896
+ #private;
897
+ /**
898
+ * Returns if the "replacement page" is currently open
899
+ */
900
+ get open_(): boolean;
901
+ /**
902
+ * Stops listening to URL changes and closes the page (if it is currently open)
903
+ */
904
+ destroy_(): void;
905
+ constructor({
906
+ is_spa_,
907
+ ...options
908
+ }: Omit<PageReplacer, "destroy_" | "addEventListener" | "removeEventListener" | "dispatchEvent" | "open_"> & {
909
+ is_spa_?: boolean;
910
+ });
792
911
  }
793
912
  /**
794
913
  * 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)
@@ -796,8 +915,11 @@ export class PageReplacer extends EventTarget {
796
915
  export function setup_fast_leave(pr: PageReplacer): void;
797
916
  export const defaultColsAtSize: SDKColsAtSize;
798
917
  export const defaultGridSpacing = "2%";
799
- export const defaultCategoryTitlePlugin: ({ category_title_, product_count_, }: {
800
- category_title_: import("solid-js").Accessor<string | undefined>;
801
- product_count_: import("solid-js").JSX.Element;
918
+ export const defaultCategoryTitlePlugin: ({
919
+ category_title_,
920
+ product_count_
921
+ }: {
922
+ category_title_: import("solid-js").Accessor<string | undefined>;
923
+ product_count_: import("solid-js").JSX.Element;
802
924
  }) => import("solid-js").JSX.Element;
803
- export type { SearchFilter } from "@depict-ai/types/api/SearchRequest";
925
+ export type { SearchFilter } from "@depict-ai/types/api/SearchRequest";