@depict-ai/ui 3.0.11 → 3.0.13

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.
@@ -77,7 +77,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
77
77
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
78
78
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
79
79
  /*! Depict.ai search and product listing SDK */
80
- const $b757f75811f3261f$export$83d89fbfd8236492 = "3.0.11";
80
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "3.0.13";
81
81
  const $0f313083912e447a$var$_tmpl$ = ["<svg", ' xmlns="http://www.w3.org/2000/svg"', ' viewBox="0 0 14 26"><path d="M2 24.656c-.078 0-.156-.016-.234-.047s-.133-.066-.187-.129c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422l10.371-10.371L1.578 2.883c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422.258-.176.422-.176.305.059.422.176l10.805 10.793a.59.59 0 0 1 .176.434c0 .172-.059.305-.176.422L2.422 24.48a.42.42 0 0 1-.199.129.54.54 0 0 1-.223.047zm0 0" fill="#0f0f0f"></path></svg>'];
82
82
  function $0f313083912e447a$export$8be2714ec7f169ee(props = {}) {
83
83
  return $5vyXB$solidjsweb.ssr($0f313083912e447a$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.ssrAttribute("width", $5vyXB$solidjsweb.escape(props.width_, true) ?? 14, false) + $5vyXB$solidjsweb.ssrAttribute("height", $5vyXB$solidjsweb.escape(props.height_, true) ?? 26, false));
@@ -687,8 +687,8 @@ const $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1 = /*@__PURE__*/(() => {
687
687
  const $a3280f0aad997933$export$c3834fa86c616831 = [[4], [3, 1024], [2, 901]];
688
688
  const $a3280f0aad997933$export$864d304a0bc46829 = "2%";
689
689
  const $a3280f0aad997933$export$7bf543b9d9be2c22 = (0, $0b23bfd073d9a4e8$export$b91cec6bdc6b32a1);
690
- function $fc23d7668ae0011d$export$a2cc176055f8f08() {
691
- const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the grid before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
690
+ function $fc23d7668ae0011d$export$a2cc176055f8f08(what = "grid") {
691
+ const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the " + what + " before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
692
692
  return (0, $5vyXB$solidjsweb.isServer) ? {
693
693
  t: `<!-- ${text} -->`
694
694
  } : document.createComment(text);
@@ -4839,25 +4839,28 @@ function $0f400c3f7248d5f1$export$92f2da32c6e7e7ee({
4839
4839
  price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
4840
4840
  });
4841
4841
  }
4842
- function $76b6ac05693f5c71$export$205efb947c7ffd78(handler, passive = true) {
4842
+ function $76b6ac05693f5c71$export$205efb947c7ffd78(handler, passive = true, override_element) {
4843
4843
  const catchified_handler = $5vyXB$depictaiutilishared.catchify(handler);
4844
4844
  const owner = $5vyXB$solidjs.getOwner();
4845
4845
  // Some customers (e.g. equestrian) have `height: 100%` and/or `overflow-x: hidden` on the body, which means that scroll events won't get dispatched on `window`. The pages who get it on <body> won't get it on `window` and vice-versa, so there shouldn't be a worry about duplicate calling of the handler.
4846
4846
  // Use observer in case that this gets called before body exists
4847
- const disconnect = (0, $5vyXB$depictaiutilishared.observer).onexists("body", ({
4848
- element: element
4849
- }) => {
4850
- element.addEventListener("scroll", catchified_handler, {
4851
- passive: passive
4847
+ if (!override_element) {
4848
+ const disconnect = (0, $5vyXB$depictaiutilishared.observer).onexists("body", ({
4849
+ element: element
4850
+ }) => {
4851
+ element.addEventListener("scroll", catchified_handler, {
4852
+ passive: passive
4853
+ });
4854
+ $5vyXB$solidjs.runWithOwner(owner, () => $5vyXB$solidjs.onCleanup(() => element.removeEventListener("scroll", catchified_handler)));
4852
4855
  });
4853
- $5vyXB$solidjs.runWithOwner(owner, () => $5vyXB$solidjs.onCleanup(() => element.removeEventListener("scroll", catchified_handler)));
4854
- });
4855
- $5vyXB$solidjs.onCleanup(disconnect);
4856
+ $5vyXB$solidjs.onCleanup(disconnect);
4857
+ }
4856
4858
  for (const event of ["resize", "orientationchange", "scroll"]) {
4857
- addEventListener(event, catchified_handler, {
4859
+ const listen_on = override_element ?? window;
4860
+ listen_on.addEventListener(event, catchified_handler, {
4858
4861
  passive: passive
4859
4862
  });
4860
- $5vyXB$solidjs.onCleanup(() => removeEventListener(event, catchified_handler));
4863
+ $5vyXB$solidjs.onCleanup(() => listen_on.removeEventListener(event, catchified_handler));
4861
4864
  }
4862
4865
  }
4863
4866
  const $401aee5f33dca9e2$var$_tmpl$ = ["<div", ' class="scroll-status" style="display:none"><span class="text"><b>', "</b> \u2013 <b>", "</b> <!--$-->", "<!--/--> <b>", "</b></span></div>"];
@@ -4869,7 +4872,9 @@ function $401aee5f33dca9e2$export$83fd5de5504a7a67({
4869
4872
  i18n_: {
4870
4873
  price_formatting_: price_formatting_,
4871
4874
  of_: of_
4872
- }
4875
+ },
4876
+ get_scroll_position_ = () => scrollY,
4877
+ listen_to_scroll_on_: listen_to_scroll_on_
4873
4878
  }) {
4874
4879
  if (0, $5vyXB$solidjsweb.isServer) return; // won't show in initial render and need scroll position
4875
4880
  const [first_to_show, set_first_to_show] = $5vyXB$solidjs.createSignal(0);
@@ -4884,12 +4889,12 @@ function $401aee5f33dca9e2$export$83fd5de5504a7a67({
4884
4889
  let element;
4885
4890
  let animation;
4886
4891
  let last_pos_time = +new Date();
4887
- let last_pos = scrollY;
4892
+ let last_pos = get_scroll_position_();
4888
4893
  let unpermit_when_possible = false;
4889
4894
  let times_too_fast = 0;
4890
4895
  const handle_scrollpos_change = () => {
4891
4896
  if (animation) set_show_triggered(prev => !prev); // make sure that once we've decided to show the indicator it doesn't disappear before we stop scrolling
4892
- const distance_travelled = Math.abs(scrollY - last_pos);
4897
+ const distance_travelled = Math.abs(get_scroll_position_() - last_pos);
4893
4898
  const now = +new Date();
4894
4899
  const age_of_distance = now - last_pos_time;
4895
4900
  const velocity = distance_travelled / age_of_distance; // pixels per millisecond
@@ -4902,9 +4907,9 @@ function $401aee5f33dca9e2$export$83fd5de5504a7a67({
4902
4907
  unpermit_when_possible = false;
4903
4908
  } else if (animation) unpermit_when_possible = true;else set_permitted_to_show(false);
4904
4909
  last_pos_time = now;
4905
- last_pos = scrollY;
4910
+ last_pos = get_scroll_position_();
4906
4911
  };
4907
- $76b6ac05693f5c71$export$205efb947c7ffd78(handle_scrollpos_change);
4912
+ $76b6ac05693f5c71$export$205efb947c7ffd78(handle_scrollpos_change, undefined, listen_to_scroll_on_);
4908
4913
  $5vyXB$solidjs.createEffect(() => {
4909
4914
  show_triggered();
4910
4915
  const first = get_first_result_in_viewport();
@@ -5491,7 +5496,8 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
5491
5496
  product_card_template_: product_card_template_,
5492
5497
  layout_options_: layout_options_,
5493
5498
  id_currently_querying_for_: id_currently_querying_for_,
5494
- content_blocks_by_row_: content_blocks_by_row_
5499
+ content_blocks_by_row_: content_blocks_by_row_,
5500
+ ConfiguredScrollStatus: ConfiguredScrollStatus
5495
5501
  }) {
5496
5502
  // The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
5497
5503
  const is_loading_ = $5vyXB$solidjs.createMemo(() => plp_results_.loading || query_base_.loading);
@@ -5553,6 +5559,7 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
5553
5559
  product_card_template_: product_card_template_,
5554
5560
  num_placeholders_: num_placeholders_
5555
5561
  }) : undefined);
5562
+ const layout = $5vyXB$solidjs.createMemo(() => layout_options_().layout || "grid");
5556
5563
  const [get_suspense_is_blocked, set_suspense_is_blocked] = $5vyXB$solidjs.createSignal(false);
5557
5564
  const block_suspense_if_needed = () => {
5558
5565
  if (!is_just_after_plp_results_update) return;
@@ -5624,7 +5631,7 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
5624
5631
  },
5625
5632
  children: product_cards_when_data
5626
5633
  });
5627
- return [$fc23d7668ae0011d$export$a2cc176055f8f08(), $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
5634
+ return [$fc23d7668ae0011d$export$a2cc176055f8f08(layout()), $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
5628
5635
  get when() {
5629
5636
  return doesnt_have_content_blocks();
5630
5637
  },
@@ -5647,22 +5654,79 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
5647
5654
  });
5648
5655
  },
5649
5656
  get children() {
5650
- return $5vyXB$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
5651
- get cols_at_size() {
5652
- return modified_cols_at_size();
5653
- },
5654
- get override_vertical_spacing() {
5655
- return layout_options_().override_vertical_spacing;
5656
- },
5657
- get grid_spacing() {
5658
- return layout_options_().grid_spacing;
5657
+ return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
5658
+ get when() {
5659
+ return layout() === "grid";
5659
5660
  },
5660
- rows: "all",
5661
- layout: "grid",
5662
- element_attributes: {
5663
- class: "cards"
5661
+ get fallback() {
5662
+ return $5vyXB$solidjsweb.createComponent((0, $a0e53f99354809d9$export$6649caad96ef8870), {
5663
+ arrow_height_: 25,
5664
+ arrow_width_: 12.5,
5665
+ disable_fading_: true,
5666
+ slider_ref_: slider => {
5667
+ const {
5668
+ insert_here: insert_here,
5669
+ container: container
5670
+ } = slider;
5671
+ const Layout = props => $f48d0fbb00835aaa$export$445d8d3f5f706a40(props, insert_here, true);
5672
+ // Do like this, so we don't have to call mergeProps ourselves
5673
+ $5vyXB$solidjsweb.createComponent(Layout, $5vyXB$solidjsweb.mergeProps({
5674
+ rows: "all"
5675
+ }, layout_options_, {
5676
+ get cols_at_size() {
5677
+ return modified_cols_at_size();
5678
+ },
5679
+ get layout() {
5680
+ return layout();
5681
+ }
5682
+ }));
5683
+ insert_here.classList.add("generated-spacing");
5684
+ $5vyXB$solidjs.createEffect(
5685
+ // @ts-ignore
5686
+ $5vyXB$solidjs.on(query_base_, () => insert_here.scrollTo({
5687
+ left: 0,
5688
+ behavior: "instant"
5689
+ }), {
5690
+ defer: true
5691
+ })); // Scroll to the beginning if a filter or the query changes
5692
+ $5vyXB$depictaiutilishared.slider_fractional_factory(0, 0.75).constructor_plugin.call(slider, {}); // enable fractional scrolling
5693
+ if (ConfiguredScrollStatus) {
5694
+ // Put scroll status into slider container, so it's centered relatively to the products
5695
+ const rendered_scroll_status = ConfiguredScrollStatus({
5696
+ get_scroll_position_: () => insert_here.scrollLeft,
5697
+ listen_to_scroll_on_: insert_here
5698
+ });
5699
+ const {
5700
+ childNodes: childNodes
5701
+ } = container;
5702
+ // We have to use `insert` over Element.append, because ConfiguredScrollStatus is in an ErrorBoundary and therefore returns a function. `insert` will wipe all children, therefore save them first and then tell insert that the element should contain these elements + whatever ScrollStatus returns
5703
+ $5vyXB$solidjsweb.insert(container, $5vyXB$solidjs.createMemo(() => [...childNodes, rendered_scroll_status]));
5704
+ }
5705
+ },
5706
+ children: listing_contents
5707
+ });
5664
5708
  },
5665
- children: listing_contents
5709
+ get children() {
5710
+ return $5vyXB$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
5711
+ get cols_at_size() {
5712
+ return modified_cols_at_size();
5713
+ },
5714
+ get override_vertical_spacing() {
5715
+ return layout_options_().override_vertical_spacing;
5716
+ },
5717
+ get grid_spacing() {
5718
+ return layout_options_().grid_spacing;
5719
+ },
5720
+ rows: "all",
5721
+ get layout() {
5722
+ return layout();
5723
+ },
5724
+ element_attributes: {
5725
+ class: "cards"
5726
+ },
5727
+ children: listing_contents
5728
+ });
5729
+ }
5666
5730
  });
5667
5731
  }
5668
5732
  })];
@@ -6572,8 +6636,11 @@ async function $276380e4607fb9fb$export$cc42dd29bf655ab6({
6572
6636
  const new_displays = last_response.displays;
6573
6637
  displays.push(...new_displays);
6574
6638
  next_cursor = last_response.cursor;
6575
- if (new_displays.length < fetch_this_time && last_response.failed !== true) break;
6576
6639
  const left_to_fetch = total_products_to_fetch - displays.length;
6640
+ if (!next_cursor) {
6641
+ if (left_to_fetch > 0) $5vyXB$depictaiutilishared.dwarn("Got response without a cursor when attempting to restore scroll position, giving up", last_response, total_products_to_fetch, displays);
6642
+ break;
6643
+ }
6577
6644
  fetch_this_time = left_to_fetch < $276380e4607fb9fb$var$api_max_products_per_request ? left_to_fetch : $276380e4607fb9fb$var$api_max_products_per_request;
6578
6645
  }
6579
6646
  return {
@@ -6912,6 +6979,20 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
6912
6979
  // @ts-ignore - there's no type error here when writing the code, but parcel can't generate types that include the symbol, so we need to suppress the error that creates in our pipelines
6913
6980
  const category_title_type = category_title_[(0, $6b502b1b2155a0bc$export$5c28802497c8a83c)];
6914
6981
  const extra_sort_and_filter_args_ = {};
6982
+ const ConfiguredScrollStatus = (extraProps = {}) => $5vyXB$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
6983
+ severity_: "error",
6984
+ message_: "Scroll status failed",
6985
+ get children() {
6986
+ return $401aee5f33dca9e2$export$83fd5de5504a7a67({
6987
+ first_result_in_viewport_: first_result_in_viewport_,
6988
+ last_result_in_viewport_: last_result_in_viewport_,
6989
+ formatted_number_of_results_: formatted_number_of_results_,
6990
+ i18n_: i18n_,
6991
+ number_of_results_: $5vyXB$solidjs.createMemo(() => plp_products_()?.n_hits),
6992
+ ...extraProps
6993
+ });
6994
+ }
6995
+ });
6915
6996
  const make_product_count_ = () => $5vyXB$solidjsweb.ssr($840d88a04b2d22a7$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
6916
6997
  get when() {
6917
6998
  return plp_products_.loading;
@@ -7086,6 +7167,7 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7086
7167
  sort_or_filter_open_: sort_or_filter_open_,
7087
7168
  desktop_filter_elements_: desktop_filter_elements_,
7088
7169
  content_blocks_by_row_: content_blocks_by_row_,
7170
+ ConfiguredScrollStatus: ConfiguredScrollStatus,
7089
7171
  id_currently_querying_for_: id_to_query_for_,
7090
7172
  no_results_options_: {
7091
7173
  selected_filters_: selected_filters_,
@@ -7097,17 +7179,12 @@ function $840d88a04b2d22a7$export$f7d2f673fc2f091d({
7097
7179
  }
7098
7180
  });
7099
7181
  }
7100
- })), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7101
- severity_: "error",
7102
- message_: "Scroll status failed",
7182
+ })), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
7183
+ get when() {
7184
+ return layout_options_().layout === "grid";
7185
+ },
7103
7186
  get children() {
7104
- return $401aee5f33dca9e2$export$83fd5de5504a7a67({
7105
- first_result_in_viewport_: first_result_in_viewport_,
7106
- last_result_in_viewport_: last_result_in_viewport_,
7107
- formatted_number_of_results_: formatted_number_of_results_,
7108
- i18n_: i18n_,
7109
- number_of_results_: $5vyXB$solidjs.createMemo(() => plp_products_()?.n_hits)
7110
- });
7187
+ return $5vyXB$solidjsweb.createComponent(ConfiguredScrollStatus, {});
7111
7188
  }
