@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.
- package/ES10/index.cjs +11107 -0
- package/{dist → ES10}/index.d.ts +594 -472
- package/ES10/index.js +11056 -0
- package/latest/index.cjs +10233 -0
- package/latest/index.d.ts +925 -0
- package/latest/index.js +10185 -0
- package/locales/ES10/index.cjs +969 -0
- package/locales/ES10/index.d.ts +92 -0
- package/locales/ES10/index.js +948 -0
- package/locales/index.cjs +1 -0
- package/locales/index.js +1 -1150
- package/locales/latest/index.cjs +969 -0
- package/locales/latest/index.d.ts +92 -0
- package/locales/latest/index.js +948 -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 +9190 -0
- package/server/ES10/index.d.ts +925 -0
- package/server/ES10/index.js +9139 -0
- package/server/latest/index.cjs +8376 -0
- package/server/latest/index.d.ts +925 -0
- package/server/latest/index.js +8328 -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
package/{dist → ES10}/index.d.ts
RENAMED
|
@@ -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.
|
|
10
|
+
export const version = "1.4.5";
|
|
11
11
|
export function ExpandingDetails(props: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
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
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
117
|
-
|
|
117
|
+
width_?: number;
|
|
118
|
+
height_?: number;
|
|
118
119
|
}): SVGElement;
|
|
119
|
-
export function show_toast({
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
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
|
-
|
|
130
|
+
close_toast_: VoidFunction;
|
|
125
131
|
};
|
|
126
132
|
export type SDKGridSpacing = string | {
|
|
127
|
-
|
|
128
|
-
|
|
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
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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
|
-
|
|
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({
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
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
|
-
|
|
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
|
-
|
|
176
|
-
|
|
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
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
199
|
+
style?: JSX.CSSProperties;
|
|
200
|
+
height: string;
|
|
201
|
+
width: string;
|
|
202
|
+
class?: string;
|
|
191
203
|
}): JSX.Element;
|
|
192
204
|
interface FilterBodyProps {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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({
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
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
|
-
|
|
249
|
-
|
|
306
|
+
merchant: string;
|
|
307
|
+
market: string;
|
|
250
308
|
};
|
|
251
309
|
type PageURLCreatorCategoryData = {
|
|
252
|
-
|
|
253
|
-
|
|
310
|
+
type: "categories";
|
|
311
|
+
data: (BaseCategoryDisplay | CategorySuggestion)[];
|
|
254
312
|
};
|
|
255
313
|
type PageURLCreatorProductData<T extends ModernDisplay> = {
|
|
256
|
-
|
|
257
|
-
|
|
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
|
-
|
|
326
|
+
page_url: string;
|
|
274
327
|
}[]> : CanBePromiseWrapped<{
|
|
275
|
-
|
|
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
|
-
|
|
338
|
+
[key: string]: any;
|
|
293
339
|
}, ExtraOptionsProvidedOnOpen extends {
|
|
294
|
-
|
|
340
|
+
[key: string]: any;
|
|
295
341
|
}>(search_modal: (options: StaticOptions & ExtraOptionsProvidedOnOpen & {
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
301
|
-
|
|
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
|
-
|
|
305
|
-
|
|
306
|
-
|
|
350
|
+
is_replace: boolean;
|
|
351
|
+
new_url: URL;
|
|
352
|
+
scroll: boolean;
|
|
307
353
|
}) => void) | "hard_navigation";
|
|
308
354
|
export type ExclusiveId = {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
355
|
+
categoryId: string;
|
|
356
|
+
productId?: undefined;
|
|
357
|
+
productIds?: undefined;
|
|
312
358
|
} | {
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
359
|
+
categoryId?: undefined;
|
|
360
|
+
productId: string;
|
|
361
|
+
productIds?: undefined;
|
|
316
362
|
} | {
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
363
|
+
categoryId?: undefined;
|
|
364
|
+
productId?: undefined;
|
|
365
|
+
productIds: string[];
|
|
320
366
|
} | {
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
367
|
+
categoryId?: undefined;
|
|
368
|
+
productId?: undefined;
|
|
369
|
+
productIds?: undefined;
|
|
324
370
|
};
|
|
325
371
|
type RecsAPIWrapperOptions = {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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>({
|
|
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
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
422
|
+
index: number;
|
|
423
|
+
i18n: search_i18n;
|
|
424
|
+
merchant: string;
|
|
425
|
+
market: string;
|
|
375
426
|
}) => JSX.Element;
|
|
376
427
|
type CategorySuggestionAfterURLCreator = CategorySuggestion & {
|
|
377
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
} &
|
|
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
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
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: ({
|
|
435
|
-
|
|
436
|
-
|
|
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: ({
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
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
|
-
|
|
530
|
+
api: DepictAPI<InputDisplay, OutputDisplay>;
|
|
476
531
|
} & {
|
|
477
|
-
|
|
532
|
+
page_url_creator?: never;
|
|
533
|
+
display_transformers?: never;
|
|
478
534
|
};
|
|
479
535
|
type CategoryConstructorOptionsWithoutApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralCategoryListingOptions & {
|
|
480
|
-
|
|
481
|
-
} &
|
|
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
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
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
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
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>({
|
|
517
|
-
|
|
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>({
|
|
520
|
-
|
|
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
|
-
|
|
531
|
-
|
|
590
|
+
style?: JSX.CSSProperties;
|
|
591
|
+
class?: string;
|
|
532
592
|
};
|
|
533
593
|
type ImagePlaceholderBlockOptions = {
|
|
534
|
-
|
|
535
|
-
|
|
594
|
+
width: string;
|
|
595
|
+
height: string;
|
|
536
596
|
};
|
|
537
597
|
type ImagePlaceholderImageOptions = {
|
|
538
|
-
|
|
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
|
-
|
|
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
|
-
|
|
633
|
+
cleanup: () => void;
|
|
574
634
|
};
|
|
575
635
|
type GeneralConstructorOptions<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = {
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
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
|
-
|
|
650
|
+
api: DepictAPI<InputDisplay, OutputDisplay>;
|
|
590
651
|
} & {
|
|
591
|
-
|
|
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
|
-
|
|
595
|
-
} &
|
|
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
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
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
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
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
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
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
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
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
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
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
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
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
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
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
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
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
|
-
|
|
854
|
+
location?: "centered";
|
|
739
855
|
};
|
|
740
856
|
type AlignedLocation = {
|
|
741
|
-
|
|
742
|
-
|
|
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
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
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
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
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
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
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: ({
|
|
800
|
-
|
|
801
|
-
|
|
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";
|