@depict-ai/ui 1.0.17 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -7,10 +7,11 @@ import { SearchSuggestionsResponse, CategorySuggestion } from "@depict-ai/types/
7
7
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
8
8
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
9
9
  import { ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
10
- export const version = "1.0.17";
10
+ export const version = "1.1.0";
11
11
  export type OnNavigation = ((options: {
12
12
  is_replace: boolean;
13
13
  new_url: URL;
14
+ scroll: boolean;
14
15
  }) => void) | "hard_navigation";
15
16
  export type ExclusiveId = {
16
17
  categoryId: string;
@@ -251,6 +252,112 @@ export type SDKColsAtSize = [number, number?][];
251
252
  * @returns
252
253
  */
253
254
  export const convert_sdk_cols_at_size_to_layout: (cols_at_size: SDKColsAtSize) => ColsAtSize;
255
+ export type BaseProviderConfig = {
256
+ /**
257
+ * The merchant to use for the search.
258
+ * @example "YOUR_MERCHANT", "stronger"
259
+ */
260
+ merchant: string;
261
+ /**
262
+ * The market to use for the search.
263
+ * @example "YOUR_MARKET", "no", "en-de"
264
+ */
265
+ market: string;
266
+ /**
267
+ * Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
268
+ */
269
+ userId?: string;
270
+ /**
271
+ * Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
272
+ */
273
+ sessionId?: string;
274
+ /**
275
+ * Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
276
+ */
277
+ metaData?: Record<string, string>;
278
+ };
279
+ export type BaseSearchProviderConfig = {
280
+ /**
281
+ * The path to the search page.
282
+ * @example "/search", "/sok"
283
+ */
284
+ searchPagePath: string;
285
+ /**
286
+ * The name of the url parameter that will be used for the search query.
287
+ * @example "q", "search_query", "query"
288
+ * @default "query"
289
+ */
290
+ urlParamName?: string;
291
+ /**
292
+ * Whether to enable category suggestions in the search modal and search page.
293
+ * @default false
294
+ */
295
+ enableCategorySuggestions?: boolean;
296
+ };
297
+ export interface BaseProductListingConfig {
298
+ /**
299
+ * How many columns to show at each media size.
300
+ * @default
301
+ * [[2, 901], [3, 1024], [4]]
302
+ * @example
303
+ * [[2, 901], [3, 1024], [4]]
304
+ * means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.
305
+ */
306
+ columnsAtSize?: SDKColsAtSize;
307
+ /**
308
+ * The spacing between products.
309
+ * @default "2%"
310
+ * @example
311
+ * "2%", "10px", "1rem", {horizontal: "1%", vertical: "5px"}
312
+ */
313
+ gridSpacing?: SDKGridSpacing;
314
+ }
315
+ export interface BaseSearchPageConfig extends BaseProductListingConfig {
316
+ /**
317
+ * Whether to show the search input field in the search page.
318
+ * @default true
319
+ */
320
+ includeInputField?: boolean;
321
+ }
322
+ export interface BaseCategoryPageConfig extends BaseProductListingConfig {
323
+ /**
324
+ * Whether to show the breadcrumbs in the category page.
325
+ * @default true
326
+ */
327
+ showBreadcrumbs?: boolean;
328
+ /**
329
+ * Whether to show the quicklinks in the category page.
330
+ * @default true
331
+ */
332
+ showQuicklinks?: boolean;
333
+ }
334
+ /**
335
+ * Props for the TextPlaceholder component.
336
+ */
337
+ export interface TextPlaceholderProps {
338
+ /**
339
+ * The height of the text, including a unit.
340
+ * @example "1em"
341
+ */
342
+ height: string;
343
+ /**
344
+ * The width of the text.
345
+ * @example "60px", "10em"
346
+ */
347
+ width: string;
348
+ }
349
+ /**
350
+ * Props for the ImagePlaceholder component.
351
+ */
352
+ export interface ImagePlaceholderProps {
353
+ /** The aspect ratio of the image that will be displayed. */
354
+ aspectRatio: number;
355
+ }
356
+ /**
357
+ * Will be sent to backend to indicate whether the query_id_ is for a collection or category.
358
+ * Backend defaults to category if not specified.
359
+ */
360
+ type ListingType = "collection" | "category";
254
361
  type DepictCategoryConstructorOptions = {
255
362
  market: string;
256
363
  merchant: string;
@@ -268,6 +375,8 @@ export class DepictCategory {
268
375
  set merchant(merchant: string);
269
376
  get market(): string;
270
377
  set market(market: string);
378
+ get listing_type(): ListingType | undefined;
379
+ set listing_type(listing_type: ListingType | undefined);
271
380
  get on_navigation(): OnNavigation;
272
381
  set on_navigation(new_function: OnNavigation);
273
382
  constructor({ api, on_navigation, ...props_on_class }: DepictCategoryConstructorOptions);
@@ -352,7 +461,7 @@ export class DepictSearch<T extends Display> {
352
461
  set market(market: string);
353
462
  fetchSearchResults(query: string, filters?: SearchFilter[], maxResults?: number): Promise<T[]>;
354
463
  }
355
- export function SearchPage<T extends Display>({ depict_search, include_input_field, grid_spacing, cols_at_size, product_card_template, extra_depict_options, }: {
464
+ export function SearchPage<T extends Display>(props: {
356
465
  depict_search: DepictSearch<T>;
357
466
  include_input_field?: boolean | {
358
467
  on_open_?: VoidFunction;
@@ -372,107 +481,6 @@ interface SearchFieldParams {
372
481
  aligner_ref?: HTMLElement | null;
373
482
  }
374
483
  export function SearchField({ depict_search, modal_dispose_handler, click_handler, aligner_ref, }: SearchFieldParams): import("@depict-ai/utilishared").Node_Array;
375
- export type BaseProviderConfig = {
376
- /**
377
- * The merchant to use for the search.
378
- * @example "YOUR_MERCHANT", "stronger"
379
- */
380
- merchant: string;
381
- /**
382
- * The market to use for the search.
383
- * @example "YOUR_MARKET", "no", "en-de"
384
- */
385
- market: string;
386
- /**
387
- * Optional unique identifier of a logged in user. Should be persistent across devices and sessions.
388
- */
389
- userId?: string;
390
- /**
391
- * Optional unique identifer of the current session. Only necessary when performing server side requests to Depict.
392
- */
393
- sessionId?: string;
394
- /**
395
- * Custom metadata to be sent with each request to the Depict API. Only necessary if specifically instructed by Depict.
396
- */
397
- metaData?: Record<string, string>;
398
- };
399
- export type BaseSearchProviderConfig = {
400
- /**
401
- * The path to the search page.
402
- * @example "/search", "/sok"
403
- */
404
- searchPagePath: string;
405
- /**
406
- * The name of the url parameter that will be used for the search query.
407
- * @example "q", "search_query", "query"
408
- * @default "query"
409
- */
410
- urlParamName?: string;
411
- /**
412
- * Whether to enable category suggestions in the search modal and search page.
413
- * @default false
414
- */
415
- enableCategorySuggestions?: boolean;
416
- };
417
- export interface BaseProductListingConfig {
418
- /**
419
- * How many columns to show at each media size.
420
- * @default
421
- * [[2, 901], [3, 1024], [4]]
422
- * @example
423
- * [[2, 901], [3, 1024], [4]]
424
- * means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any viewport size.
425
- */
426
- columnsAtSize?: SDKColsAtSize;
427
- /**
428
- * The spacing between products.
429
- * @default "2%"
430
- * @example
431
- * "2%", "10px", "1rem", {horizontal: "1%", vertical: "5px"}
432
- */
433
- gridSpacing?: SDKGridSpacing;
434
- }
435
- export interface BaseSearchPageConfig extends BaseProductListingConfig {
436
- /**
437
- * Whether to show the search input field in the search page.
438
- * @default true
439
- */
440
- includeInputField?: boolean;
441
- }
442
- export interface BaseCategoryPageConfig extends BaseProductListingConfig {
443
- /**
444
- * Whether to show the breadcrumbs in the category page.
445
- * @default true
446
- */
447
- showBreadcrumbs?: boolean;
448
- /**
449
- * Whether to show the quicklinks in the category page.
450
- * @default true
451
- */
452
- showQuicklinks?: boolean;
453
- }
454
- /**
455
- * Props for the TextPlaceholder component.
456
- */
457
- export interface TextPlaceholderProps {
458
- /**
459
- * The height of the text, including a unit.
460
- * @example "1em"
461
- */
462
- height: string;
463
- /**
464
- * The width of the text.
465
- * @example "60px", "10em"
466
- */
467
- width: string;
468
- }
469
- /**
470
- * Props for the ImagePlaceholder component.
471
- */
472
- export interface ImagePlaceholderProps {
473
- /** The aspect ratio of the image that will be displayed. */
474
- aspectRatio: number;
475
- }
476
484
  type CenteredLocation = {
477
485
  location?: "centered";
478
486
  };
package/dist/main.js CHANGED
@@ -37,7 +37,7 @@ $parcel$export(module.exports, "defaultGridSpacing", () => $a3280f0aad997933$exp
37
37
  $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$export$c3834fa86c616831);
38
38
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
39
39
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
40
- /*! Depict.ai search and product listing SDK */ const $b757f75811f3261f$export$83d89fbfd8236492 = "1.0.17";
40
+ /*! Depict.ai search and product listing SDK */ const $b757f75811f3261f$export$83d89fbfd8236492 = "1.1.0";
41
41
 
42
42
 
43
43
 
@@ -179,10 +179,23 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
179
179
  let resolve_in_progress;
180
180
  cache_obj.in_progress_[body] = new Promise((r)=>resolve_in_progress = r);
181
181
  try {
182
- const search_results = await (0, $iBTHO$depictaiutilishared.fetch_retry)((0, $iBTHO$depictaiutilishared.add_version_query_params)(endpoint1), {
182
+ let search_results = await (0, $iBTHO$depictaiutilishared.fetch_retry)((0, $iBTHO$depictaiutilishared.add_version_query_params)(endpoint1), {
183
183
  method: "POST",
184
184
  body: body
185
185
  });
186
+ if ("query_id" in request && request.type === "collection") // FIXME: Remove. Backwards compatibility layer
187
+ // This will retry the request without the collection type if the first request fails
188
+ {
189
+ if (!search_results || search_results?.status === 404) {
190
+ (0, $iBTHO$depictaiutilishared.dlog)("Fallback request for collections due to failure");
191
+ const fallback_body = JSON.parse(body);
192
+ delete fallback_body.type;
193
+ search_results = await (0, $iBTHO$depictaiutilishared.fetch_retry)((0, $iBTHO$depictaiutilishared.add_version_query_params)(endpoint1), {
194
+ method: "POST",
195
+ body: JSON.stringify(fallback_body)
196
+ });
197
+ }
198
+ }
186
199
  if (!search_results || search_results.status !== 200) {
187
200
  const retval = fallback_response(input_req);
188
201
  resolve_in_progress(retval);
@@ -5006,7 +5019,7 @@ function $cafad5eca9f09cb5$export$d4fc5c0e68a52116(el, query_id_, i18n_) {
5006
5019
 
5007
5020
 
5008
5021
  const $840d88a04b2d22a7$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div class="product-count"> </div>`, 2), $840d88a04b2d22a7$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div></div>`, 2), $840d88a04b2d22a7$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div class="filter-results-for-one-row"></div>`, 2), $840d88a04b2d22a7$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div class="depict plp category"><div class="listing-page"></div></div>`, 4);
5009
- function $840d88a04b2d22a7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ , sideways_filter_clearing_flag_: sideways_filter_clearing_flag_ }) {
5022
+ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , listing_type_: listing_type_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ , sideways_filter_clearing_flag_: sideways_filter_clearing_flag_ }) {
5010
5023
  let results_for;
5011
5024
  let only_show_filters_opener_;
5012
5025
  let middle_elements_;
@@ -5031,6 +5044,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
5031
5044
  tenant: tenant_(),
5032
5045
  market: market_(),
5033
5046
  query_id: query_id_(),
5047
+ type: listing_type_(),
5034
5048
  ...f.length ? {
5035
5049
  filters: f
5036
5050
  } : {},
@@ -5532,7 +5546,8 @@ function $c79fd10a3ab7d6e0$export$477caf01aecaeb2a(options) {
5532
5546
  router_.navigate_.go_to_({
5533
5547
  is_replace_: true,
5534
5548
  new_url_: url_object.href,
5535
- force_spa_navigation_: true
5549
+ force_spa_navigation_: true,
5550
+ scroll: false
5536
5551
  });
5537
5552
  }, {
5538
5553
  defer: true
@@ -5592,7 +5607,7 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
5592
5607
  * @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
5593
5608
  * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
5594
5609
  * @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
5595
- */ go_to_: (0, $iBTHO$depictaiutilishared.catchify)(async ({ new_url_: raw_new_url , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
5610
+ */ go_to_: (0, $iBTHO$depictaiutilishared.catchify)(async ({ new_url_: raw_new_url , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ , scroll: scroll = true })=>{
5596
5611
  const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
5597
5612
  const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
5598
5613
  if (this.#dont_attempt_navigation(event_)) return;
@@ -5614,7 +5629,8 @@ class $e96dd13889871fc0$export$7e1297a3a19f10d8 {
5614
5629
  history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
5615
5630
  } else this.#throwing_on_navigation.call(this, {
5616
5631
  is_replace: is_replace_,
5617
- new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin)
5632
+ new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin),
5633
+ scroll: scroll
5618
5634
  });
5619
5635
  await promise;
5620
5636
  })
@@ -5640,6 +5656,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
5640
5656
  #merchant_signal = (0, $iBTHO$solidjs.createSignal)();
5641
5657
  #market_signal = (0, $iBTHO$solidjs.createSignal)();
5642
5658
  #query_id_signal = (0, $iBTHO$solidjs.createSignal)("");
5659
+ #listing_type_signal = (0, $iBTHO$solidjs.createSignal)();
5643
5660
  static #has_been_constructed = false;
5644
5661
  get localization() {
5645
5662
  // allow reactive access
@@ -5666,6 +5683,12 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
5666
5683
  set market(market) {
5667
5684
  this.#market_signal[1](market);
5668
5685
  }
5686
+ get listing_type() {
5687
+ return this.#listing_type_signal[0]();
5688
+ }
5689
+ set listing_type(listing_type) {
5690
+ this.#listing_type_signal[1](listing_type);
5691
+ }
5669
5692
  get on_navigation() {
5670
5693
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
5671
5694
  return this.#router.on_navigation_;
@@ -5731,6 +5754,7 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e({ depict_category: depict_cat
5731
5754
  min_products_to_fetch_: $48567ac5b39bac56$var$min_products_to_fetch_,
5732
5755
  local_filter_cache_: local_filter_cache_,
5733
5756
  query_id_: ()=>depict_category.category_id,
5757
+ listing_type_: ()=>depict_category.listing_type,
5734
5758
  i18n_: i18n_,
5735
5759
  show_quicklinks_: show_quicklinks,
5736
5760
  category_title_: category_title,
@@ -7630,9 +7654,28 @@ function $65a0c4b1c2eb5d0b$export$9dd50d35b9d94fdf({ get_search_query_: get_sear
7630
7654
 
7631
7655
 
7632
7656
 
7657
+
7658
+
7659
+ function $2005eec80e40088f$export$41b4894022a3580f({ style_props_: style_props_ = (0, $iBTHO$solidjs.createSignal)({}) } = {}) {
7660
+ const [, set_style_props] = style_props_;
7661
+ const supports_hover = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(hover: hover) and (pointer: fine)");
7662
+ const desktop_short = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(max-height: 790px)");
7663
+ const mobile_short = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(max-height: 1000px)");
7664
+ const transform_y = (0, $iBTHO$solidjs.createMemo)(()=>supports_hover() ? !desktop_short() : !mobile_short());
7665
+ set_style_props({
7666
+ position: "fixed",
7667
+ top: "50%"
7668
+ });
7669
+ (0, $iBTHO$solidjs.createComputed)(()=>set_style_props((old_value)=>({
7670
+ ...old_value,
7671
+ transform: transform_y() ? "translateY(-50%)" : "unset"
7672
+ })));
7673
+ return style_props_;
7674
+ }
7675
+
7676
+
7633
7677
  const $f1d7cb69f839a526$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div class="filter-results-for-one-row"></div>`, 2), $f1d7cb69f839a526$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div class="depict plp search"><div class="listing-page"></div></div>`, 4);
7634
- function $f1d7cb69f839a526$export$a54ec244c8863715(opts) {
7635
- const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , get_search_query_: get_search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , search_recs_view_more_: search_recs_view_more_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ } = opts;
7678
+ function $f1d7cb69f839a526$export$a54ec244c8863715({ depict_api_: depict_api_ , search_field_value_: search_field_value_ , get_search_query_: get_search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , search_recs_view_more_: search_recs_view_more_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ , modal_body_style_ref_: modal_body_style_ref_ }) {
7636
7679
  const [get_sorting] = current_sorting_;
7637
7680
  const all_products_loaded_ = (0, $iBTHO$solidjs.createSignal)(false);
7638
7681
  const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
@@ -7685,42 +7728,8 @@ function $f1d7cb69f839a526$export$a54ec244c8863715(opts) {
7685
7728
  })));
7686
7729
  const available_filters_ = (0, $iBTHO$solidjs.createMemo)(()=>search_results_()?.filters);
7687
7730
  const modal_body_style = (0, $iBTHO$solidjs.createSignal)({});
7688
- let search_field;
7689
- if (include_input_field_) {
7690
- const SafeSearchField = (0, $iBTHO$depictaiutilishared.catchify)((0, $66b8b9a9613c141d$export$b94867ecbd698f21));
7691
- let input_element;
7692
- let div_with_field_class;
7693
- search_field = SafeSearchField({
7694
- i18n_: i18n_,
7695
- search_field_value_: search_field_value_,
7696
- submit_query_: submit_query_,
7697
- clear_filters_: clear_filters_on_next_submit_,
7698
- input_field_ref_: (el)=>input_element = el,
7699
- field_element_ref_: (el)=>div_with_field_class = el,
7700
- disabled_: true
7701
- });
7702
- if (search_field) {
7703
- opts?.modal_body_style_ref_?.(modal_body_style);
7704
- const align_position = (0, $iBTHO$depictaiutilishared.catchify)((0, $fd463ff0edb29915$export$b3ad617e9036868))(modal_body_style, search_field, undefined, true);
7705
- div_with_field_class.addEventListener("click", (0, $iBTHO$depictaiutilishared.catchify)((e)=>{
7706
- const target = e.target;
7707
- const sel = ".submit";
7708
- if (target?.matches?.(sel) || target?.closest?.(sel)) // the search button is just decor, don't do anything when clicked
7709
- return;
7710
- // When selecting text in the SearchField that's in the page we want the same selection to persist. It doesn't by itself, since the SearchModal has an entirely different SearchField. Therefore, we manually copy the selection over.
7711
- const selected_text_range_ = [
7712
- input_element.selectionStart,
7713
- input_element.selectionEnd
7714
- ];
7715
- align_position?.();
7716
- open_modal_({
7717
- style_props_: modal_body_style,
7718
- selected_text_range_: selected_text_range_
7719
- }, ()=>include_input_field_?.on_close_?.());
7720
- include_input_field_?.on_open_?.();
7721
- }));
7722
- }
7723
- }
7731
+ const [get_search_field_elements, set_search_field_elements] = (0, $iBTHO$solidjs.createSignal)();
7732
+ const SafeSearchField = (0, $iBTHO$depictaiutilishared.catchify)((0, $66b8b9a9613c141d$export$b94867ecbd698f21));
7724
7733
  const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $iBTHO$solidjs.createSignal)(false);
7725
7734
  const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $iBTHO$solidjs.createSignal)();
7726
7735
  const formatted_number_of_results_ = (0, $0f400c3f7248d5f1$export$92f2da32c6e7e7ee)({
@@ -7784,11 +7793,60 @@ function $f1d7cb69f839a526$export$a54ec244c8863715(opts) {
7784
7793
  get_search_query_();
7785
7794
  (0, $341a019928b8b91e$export$c7e181728ad525f)(location);
7786
7795
  });
7796
+ (0, $iBTHO$solidjs.createEffect)(()=>{
7797
+ // reactive include_input_field
7798
+ // this uses ~7 variables from outer scope which is why I didn't refactor it into a function
7799
+ add_input_field: {
7800
+ const input_field_accessor_value = include_input_field_?.() ?? true; // default to showing input field
7801
+ if (!input_field_accessor_value) break add_input_field;
7802
+ let input_element;
7803
+ let div_with_field_class;
7804
+ const search_field = SafeSearchField({
7805
+ i18n_: i18n_,
7806
+ search_field_value_: search_field_value_,
7807
+ submit_query_: submit_query_,
7808
+ clear_filters_: clear_filters_on_next_submit_,
7809
+ input_field_ref_: (el)=>input_element = el,
7810
+ field_element_ref_: (el)=>div_with_field_class = el,
7811
+ disabled_: true
7812
+ });
7813
+ if (!search_field) break add_input_field;
7814
+ modal_body_style[1]({});
7815
+ modal_body_style_ref_?.(modal_body_style);
7816
+ const align_position = (0, $iBTHO$depictaiutilishared.catchify)((0, $fd463ff0edb29915$export$b3ad617e9036868))(modal_body_style, search_field, undefined, true);
7817
+ div_with_field_class.addEventListener("click", (0, $iBTHO$depictaiutilishared.catchify)((e)=>{
7818
+ const target = e.target;
7819
+ const sel = ".submit";
7820
+ if (target?.matches?.(sel) || target?.closest?.(sel)) // the search button is just decor, don't do anything when clicked
7821
+ return;
7822
+ // When selecting text in the SearchField that's in the page we want the same selection to persist. It doesn't by itself, since the SearchModal has an entirely different SearchField. Therefore, we manually copy the selection over.
7823
+ const selected_text_range_ = [
7824
+ input_element.selectionStart,
7825
+ input_element.selectionEnd
7826
+ ];
7827
+ align_position?.();
7828
+ open_modal_({
7829
+ style_props_: modal_body_style,
7830
+ selected_text_range_: selected_text_range_
7831
+ }, ()=>input_field_accessor_value?.on_close_?.());
7832
+ input_field_accessor_value?.on_open_?.();
7833
+ }));
7834
+ set_search_field_elements(search_field);
7835
+ return;
7836
+ }
7837
+ // We bailed out of adding the input field
7838
+ set_search_field_elements();
7839
+ // There *might* still be a modal open, either from depict_search.modal_open = true or clicking the SearchField which existed here. Said modal now doesn't have anything to align to anymore - it will still try to align to the style_props_ which it got through the modal_body_style_ref_ which are now no longer updated.
7840
+ // In that case, we write what's needed to center the modal to the modal_body_style for the lifetime of this effect function call to make sure the modal is centered and the UI doesn't look "botched".
7841
+ (0, $2005eec80e40088f$export$41b4894022a3580f)({
7842
+ style_props_: modal_body_style
7843
+ });
7844
+ });
7787
7845
  return [
7788
7846
  document.createComment("Search page based on Depict SDK"),
7789
7847
  (()=>{
7790
7848
  const _el$2 = $f1d7cb69f839a526$var$_tmpl$2.cloneNode(true), _el$3 = _el$2.firstChild;
7791
- (0, $iBTHO$solidjsweb.insert)(_el$3, search_field, null);
7849
+ (0, $iBTHO$solidjsweb.insert)(_el$3, get_search_field_elements, null);
7792
7850
  (0, $iBTHO$solidjsweb.insert)(_el$3, make_category_suggestion_card_ ? (0, $iBTHO$solidjsweb.createComponent)((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7793
7851
  severity_: "error",
7794
7852
  message_: "Category suggestions failed",
@@ -7916,7 +7974,6 @@ function $f1d7cb69f839a526$export$a54ec244c8863715(opts) {
7916
7974
 
7917
7975
 
7918
7976
 
7919
-
7920
7977
  function $d8e94ea381ab57fa$export$828dcdd425fd3231(aligner) {
7921
7978
  const style_element = document.createElement("style");
7922
7979
  document.head.append(style_element);
@@ -7941,6 +7998,7 @@ function $d8e94ea381ab57fa$export$828dcdd425fd3231(aligner) {
7941
7998
 
7942
7999
 
7943
8000
 
8001
+
7944
8002
  const $2c61e4cd8229c49a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$iBTHO$solidjsweb.template)(`<div class="depict plp search"></div>`, 2);
7945
8003
  /**
7946
8004
  * Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
@@ -8083,18 +8141,7 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
8083
8141
  return;
8084
8142
  }
8085
8143
  // Open centered modal
8086
- const supports_hover = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(hover: hover) and (pointer: fine)");
8087
- const desktop_short = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(max-height: 790px)");
8088
- const mobile_short = (0, $b54e6192d0caa293$export$d9f36cf74e24d595)("(max-height: 1000px)");
8089
- const transform_y = (0, $iBTHO$solidjs.createMemo)(()=>supports_hover() ? !desktop_short() : !mobile_short());
8090
- const style_props_ = (0, $iBTHO$solidjs.createSignal)({
8091
- position: "fixed",
8092
- top: "50%"
8093
- });
8094
- (0, $iBTHO$solidjs.createComputed)(()=>style_props_[1]((old_value)=>({
8095
- ...old_value,
8096
- transform: transform_y() ? "translateY(-50%)" : "unset"
8097
- })));
8144
+ const style_props_ = (0, $2005eec80e40088f$export$41b4894022a3580f)();
8098
8145
  if (signal_value_is_options) {
8099
8146
  const [options_arg, ...rest] = open_signal_value;
8100
8147
  open_modal_({
@@ -8162,7 +8209,8 @@ function $2c61e4cd8229c49a$var$get_shared_properties(depict_search) {
8162
8209
  if (!shared_properties) throw new Error("Can't connect to provided DepictSearch instance");
8163
8210
  return shared_properties;
8164
8211
  }
8165
- function $2c61e4cd8229c49a$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , extra_depict_options: extra_depict_options }) {
8212
+ function $2c61e4cd8229c49a$export$f2dc7e4e4aa11abb(props) {
8213
+ const { depict_search: depict_search , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , extra_depict_options: extra_depict_options } = props;
8166
8214
  const shared_properties = $2c61e4cd8229c49a$var$get_shared_properties(depict_search);
8167
8215
  const grid_spacing_override = typeof grid_spacing === "string" ? {
8168
8216
  grid_spacing: grid_spacing
@@ -8216,7 +8264,7 @@ function $2c61e4cd8229c49a$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
8216
8264
  selected_filters_: shared_properties.selected_filters_,
8217
8265
  showing_recommendation_rows_: state_.search_showing_recommendation_rows,
8218
8266
  scroll_restoration_data_: state_.search_scroll_restoration_data,
8219
- include_input_field_: include_input_field,
8267
+ include_input_field_: ()=>props.include_input_field,
8220
8268
  layout_options_: {
8221
8269
  cols_at_size: (0, $4e04be41243c3d80$export$6daf8749b65a1b77)(cols_at_size),
8222
8270
  ...grid_spacing_override