7112
7189
  })), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
7113
7190
  severity_: "error",
@@ -7490,7 +7567,8 @@ function $48567ac5b39bac56$export$e2bf8ce7779e827e(props) {
7490
7567
  scroll_restoration_data_: scroll_restoration_data_,
7491
7568
  layout_options_: $5vyXB$solidjs.createMemo(() => ({
7492
7569
  cols_at_size: $4e04be41243c3d80$export$6daf8749b65a1b77(props.cols_at_size),
7493
- ...grid_spacing_override()
7570
+ ...grid_spacing_override(),
7571
+ layout: props.layout || "grid"
7494
7572
  })),
7495
7573
  product_card_template_: product_card_template,
7496
7574
  sorting_query_param_: sorting_query_param_,
@@ -10,7 +10,7 @@ import { ProductListingRequestV3 } from "@depict-ai/types/api/ProductListingRequ
10
10
  import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
11
11
  import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
12
12
  import { SearchFilter as _SearchFilter2 } from "@depict-ai/types/api/SearchRequestV2";
13
- export const version = "3.0.11";
13
+ export const version = "3.0.13";
14
14
  export type SDKColsAtSize = [number, number?][];
15
15
  /**
16
16
  * Transform SDK ColsAtSize into valid Layout ColsAtSize
@@ -182,6 +182,11 @@ export interface BaseCategoryPageConfig extends BaseProductListingConfig {
182
182
  * @default true
183
183
  */
184
184
  showQuicklinks?: boolean;
185
+ /**
186
+ * Whether to show the listing in a grid or a slider.
187
+ * @default "grid"
188
+ */
189
+ layout?: "grid" | "slider";
185
190
  }
