@depict-ai/ui 1.0.18 → 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/module.js CHANGED
@@ -2,7 +2,7 @@ import {add_to_version_info as $kyEB6$add_to_version_info, fetch_recs as $kyEB6$
2
2
  import {template as $kyEB6$template, insert as $kyEB6$insert, effect as $kyEB6$effect, setAttribute as $kyEB6$setAttribute, createComponent as $kyEB6$createComponent, use as $kyEB6$use, memo as $kyEB6$memo, addEventListener as $kyEB6$addEventListener, delegateEvents as $kyEB6$delegateEvents, spread as $kyEB6$spread, classList as $kyEB6$classList, style as $kyEB6$style, Dynamic as $kyEB6$Dynamic, mergeProps as $kyEB6$mergeProps, className as $kyEB6$className} from "solid-js/web";
3
3
  import {createSignal as $kyEB6$createSignal, getOwner as $kyEB6$getOwner, createRoot as $kyEB6$createRoot, runWithOwner as $kyEB6$runWithOwner, onCleanup as $kyEB6$onCleanup, createComputed as $kyEB6$createComputed, createRenderEffect as $kyEB6$createRenderEffect, createEffect as $kyEB6$createEffect, untrack as $kyEB6$untrack, batch as $kyEB6$batch, createResource as $kyEB6$createResource, createMemo as $kyEB6$createMemo, Show as $kyEB6$Show, createReaction as $kyEB6$createReaction, Suspense as $kyEB6$Suspense, on as $kyEB6$on, ErrorBoundary as $kyEB6$ErrorBoundary, For as $kyEB6$For, Index as $kyEB6$Index} from "solid-js";
4
4
 
5
- /*! Depict.ai search and product listing SDK */ const $ec291e0010116877$export$83d89fbfd8236492 = "1.0.9";
5
+ /*! Depict.ai search and product listing SDK */ const $ec291e0010116877$export$83d89fbfd8236492 = "1.1.0";
6
6
 
7
7
 
8
8
 
@@ -144,10 +144,23 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
144
144
  let resolve_in_progress;
145
145
  cache_obj.in_progress_[body] = new Promise((r)=>resolve_in_progress = r);
146
146
  try {
147
- const search_results = await (0, $kyEB6$fetch_retry)((0, $kyEB6$add_version_query_params)(endpoint1), {
147
+ let search_results = await (0, $kyEB6$fetch_retry)((0, $kyEB6$add_version_query_params)(endpoint1), {
148
148
  method: "POST",
149
149
  body: body
150
150
  });
151
+ if ("query_id" in request && request.type === "collection") // FIXME: Remove. Backwards compatibility layer
152
+ // This will retry the request without the collection type if the first request fails
153
+ {
154
+ if (!search_results || search_results?.status === 404) {
155
+ (0, $kyEB6$dlog)("Fallback request for collections due to failure");
156
+ const fallback_body = JSON.parse(body);
157
+ delete fallback_body.type;
158
+ search_results = await (0, $kyEB6$fetch_retry)((0, $kyEB6$add_version_query_params)(endpoint1), {
159
+ method: "POST",
160
+ body: JSON.stringify(fallback_body)
161
+ });
162
+ }
163
+ }
151
164
  if (!search_results || search_results.status !== 200) {
152
165
  const retval = fallback_response(input_req);
153
166
  resolve_in_progress(retval);
@@ -960,22 +973,17 @@ function $29ec7cddbe1d3484$export$43f0fb951fcb0c54({ displays_by_key_: displays_
960
973
  ];
961
974
  },
962
975
  children: (product_id, index)=>{
963
- // We're using `untrack` here since we don't want to react in here to displays_by_key changing
964
- // As long as our key stays the same we assume that the display hasn't changed, so we don't want to rerender
965
- // If the key gets removed, <For> will remove us
966
976
  const owner = (0, $kyEB6$getOwner)();
967
977
  const display_accessor = (0, $kyEB6$createMemo)(()=>displays_by_key_().get(product_id));
968
- const [product_card_resource] = (0, $kyEB6$createResource)((0, $kyEB6$createMemo)(()=>[
969
- merchant_(),
970
- market_()
971
- ]), // re-render when merchant or market changes
972
- ([merchant, market])=>{
978
+ const [product_card_resource] = (0, $kyEB6$createResource)(display_accessor, // re-render when the reference to the display object changes
979
+ // this should only be the case when the merchant or market changes and the new request has completed
980
+ (display)=>{
973
981
  // get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
974
- const display = (0, $kyEB6$untrack)(display_accessor);
975
982
  return product_card_template_(display, {
976
983
  set_on_index_change: (fn)=>(0, $kyEB6$runWithOwner)(owner, ()=>(0, $kyEB6$createEffect)(()=>fn(index()))),
977
- merchant: merchant,
978
- market: market
984
+ merchant: (0, $kyEB6$untrack)(merchant_),
985
+ // this means that the merchant and market provided to the template is wrong while we do another fetch, but I don't see how anyone would need to know the correct market there
986
+ market: (0, $kyEB6$untrack)(market_)
979
987
  });
980
988
  });
981
989
  const node_accessor = (0, $a52235d12ccf9c88$export$2f0cbfbb4354bb52)(product_card_resource);
@@ -4976,7 +4984,7 @@ function $eb9ba2e49ab3dcc2$export$d4fc5c0e68a52116(el, query_id_, i18n_) {
4976
4984
 
4977
4985
 
4978
4986
  const $df5d81d0fe61ff21$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div class="product-count"> </div>`, 2), $df5d81d0fe61ff21$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div></div>`, 2), $df5d81d0fe61ff21$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div class="filter-results-for-one-row"></div>`, 2), $df5d81d0fe61ff21$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div class="depict plp category"><div class="listing-page"></div></div>`, 4);
4979
- function $df5d81d0fe61ff21$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_ }) {
4987
+ function $df5d81d0fe61ff21$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_ }) {
4980
4988
  let results_for;
4981
4989
  let only_show_filters_opener_;
4982
4990
  let middle_elements_;
@@ -5001,6 +5009,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
5001
5009
  tenant: tenant_(),
5002
5010
  market: market_(),
5003
5011
  query_id: query_id_(),
5012
+ type: listing_type_(),
5004
5013
  ...f.length ? {
5005
5014
  filters: f
5006
5015
  } : {},
@@ -5502,7 +5511,8 @@ function $ccd5db07a3a069c5$export$477caf01aecaeb2a(options) {
5502
5511
  router_.navigate_.go_to_({
5503
5512
  is_replace_: true,
5504
5513
  new_url_: url_object.href,
5505
- force_spa_navigation_: true
5514
+ force_spa_navigation_: true,
5515
+ scroll: false
5506
5516
  });
5507
5517
  }, {
5508
5518
  defer: true
@@ -5562,7 +5572,7 @@ class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
5562
5572
  * @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
5563
5573
  * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
5564
5574
  * @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
5565
- */ go_to_: (0, $kyEB6$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_ })=>{
5575
+ */ go_to_: (0, $kyEB6$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 })=>{
5566
5576
  const new_url_ = raw_new_url instanceof URL ? raw_new_url : new URL(raw_new_url, location.origin);
5567
5577
  const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
5568
5578
  if (this.#dont_attempt_navigation(event_)) return;
@@ -5584,7 +5594,8 @@ class $4fd2ba03703a7d92$export$7e1297a3a19f10d8 {
5584
5594
  history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
5585
5595
  } else this.#throwing_on_navigation.call(this, {
5586
5596
  is_replace: is_replace_,
5587
- new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin)
5597
+ new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin),
5598
+ scroll: scroll
5588
5599
  });
5589
5600
  await promise;
5590
5601
  })
@@ -5610,6 +5621,7 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
5610
5621
  #merchant_signal = (0, $kyEB6$createSignal)();
5611
5622
  #market_signal = (0, $kyEB6$createSignal)();
5612
5623
  #query_id_signal = (0, $kyEB6$createSignal)("");
5624
+ #listing_type_signal = (0, $kyEB6$createSignal)();
5613
5625
  static #has_been_constructed = false;
5614
5626
  get localization() {
5615
5627
  // allow reactive access
@@ -5636,6 +5648,12 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
5636
5648
  set market(market) {
5637
5649
  this.#market_signal[1](market);
5638
5650
  }
5651
+ get listing_type() {
5652
+ return this.#listing_type_signal[0]();
5653
+ }
5654
+ set listing_type(listing_type) {
5655
+ this.#listing_type_signal[1](listing_type);
5656
+ }
5639
5657
  get on_navigation() {
5640
5658
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
5641
5659
  return this.#router.on_navigation_;
@@ -5701,6 +5719,7 @@ function $961b5c64bef4662f$export$e2bf8ce7779e827e({ depict_category: depict_cat
5701
5719
  min_products_to_fetch_: $961b5c64bef4662f$var$min_products_to_fetch_,
5702
5720
  local_filter_cache_: local_filter_cache_,
5703
5721
  query_id_: ()=>depict_category.category_id,
5722
+ listing_type_: ()=>depict_category.listing_type,
5704
5723
  i18n_: i18n_,
5705
5724
  show_quicklinks_: show_quicklinks,
5706
5725
  category_title_: category_title,
@@ -6422,7 +6441,8 @@ const $e003be2a50d9e5bc$export$b05c0ae390cf3e06 = (display_or_variant_container,
6422
6441
  sizes: "0px"
6423
6442
  }));
6424
6443
  const is_sale = (0, $kyEB6$createMemo)(()=>display().sale_price !== display().original_price);
6425
- const href = (0, $kyEB6$createMemo)(()=>display().page_url);
6444
+ // localized_page_url currently only used by MayaDelorez, but potentially more. Convenience to avoid requireing full frontend URL transformation.
6445
+ const href = (0, $kyEB6$createMemo)(()=>display().localized_page_url || display().page_url);
6426
6446
  return (()=>{
6427
6447
  const _el$ = $e003be2a50d9e5bc$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$4.nextSibling, _el$9 = _el$7.firstChild;
6428
6448
  (0, $kyEB6$addEventListener)(_el$, "click", (0, $kyEB6$catchify)((event_)=>router_.navigate_.go_to_({
@@ -7599,9 +7619,28 @@ function $f8c929beb82c512b$export$9dd50d35b9d94fdf({ get_search_query_: get_sear
7599
7619
 
7600
7620
 
7601
7621
 
7622
+
7623
+
7624
+ function $1801dbce7adb3f19$export$41b4894022a3580f({ style_props_: style_props_ = (0, $kyEB6$createSignal)({}) } = {}) {
7625
+ const [, set_style_props] = style_props_;
7626
+ const supports_hover = (0, $dc9262ef6f786812$export$d9f36cf74e24d595)("(hover: hover) and (pointer: fine)");
7627
+ const desktop_short = (0, $dc9262ef6f786812$export$d9f36cf74e24d595)("(max-height: 790px)");
7628
+ const mobile_short = (0, $dc9262ef6f786812$export$d9f36cf74e24d595)("(max-height: 1000px)");
7629
+ const transform_y = (0, $kyEB6$createMemo)(()=>supports_hover() ? !desktop_short() : !mobile_short());
7630
+ set_style_props({
7631
+ position: "fixed",
7632
+ top: "50%"
7633
+ });
7634
+ (0, $kyEB6$createComputed)(()=>set_style_props((old_value)=>({
7635
+ ...old_value,
7636
+ transform: transform_y() ? "translateY(-50%)" : "unset"
7637
+ })));
7638
+ return style_props_;
7639
+ }
7640
+
7641
+
7602
7642
  const $7097477c78a89208$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div class="filter-results-for-one-row"></div>`, 2), $7097477c78a89208$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div class="depict plp search"><div class="listing-page"></div></div>`, 4);
7603
- function $7097477c78a89208$export$a54ec244c8863715(opts) {
7604
- 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;
7643
+ function $7097477c78a89208$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_ }) {
7605
7644
  const [get_sorting] = current_sorting_;
7606
7645
  const all_products_loaded_ = (0, $kyEB6$createSignal)(false);
7607
7646
  const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
@@ -7654,42 +7693,8 @@ function $7097477c78a89208$export$a54ec244c8863715(opts) {
7654
7693
  })));
7655
7694
  const available_filters_ = (0, $kyEB6$createMemo)(()=>search_results_()?.filters);
7656
7695
  const modal_body_style = (0, $kyEB6$createSignal)({});
7657
- let search_field;
7658
- if (include_input_field_) {
7659
- const SafeSearchField = (0, $kyEB6$catchify)((0, $5285d2814d0fac0c$export$b94867ecbd698f21));
7660
- let input_element;
7661
- let div_with_field_class;
7662
- search_field = SafeSearchField({
7663
- i18n_: i18n_,
7664
- search_field_value_: search_field_value_,
7665
- submit_query_: submit_query_,
7666
- clear_filters_: clear_filters_on_next_submit_,
7667
- input_field_ref_: (el)=>input_element = el,
7668
- field_element_ref_: (el)=>div_with_field_class = el,
7669
- disabled_: true
7670
- });
7671
- if (search_field) {
7672
- opts?.modal_body_style_ref_?.(modal_body_style);
7673
- const align_position = (0, $kyEB6$catchify)((0, $b6d5529b253681aa$export$b3ad617e9036868))(modal_body_style, search_field, undefined, true);
7674
- div_with_field_class.addEventListener("click", (0, $kyEB6$catchify)((e)=>{
7675
- const target = e.target;
7676
- const sel = ".submit";
7677
- if (target?.matches?.(sel) || target?.closest?.(sel)) // the search button is just decor, don't do anything when clicked
7678
- return;
7679
- // 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.
7680
- const selected_text_range_ = [
7681
- input_element.selectionStart,
7682
- input_element.selectionEnd
7683
- ];
7684
- align_position?.();
7685
- open_modal_({
7686
- style_props_: modal_body_style,
7687
- selected_text_range_: selected_text_range_
7688
- }, ()=>include_input_field_?.on_close_?.());
7689
- include_input_field_?.on_open_?.();
7690
- }));
7691
- }
7692
- }
7696
+ const [get_search_field_elements, set_search_field_elements] = (0, $kyEB6$createSignal)();
7697
+ const SafeSearchField = (0, $kyEB6$catchify)((0, $5285d2814d0fac0c$export$b94867ecbd698f21));
7693
7698
  const [sort_or_filter_open_, set_sort_or_filter_open_] = (0, $kyEB6$createSignal)(false);
7694
7699
  const [desktop_filter_elements_, set_desktop_filter_elements] = (0, $kyEB6$createSignal)();
7695
7700
  const formatted_number_of_results_ = (0, $511cc0abd9a64ce8$export$92f2da32c6e7e7ee)({
@@ -7753,11 +7758,60 @@ function $7097477c78a89208$export$a54ec244c8863715(opts) {
7753
7758
  get_search_query_();
7754
7759
  (0, $d78eea1e8707dc2d$export$c7e181728ad525f)(location);
7755
7760
  });
7761
+ (0, $kyEB6$createEffect)(()=>{
7762
+ // reactive include_input_field
7763
+ // this uses ~7 variables from outer scope which is why I didn't refactor it into a function
7764
+ add_input_field: {
7765
+ const input_field_accessor_value = include_input_field_?.() ?? true; // default to showing input field
7766
+ if (!input_field_accessor_value) break add_input_field;
7767
+ let input_element;
7768
+ let div_with_field_class;
7769
+ const search_field = SafeSearchField({
7770
+ i18n_: i18n_,
7771
+ search_field_value_: search_field_value_,
7772
+ submit_query_: submit_query_,
7773
+ clear_filters_: clear_filters_on_next_submit_,
7774
+ input_field_ref_: (el)=>input_element = el,
7775
+ field_element_ref_: (el)=>div_with_field_class = el,
7776
+ disabled_: true
7777
+ });
7778
+ if (!search_field) break add_input_field;
7779
+ modal_body_style[1]({});
7780
+ modal_body_style_ref_?.(modal_body_style);
7781
+ const align_position = (0, $kyEB6$catchify)((0, $b6d5529b253681aa$export$b3ad617e9036868))(modal_body_style, search_field, undefined, true);
7782
+ div_with_field_class.addEventListener("click", (0, $kyEB6$catchify)((e)=>{
7783
+ const target = e.target;
7784
+ const sel = ".submit";
7785
+ if (target?.matches?.(sel) || target?.closest?.(sel)) // the search button is just decor, don't do anything when clicked
7786
+ return;
7787
+ // 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.
7788
+ const selected_text_range_ = [
7789
+ input_element.selectionStart,
7790
+ input_element.selectionEnd
7791
+ ];
7792
+ align_position?.();
7793
+ open_modal_({
7794
+ style_props_: modal_body_style,
7795
+ selected_text_range_: selected_text_range_
7796
+ }, ()=>input_field_accessor_value?.on_close_?.());
7797
+ input_field_accessor_value?.on_open_?.();
7798
+ }));
7799
+ set_search_field_elements(search_field);
7800
+ return;
7801
+ }
7802
+ // We bailed out of adding the input field
7803
+ set_search_field_elements();
7804
+ // 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.
7805
+ // 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".
7806
+ (0, $1801dbce7adb3f19$export$41b4894022a3580f)({
7807
+ style_props_: modal_body_style
7808
+ });
7809
+ });
7756
7810
  return [
7757
7811
  document.createComment("Search page based on Depict SDK"),
7758
7812
  (()=>{
7759
7813
  const _el$2 = $7097477c78a89208$var$_tmpl$2.cloneNode(true), _el$3 = _el$2.firstChild;
7760
- (0, $kyEB6$insert)(_el$3, search_field, null);
7814
+ (0, $kyEB6$insert)(_el$3, get_search_field_elements, null);
7761
7815
  (0, $kyEB6$insert)(_el$3, make_category_suggestion_card_ ? (0, $kyEB6$createComponent)((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
7762
7816
  severity_: "error",
7763
7817
  message_: "Category suggestions failed",
@@ -7885,7 +7939,6 @@ function $7097477c78a89208$export$a54ec244c8863715(opts) {
7885
7939
 
7886
7940
 
7887
7941
 
7888
-
7889
7942
  function $4ca91518c9a35379$export$828dcdd425fd3231(aligner) {
7890
7943
  const style_element = document.createElement("style");
7891
7944
  document.head.append(style_element);
@@ -7910,6 +7963,7 @@ function $4ca91518c9a35379$export$828dcdd425fd3231(aligner) {
7910
7963
 
7911
7964
 
7912
7965
 
7966
+
7913
7967
  const $806c97b931758897$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$kyEB6$template)(`<div class="depict plp search"></div>`, 2);
7914
7968
  /**
7915
7969
  * 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.
@@ -8052,18 +8106,7 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
8052
8106
  return;
8053
8107
  }
8054
8108
  // Open centered modal
8055
- const supports_hover = (0, $dc9262ef6f786812$export$d9f36cf74e24d595)("(hover: hover) and (pointer: fine)");
8056
- const desktop_short = (0, $dc9262ef6f786812$export$d9f36cf74e24d595)("(max-height: 790px)");
8057
- const mobile_short = (0, $dc9262ef6f786812$export$d9f36cf74e24d595)("(max-height: 1000px)");
8058
- const transform_y = (0, $kyEB6$createMemo)(()=>supports_hover() ? !desktop_short() : !mobile_short());
8059
- const style_props_ = (0, $kyEB6$createSignal)({
8060
- position: "fixed",
8061
- top: "50%"
8062
- });
8063
- (0, $kyEB6$createComputed)(()=>style_props_[1]((old_value)=>({
8064
- ...old_value,
8065
- transform: transform_y() ? "translateY(-50%)" : "unset"
8066
- })));
8109
+ const style_props_ = (0, $1801dbce7adb3f19$export$41b4894022a3580f)();
8067
8110
  if (signal_value_is_options) {
8068
8111
  const [options_arg, ...rest] = open_signal_value;
8069
8112
  open_modal_({
@@ -8131,7 +8174,8 @@ function $806c97b931758897$var$get_shared_properties(depict_search) {
8131
8174
  if (!shared_properties) throw new Error("Can't connect to provided DepictSearch instance");
8132
8175
  return shared_properties;
8133
8176
  }
8134
- function $806c97b931758897$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 }) {
8177
+ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
8178
+ 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;
8135
8179
  const shared_properties = $806c97b931758897$var$get_shared_properties(depict_search);
8136
8180
  const grid_spacing_override = typeof grid_spacing === "string" ? {
8137
8181
  grid_spacing: grid_spacing
@@ -8185,7 +8229,7 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
8185
8229
  selected_filters_: shared_properties.selected_filters_,
8186
8230
  showing_recommendation_rows_: state_.search_showing_recommendation_rows,
8187
8231
  scroll_restoration_data_: state_.search_scroll_restoration_data,
8188
- include_input_field_: include_input_field,
8232
+ include_input_field_: ()=>props.include_input_field,
8189
8233
  layout_options_: {
8190
8234
  cols_at_size: (0, $b5cccc8ee7d24677$export$6daf8749b65a1b77)(cols_at_size),
8191
8235
  ...grid_spacing_override
@@ -213,10 +213,23 @@ class $e1d6c0f3d89d531c$export$e015ed2f2950f2e3 {
213
213
  let resolve_in_progress;
214
214
  cache_obj.in_progress_[body] = new Promise((r)=>resolve_in_progress = r);
215
215
  try {
216
- const search_results = await (0, $diwD4$depictaiutilishared.fetch_retry)((0, $diwD4$depictaiutilishared.add_version_query_params)(endpoint1), {
216
+ let search_results = await (0, $diwD4$depictaiutilishared.fetch_retry)((0, $diwD4$depictaiutilishared.add_version_query_params)(endpoint1), {
217
217
  method: "POST",
218
218
  body: body
219
219
  });
220
+ if ("query_id" in request && request.type === "collection") // FIXME: Remove. Backwards compatibility layer
221
+ // This will retry the request without the collection type if the first request fails
222
+ {
223
+ if (!search_results || search_results?.status === 404) {
224
+ (0, $diwD4$depictaiutilishared.dlog)("Fallback request for collections due to failure");
225
+ const fallback_body = JSON.parse(body);
226
+ delete fallback_body.type;
227
+ search_results = await (0, $diwD4$depictaiutilishared.fetch_retry)((0, $diwD4$depictaiutilishared.add_version_query_params)(endpoint1), {
228
+ method: "POST",
229
+ body: JSON.stringify(fallback_body)
230
+ });
231
+ }
232
+ }
220
233
  if (!search_results || search_results.status !== 200) {
221
234
  const retval = fallback_response(input_req);
222
235
  resolve_in_progress(retval);
@@ -4593,7 +4606,7 @@ const $840d88a04b2d22a7$var$_tmpl$ = [
4593
4606
  "<!--/--><!--#-->",
4594
4607
  "<!--/--></div>"
4595
4608
  ];
4596
- 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_ , 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_ }) {
4609
+ 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_ , 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_ }) {
4597
4610
  let results_for;
4598
4611
  let only_show_filters_opener_;
4599
4612
  let middle_elements_;
@@ -4618,6 +4631,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4618
4631
  tenant: tenant_(),
4619
4632
  market: market_(),
4620
4633
  query_id: query_id_(),
4634
+ type: listing_type_(),
4621
4635
  ...f.length ? {
4622
4636
  filters: f
4623
4637
  } : {},
@@ -5207,6 +5221,7 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
5207
5221
  #merchant_signal = (0, $diwD4$solidjs.createSignal)();
5208
5222
  #market_signal = (0, $diwD4$solidjs.createSignal)();
5209
5223
  #query_id_signal = (0, $diwD4$solidjs.createSignal)("");
5224
+ #listing_type_signal = (0, $diwD4$solidjs.createSignal)();
5210
5225
  static #has_been_constructed = false;
5211
5226
  get localization() {
5212
5227
  // allow reactive access
@@ -5233,6 +5248,12 @@ class $48567ac5b39bac56$export$f34314aa9505732e {
5233
5248
  set market(market) {
5234
5249
  this.#market_signal[1](market);
5235
5250
  }
5251
+ get listing_type() {
5252
+ return this.#listing_type_signal[0]();
5253
+ }
5254
+ set listing_type(listing_type) {
5255
+ this.#listing_type_signal[1](listing_type);
5256
+ }
5236
5257
  get on_navigation() {
5237
5258
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
5238
5259
  return this.#router.on_navigation_;
@@ -5295,6 +5316,7 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e({ depict_category: depict_cat
5295
5316
  min_products_to_fetch_: $48567ac5b39bac56$var$min_products_to_fetch_,
5296
5317
  local_filter_cache_: local_filter_cache_,
5297
5318
  query_id_: ()=>depict_category.category_id,
5319
+ listing_type_: ()=>depict_category.listing_type,
5298
5320
  i18n_: i18n_,
5299
5321
  show_quicklinks_: show_quicklinks,
5300
5322
  category_title_: category_title,
@@ -173,10 +173,23 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
173
173
  let resolve_in_progress;
174
174
  cache_obj.in_progress_[body] = new Promise((r)=>resolve_in_progress = r);
175
175
  try {
176
- const search_results = await (0, $cV3wj$fetch_retry)((0, $cV3wj$add_version_query_params)(endpoint1), {
176
+ let search_results = await (0, $cV3wj$fetch_retry)((0, $cV3wj$add_version_query_params)(endpoint1), {
177
177
  method: "POST",
178
178
  body: body
179
179
  });
180
+ if ("query_id" in request && request.type === "collection") // FIXME: Remove. Backwards compatibility layer
181
+ // This will retry the request without the collection type if the first request fails
182
+ {
183
+ if (!search_results || search_results?.status === 404) {
184
+ (0, $cV3wj$dlog)("Fallback request for collections due to failure");
185
+ const fallback_body = JSON.parse(body);
186
+ delete fallback_body.type;
187
+ search_results = await (0, $cV3wj$fetch_retry)((0, $cV3wj$add_version_query_params)(endpoint1), {
188
+ method: "POST",
189
+ body: JSON.stringify(fallback_body)
190
+ });
191
+ }
192
+ }
180
193
  if (!search_results || search_results.status !== 200) {
181
194
  const retval = fallback_response(input_req);
182
195
  resolve_in_progress(retval);
@@ -4553,7 +4566,7 @@ const $df5d81d0fe61ff21$var$_tmpl$ = [
4553
4566
  "<!--/--><!--#-->",
4554
4567
  "<!--/--></div>"
4555
4568
  ];
4556
- function $df5d81d0fe61ff21$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_ , 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_ }) {
4569
+ function $df5d81d0fe61ff21$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_ , 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_ }) {
4557
4570
  let results_for;
4558
4571
  let only_show_filters_opener_;
4559
4572
  let middle_elements_;
@@ -4578,6 +4591,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
4578
4591
  tenant: tenant_(),
4579
4592
  market: market_(),
4580
4593
  query_id: query_id_(),
4594
+ type: listing_type_(),
4581
4595
  ...f.length ? {
4582
4596
  filters: f
4583
4597
  } : {},
@@ -5167,6 +5181,7 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
5167
5181
  #merchant_signal = (0, $cV3wj$createSignal)();
5168
5182
  #market_signal = (0, $cV3wj$createSignal)();
5169
5183
  #query_id_signal = (0, $cV3wj$createSignal)("");
5184
+ #listing_type_signal = (0, $cV3wj$createSignal)();
5170
5185
  static #has_been_constructed = false;
5171
5186
  get localization() {
5172
5187
  // allow reactive access
@@ -5193,6 +5208,12 @@ class $961b5c64bef4662f$export$f34314aa9505732e {
5193
5208
  set market(market) {
5194
5209
  this.#market_signal[1](market);
5195
5210
  }
5211
+ get listing_type() {
5212
+ return this.#listing_type_signal[0]();
5213
+ }
5214
+ set listing_type(listing_type) {
5215
+ this.#listing_type_signal[1](listing_type);
5216
+ }
5196
5217
  get on_navigation() {
5197
5218
  // The only non-reactive public property on the class (I don't see it making sense to have it reactive)
5198
5219
  return this.#router.on_navigation_;
@@ -5255,6 +5276,7 @@ function $961b5c64bef4662f$export$e2bf8ce7779e827e({ depict_category: depict_cat
5255
5276
  min_products_to_fetch_: $961b5c64bef4662f$var$min_products_to_fetch_,
5256
5277
  local_filter_cache_: local_filter_cache_,
5257
5278
  query_id_: ()=>depict_category.category_id,
5279
+ listing_type_: ()=>depict_category.listing_type,
5258
5280
  i18n_: i18n_,
5259
5281
  show_quicklinks_: show_quicklinks,
5260
5282
  category_title_: category_title,
package/package.json CHANGED
@@ -1,10 +1,14 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "1.0.18",
3
+ "version": "1.1.0",
4
4
  "description": "Base package containing the actual UI of Depict UI along with translations, with a not-simplified API. We recommend using @depict-ai/js-ui or @depict-ai/react-ui instead.",
5
5
  "packageManager": "yarn@3.2.2",
6
- "main": "dist/client/main.js",
7
- "module": "dist/client/module.js",
6
+ "source": [
7
+ "src/index.ts",
8
+ "src/locales/index.ts"
9
+ ],
10
+ "main": "dist/main.js",
11
+ "module": "dist/module.js",
8
12
  "sass": "styles.scss",
9
13
  "context": "node",
10
14
  "engines": {
@@ -29,54 +33,35 @@
29
33
  "Carl Riis <carl@depict.ai>"
30
34
  ],
31
35
  "targets": {
32
- "localesModule": {
36
+ "module": {
33
37
  "isLibrary": true,
38
+ "source": "src/index.ts",
34
39
  "optimize": false,
35
- "source": "src/locales/index.ts",
36
- "distDir": "locales/module",
37
- "outputFormat": "esmodule",
38
40
  "context": "node"
39
41
  },
40
- "localesCommonJS": {
42
+ "main": {
41
43
  "isLibrary": true,
44
+ "source": "src/index.ts",
42
45
  "optimize": false,
43
- "source": "src/locales/index.ts",
44
- "distDir": "locales/main",
45
- "outputFormat": "commonjs",
46
46
  "context": "node"
47
47
  },
48
- "client_esmodule": {
48
+ "localesModule": {
49
49
  "isLibrary": true,
50
- "source": "src/index.ts",
51
50
  "optimize": false,
51
+ "source": "src/locales/index.ts",
52
+ "distDir": "locales/module",
52
53
  "outputFormat": "esmodule",
53
- "context": "node",
54
- "distDir": "dist/client/esmodule"
54
+ "context": "node"
55
55
  },
56
- "client_commonjs": {
56
+ "localesCommonJS": {
57
57
  "isLibrary": true,
58
- "source": "src/index.ts",
59
58
  "optimize": false,
60
- "context": "node",
59
+ "source": "src/locales/index.ts",
60
+ "distDir": "locales/main",
61
61
  "outputFormat": "commonjs",
62
- "distDir": "dist/client/commonjs"
63
- },
64
- "server_esmodule": {
65
- "isLibrary": true,
66
- "source": "src/index.ts",
67
- "optimize": false,
68
- "outputFormat": "esmodule",
69
- "context": "node",
70
- "distDir": "dist/server/esmodule"
62
+ "context": "node"
71
63
  },
72
- "server_commonjs": {
73
- "isLibrary": true,
74
- "source": "src/index.ts",
75
- "optimize": false,
76
- "context": "node",
77
- "outputFormat": "commonjs",
78
- "distDir": "dist/server/commonjs"
79
- }
64
+ "types": {}
80
65
  },
81
66
  "files": [
82
67
  "/dist",
@@ -87,17 +72,10 @@
87
72
  "exports": {
88
73
  "./styles.scss": "./styles.scss",
89
74
  ".": {
75
+ "import": "./dist/module.js",
76
+ "require": "./dist/main.js",
90
77
  "types": "./dist/index.d.ts",
91
- "browser": {
92
- "import": "./dist/client/module.js",
93
- "require": "./dist/client/main.js",
94
- "default": "./dist/client/module.js"
95
- },
96
- "node": {
97
- "import": "./dist/server/module.js",
98
- "require": "./dist/server/main.js",
99
- "default": "./dist/server/module.js"
100
- }
78
+ "default": "./dist/module.js"
101
79
  },
102
80
  "./locales": {
103
81
  "types": "./locales/index.d.ts",
@@ -124,11 +102,10 @@
124
102
  "ts-jest": "^29.0.3"
125
103
  },
126
104
  "dependencies": {
127
- "@depict-ai/plp-styling": "^1.0.16",
128
- "@depict-ai/types": "^1.0.19",
129
- "@depict-ai/utilishared": "^1.0.15",
105
+ "@depict-ai/plp-styling": "^1.0.17",
106
+ "@depict-ai/types": "^1.0.20",
107
+ "@depict-ai/utilishared": "^1.0.16",
130
108
  "solid-js": "^1.7.3"
131
109
  },
132
- "types": "dist/index.d.ts",
133
- "type": "module"
110
+ "types": "dist/index.d.ts"
134
111
  }