186
191
  /**
187
192
  * The listing to query Depict for. `type` can be `"listingId"` or `"externalId"` and `id` is the actual id.
@@ -965,6 +970,7 @@ export function CategoryPage<OriginalDisplay extends Display, OutputDisplay exte
965
970
  category_title: typeof CategoryTitle | typeof embedded_num_products;
966
971
  on_listing_query_change?: (new_listing_query?: ListingQuery | undefined, old_listing_query?: ListingQuery | undefined) => void;
967
972
  content_blocks_by_row?: ContentBlocksByRow;
973
+ layout?: "slider" | "grid";
968
974
  }): import("@depict-ai/utilishared/latest").Node_Array;
969
975
  export function BreadCrumbs<T extends Display>({
970
976
  depict_category
@@ -7,7 +7,7 @@ import { createStore as $i7OB2$createStore, reconcile as $i7OB2$reconcile } from
7
7
  /*! Depict.ai search and product listing SDK */
8
8
  import { register_es_version } from "../../multi_import_deduplicator.mjs";
9
9
  register_es_version("ui", "latest");
10
- const $ec291e0010116877$export$83d89fbfd8236492 = "3.0.11";
10
+ const $ec291e0010116877$export$83d89fbfd8236492 = "3.0.13";
11
11
  const $fbbadcb080ad1d4a$var$_tmpl$ = ["<svg", ' xmlns="http://www.w3.org/2000/svg"', ' viewBox="0 0 14 26"><path d="M2 24.656c-.078 0-.156-.016-.234-.047s-.133-.066-.187-.129c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422l10.371-10.371L1.578 2.883c-.117-.117-.176-.258-.176-.422s.059-.305.176-.422.258-.176.422-.176.305.059.422.176l10.805 10.793a.59.59 0 0 1 .176.434c0 .172-.059.305-.176.422L2.422 24.48a.42.42 0 0 1-.199.129.54.54 0 0 1-.223.047zm0 0" fill="#0f0f0f"></path></svg>'];
12
12
  function $fbbadcb080ad1d4a$export$8be2714ec7f169ee(props = {}) {
13
13
  return $i7OB2$ssr($fbbadcb080ad1d4a$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$ssrAttribute("width", $i7OB2$escape(props.width_, true) ?? 14, false) + $i7OB2$ssrAttribute("height", $i7OB2$escape(props.height_, true) ?? 26, false));
@@ -617,8 +617,8 @@ const $e4615ecd1849548f$export$b91cec6bdc6b32a1 = /*@__PURE__*/(() => {
617
617
  const $4690a06c8489dcd0$export$c3834fa86c616831 = [[4], [3, 1024], [2, 901]];
618
618
  const $4690a06c8489dcd0$export$864d304a0bc46829 = "2%";
619
619
  const $4690a06c8489dcd0$export$7bf543b9d9be2c22 = (0, $e4615ecd1849548f$export$b91cec6bdc6b32a1);
620
- function $a458486f22b22f63$export$a2cc176055f8f08() {
621
- const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the grid before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
620
+ function $a458486f22b22f63$export$a2cc176055f8f08(what = "grid") {
621
+ const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the " + what + " before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
622
622
  return (0, $i7OB2$isServer) ? {
623
623
  t: `<!-- ${text} -->`
624
624
  } : document.createComment(text);
@@ -4769,25 +4769,28 @@ function $511cc0abd9a64ce8$export$92f2da32c6e7e7ee({
4769
4769
  price_formatting.decimal_places_delimiter_, price_formatting.thousands_delimiter_);
4770
4770
  });
4771
4771
  }
4772
- function $8f9120a1ca151e6a$export$205efb947c7ffd78(handler, passive = true) {
4772
+ function $8f9120a1ca151e6a$export$205efb947c7ffd78(handler, passive = true, override_element) {
4773
4773
  const catchified_handler = $i7OB2$catchify1(handler);
4774
4774
  const owner = $i7OB2$getOwner();
4775
4775
  // Some customers (e.g. equestrian) have `height: 100%` and/or `overflow-x: hidden` on the body, which means that scroll events won't get dispatched on `window`. The pages who get it on <body> won't get it on `window` and vice-versa, so there shouldn't be a worry about duplicate calling of the handler.
4776
4776
  // Use observer in case that this gets called before body exists
4777
- const disconnect = (0, $i7OB2$observer).onexists("body", ({
4778
- element: element
4779
- }) => {
4780
- element.addEventListener("scroll", catchified_handler, {
4781
- passive: passive
4777
+ if (!override_element) {
4778
+ const disconnect = (0, $i7OB2$observer).onexists("body", ({
4779
+ element: element
4780
+ }) => {
4781
+ element.addEventListener("scroll", catchified_handler, {
4782
+ passive: passive
4783
+ });
4784
+ $i7OB2$runWithOwner(owner, () => $i7OB2$onCleanup(() => element.removeEventListener("scroll", catchified_handler)));
4782
4785
  });
4783
- $i7OB2$runWithOwner(owner, () => $i7OB2$onCleanup(() => element.removeEventListener("scroll", catchified_handler)));
4784
- });
4785
- $i7OB2$onCleanup(disconnect);
4786
+ $i7OB2$onCleanup(disconnect);
4787
+ }
4786
4788
  for (const event of ["resize", "orientationchange", "scroll"]) {
4787
- addEventListener(event, catchified_handler, {
4789
+ const listen_on = override_element ?? window;
4790
+ listen_on.addEventListener(event, catchified_handler, {
4788
4791
  passive: passive
4789
4792
  });
4790
- $i7OB2$onCleanup(() => removeEventListener(event, catchified_handler));
4793
+ $i7OB2$onCleanup(() => listen_on.removeEventListener(event, catchified_handler));
4791
4794
  }
4792
4795
  }
4793
4796
  const $6db49ca163afa2c3$var$_tmpl$ = ["<div", ' class="scroll-status" style="display:none"><span class="text"><b>', "</b> \u2013 <b>", "</b> <!--$-->", "<!--/--> <b>", "</b></span></div>"];
@@ -4799,7 +4802,9 @@ function $6db49ca163afa2c3$export$83fd5de5504a7a67({
4799
4802
  i18n_: {
4800
4803
  price_formatting_: price_formatting_,
4801
4804
  of_: of_
4802
- }
4805
+ },
4806
+ get_scroll_position_ = () => scrollY,
4807
+ listen_to_scroll_on_: listen_to_scroll_on_
4803
4808
  }) {
4804
4809
  if (0, $i7OB2$isServer) return; // won't show in initial render and need scroll position
4805
4810
  const [first_to_show, set_first_to_show] = $i7OB2$createSignal(0);
@@ -4814,12 +4819,12 @@ function $6db49ca163afa2c3$export$83fd5de5504a7a67({
4814
4819
  let element;
4815
4820
  let animation;
4816
4821
  let last_pos_time = +new Date();
4817
- let last_pos = scrollY;
4822
+ let last_pos = get_scroll_position_();
4818
4823
  let unpermit_when_possible = false;
4819
4824
  let times_too_fast = 0;
4820
4825
  const handle_scrollpos_change = () => {
4821
4826
  if (animation) set_show_triggered(prev => !prev); // make sure that once we've decided to show the indicator it doesn't disappear before we stop scrolling
4822
- const distance_travelled = Math.abs(scrollY - last_pos);
4827
+ const distance_travelled = Math.abs(get_scroll_position_() - last_pos);
4823
4828
  const now = +new Date();
4824
4829
  const age_of_distance = now - last_pos_time;
4825
4830
  const velocity = distance_travelled / age_of_distance; // pixels per millisecond
@@ -4832,9 +4837,9 @@ function $6db49ca163afa2c3$export$83fd5de5504a7a67({
4832
4837
  unpermit_when_possible = false;
4833
4838
  } else if (animation) unpermit_when_possible = true;else set_permitted_to_show(false);
4834
4839
  last_pos_time = now;
4835
- last_pos = scrollY;
4840
+ last_pos = get_scroll_position_();
4836
4841
  };
4837
- $8f9120a1ca151e6a$export$205efb947c7ffd78(handle_scrollpos_change);
4842
+ $8f9120a1ca151e6a$export$205efb947c7ffd78(handle_scrollpos_change, undefined, listen_to_scroll_on_);
4838
4843
  $i7OB2$createEffect(() => {
4839
4844
  show_triggered();
4840
4845
  const first = get_first_result_in_viewport();
@@ -5421,7 +5426,8 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
5421
5426
  product_card_template_: product_card_template_,
5422
5427
  layout_options_: layout_options_,
5423
5428
  id_currently_querying_for_: id_currently_querying_for_,
5424
- content_blocks_by_row_: content_blocks_by_row_
5429
+ content_blocks_by_row_: content_blocks_by_row_,
5430
+ ConfiguredScrollStatus: ConfiguredScrollStatus
5425
5431
  }) {
5426
5432
  // The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
5427
5433
  const is_loading_ = $i7OB2$createMemo(() => plp_results_.loading || query_base_.loading);
@@ -5483,6 +5489,7 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
5483
5489
  product_card_template_: product_card_template_,
5484
5490
  num_placeholders_: num_placeholders_
5485
5491
  }) : undefined);
5492
+ const layout = $i7OB2$createMemo(() => layout_options_().layout || "grid");
5486
5493
  const [get_suspense_is_blocked, set_suspense_is_blocked] = $i7OB2$createSignal(false);
5487
5494
  const block_suspense_if_needed = () => {
5488
5495
  if (!is_just_after_plp_results_update) return;
@@ -5554,7 +5561,7 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
5554
5561
  },
5555
5562
  children: product_cards_when_data
5556
5563
  });
5557
- return [$a458486f22b22f63$export$a2cc176055f8f08(), $i7OB2$createComponent((0, $i7OB2$Show), {
5564
+ return [$a458486f22b22f63$export$a2cc176055f8f08(layout()), $i7OB2$createComponent((0, $i7OB2$Show), {
5558
5565
  get when() {
5559
5566
  return doesnt_have_content_blocks();
5560
5567
  },
@@ -5577,22 +5584,79 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
5577
5584
  });
5578
5585
  },
5579
5586
  get children() {
5580
- return $i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), {
5581
- get cols_at_size() {
5582
- return modified_cols_at_size();
5583
- },
5584
- get override_vertical_spacing() {
5585
- return layout_options_().override_vertical_spacing;
5586
- },
5587
- get grid_spacing() {
5588
- return layout_options_().grid_spacing;
5587
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
5588
+ get when() {
5589
+ return layout() === "grid";
5589
5590
  },
5590
- rows: "all",
5591
- layout: "grid",
5592
- element_attributes: {
5593
- class: "cards"
5591
+ get fallback() {
5592
+ return $i7OB2$createComponent((0, $f32e14878e75af51$export$6649caad96ef8870), {
5593
+ arrow_height_: 25,
5594
+ arrow_width_: 12.5,
5595
+ disable_fading_: true,
5596
+ slider_ref_: slider => {
5597
+ const {
5598
+ insert_here: insert_here,
5599
+ container: container
5600
+ } = slider;
5601
+ const Layout = props => $c8d5ff4524619fcd$export$445d8d3f5f706a40(props, insert_here, true);
5602
+ // Do like this, so we don't have to call mergeProps ourselves
5603
+ $i7OB2$createComponent(Layout, $i7OB2$mergeProps({
5604
+ rows: "all"
5605
+ }, layout_options_, {
5606
+ get cols_at_size() {
5607
+ return modified_cols_at_size();
5608
+ },
5609
+ get layout() {
5610
+ return layout();
5611
+ }
5612
+ }));
5613
+ insert_here.classList.add("generated-spacing");
5614
+ $i7OB2$createEffect(
5615
+ // @ts-ignore
5616
+ $i7OB2$on(query_base_, () => insert_here.scrollTo({
5617
+ left: 0,
5618
+ behavior: "instant"
5619
+ }), {
5620
+ defer: true
5621
+ })); // Scroll to the beginning if a filter or the query changes
5622
+ $i7OB2$slider_fractional_factory(0, 0.75).constructor_plugin.call(slider, {}); // enable fractional scrolling
5623
+ if (ConfiguredScrollStatus) {
5624
+ // Put scroll status into slider container, so it's centered relatively to the products
5625
+ const rendered_scroll_status = ConfiguredScrollStatus({
5626
+ get_scroll_position_: () => insert_here.scrollLeft,
5627
+ listen_to_scroll_on_: insert_here
5628
+ });
5629
+ const {
5630
+ childNodes: childNodes
5631
+ } = container;
5632
+ // We have to use `insert` over Element.append, because ConfiguredScrollStatus is in an ErrorBoundary and therefore returns a function. `insert` will wipe all children, therefore save them first and then tell insert that the element should contain these elements + whatever ScrollStatus returns
5633
+ $i7OB2$insert(container, $i7OB2$createMemo(() => [...childNodes, rendered_scroll_status]));
5634
+ }
5635
+ },
5636
+ children: listing_contents
5637
+ });
5594
5638
  },
5595
- children: listing_contents
5639
+ get children() {
5640
+ return $i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), {
5641
+ get cols_at_size() {
5642
+ return modified_cols_at_size();
5643
+ },
5644
+ get override_vertical_spacing() {
5645
+ return layout_options_().override_vertical_spacing;
5646
+ },
5647
+ get grid_spacing() {
5648
+ return layout_options_().grid_spacing;
5649
+ },
5650
+ rows: "all",
5651
+ get layout() {
5652
+ return layout();
5653
+ },
5654
+ element_attributes: {
5655
+ class: "cards"
5656
+ },
5657
+ children: listing_contents
5658
+ });
5659
+ }
5596
5660
  });
5597
5661
  }
5598
5662
  })];
@@ -6502,8 +6566,11 @@ async function $641bba2917fe862b$export$cc42dd29bf655ab6({
6502
6566
  const new_displays = last_response.displays;
6503
6567
  displays.push(...new_displays);
6504
6568
  next_cursor = last_response.cursor;
6505
- if (new_displays.length < fetch_this_time && last_response.failed !== true) break;
6506
6569
  const left_to_fetch = total_products_to_fetch - displays.length;
6570
+ if (!next_cursor) {
6571
+ if (left_to_fetch > 0) $i7OB2$dwarn("Got response without a cursor when attempting to restore scroll position, giving up", last_response, total_products_to_fetch, displays);
6572
+ break;
6573
+ }
6507
6574
  fetch_this_time = left_to_fetch < $641bba2917fe862b$var$api_max_products_per_request ? left_to_fetch : $641bba2917fe862b$var$api_max_products_per_request;
6508
6575
  }
6509
6576
  return {
@@ -6842,6 +6909,20 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
6842
6909
  // @ts-ignore - there's no type error here when writing the code, but parcel can't generate types that include the symbol, so we need to suppress the error that creates in our pipelines
6843
6910
  const category_title_type = category_title_[(0, $4fb3a1cf207a7d5c$export$5c28802497c8a83c)];
6844
6911
  const extra_sort_and_filter_args_ = {};
6912
+ const ConfiguredScrollStatus = (extraProps = {}) => $i7OB2$createComponent((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
6913
+ severity_: "error",
6914
+ message_: "Scroll status failed",
6915
+ get children() {
6916
+ return $6db49ca163afa2c3$export$83fd5de5504a7a67({
6917
+ first_result_in_viewport_: first_result_in_viewport_,
6918
+ last_result_in_viewport_: last_result_in_viewport_,
6919
+ formatted_number_of_results_: formatted_number_of_results_,
6920
+ i18n_: i18n_,
6921
+ number_of_results_: $i7OB2$createMemo(() => plp_products_()?.n_hits),
6922
+ ...extraProps
6923
+ });
6924
+ }
6925
+ });
6845
6926
  const make_product_count_ = () => $i7OB2$ssr($df5d81d0fe61ff21$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
6846
6927
  get when() {
6847
6928
  return plp_products_.loading;
@@ -7016,6 +7097,7 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
7016
7097
  sort_or_filter_open_: sort_or_filter_open_,
7017
7098
  desktop_filter_elements_: desktop_filter_elements_,
7018
7099
  content_blocks_by_row_: content_blocks_by_row_,
7100
+ ConfiguredScrollStatus: ConfiguredScrollStatus,
7019
7101
  id_currently_querying_for_: id_to_query_for_,
7020
7102
  no_results_options_: {
7021
7103
  selected_filters_: selected_filters_,
@@ -7027,17 +7109,12 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
7027
7109
  }
7028
7110
  });
7029
7111
  }
7030
- })), $i7OB2$escape($i7OB2$createComponent((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
7031
- severity_: "error",
7032
- message_: "Scroll status failed",
7112
+ })), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
7113
+ get when() {
7114
+ return layout_options_().layout === "grid";
7115
+ },
7033
7116
  get children() {
7034
- return $6db49ca163afa2c3$export$83fd5de5504a7a67({
7035
- first_result_in_viewport_: first_result_in_viewport_,
7036
- last_result_in_viewport_: last_result_in_viewport_,
7037
- formatted_number_of_results_: formatted_number_of_results_,
7038
- i18n_: i18n_,
7039
- number_of_results_: $i7OB2$createMemo(() => plp_products_()?.n_hits)
7040
- });
7117
+ return $i7OB2$createComponent(ConfiguredScrollStatus, {});
7041
7118
  }
7042
7119
  })), $i7OB2$escape($i7OB2$createComponent((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
7043
7120
  severity_: "error",
@@ -7420,7 +7497,8 @@ function $961b5c64bef4662f$export$e2bf8ce7779e827e(props) {
7420
7497
  scroll_restoration_data_: scroll_restoration_data_,
7421
7498
  layout_options_: $i7OB2$createMemo(() => ({
7422
7499
  cols_at_size: $b5cccc8ee7d24677$export$6daf8749b65a1b77(props.cols_at_size),
7423
- ...grid_spacing_override()
7500
+ ...grid_spacing_override(),
7501
+ layout: props.layout || "grid"
7424
7502
  })),
7425
7503
  product_card_template_: product_card_template,
7426
7504
  sorting_query_param_: sorting_query_param_,