@depict-ai/ui 2.0.7 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { add_to_version_info as $b8hua$add_to_version_info, catchify as $b8hua$catchify, slider_fractional_factory as $b8hua$slider_fractional_factory, make_random_classname as $b8hua$make_random_classname, n_col_styling_with_dist as $b8hua$n_col_styling_with_dist, layout_get_visible_recs_without_partial_rows as $b8hua$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $b8hua$layout_get_total_rec_amount_for_row, layout_media_query_header as $b8hua$layout_media_query_header, report as $b8hua$report, Amazing_Slider as $b8hua$Amazing_Slider, slider_snap_css as $b8hua$slider_snap_css, slider_fading_factory as $b8hua$slider_fading_factory, observer as $b8hua$observer, is_safari as $b8hua$is_safari, useExpandingContainer as $b8hua$useExpandingContainer, standard_price_format as $b8hua$standard_price_format, dlog as $b8hua$dlog, hex_to_rgb as $b8hua$hex_to_rgb, relative_luminance_from_rgb as $b8hua$relative_luminance_from_rgb, javascript_media_query as $b8hua$javascript_media_query, fetch_recs as $b8hua$fetch_recs, snakeCasifyObject as $b8hua$snakeCasifyObject, instant_exec_on_suspect_history_change as $b8hua$instant_exec_on_suspect_history_change, base_url as $b8hua$base_url, get_depict_id as $b8hua$get_depict_id, get_user_id as $b8hua$get_user_id, get_session_id as $b8hua$get_session_id, make_url_with_query_params as $b8hua$make_url_with_query_params, fetch_retry as $b8hua$fetch_retry, add_version_query_params as $b8hua$add_version_query_params, dwarn as $b8hua$dwarn, sort_obj as $b8hua$sort_obj, edit_current_page_meta_tags as $b8hua$edit_current_page_meta_tags, use_href_accessor as $b8hua$use_href_accessor, base64_encode_unicode as $b8hua$base64_encode_unicode, base64_decode_unicode as $b8hua$base64_decode_unicode, queueMacroTask as $b8hua$queueMacroTask, make_asyncIterable_exiter as $b8hua$make_asyncIterable_exiter, href_change_ipns as $b8hua$href_change_ipns, ContainedImage as $b8hua$ContainedImage, deparallelize_no_drop as $b8hua$deparallelize_no_drop, ListenableSet as $b8hua$ListenableSet, insert_surfaces as $b8hua$insert_surfaces } from "@depict-ai/utilishared/ES10";
2
- import { createSignal as $b8hua$createSignal, onCleanup as $b8hua$onCleanup, createMemo as $b8hua$createMemo, createResource as $b8hua$createResource, Suspense as $b8hua$Suspense, Show as $b8hua$Show, createRenderEffect as $b8hua$createRenderEffect, createRoot as $b8hua$createRoot, For as $b8hua$For, getOwner as $b8hua$getOwner, runWithOwner as $b8hua$runWithOwner, createEffect as $b8hua$createEffect, untrack as $b8hua$untrack, createUniqueId as $b8hua$createUniqueId, createComputed as $b8hua$createComputed, ErrorBoundary as $b8hua$ErrorBoundary, Index as $b8hua$Index, on as $b8hua$on, batch as $b8hua$batch, createReaction as $b8hua$createReaction } from "solid-js";
1
+ import { add_to_version_info as $b8hua$add_to_version_info, catchify as $b8hua$catchify, slider_fractional_factory as $b8hua$slider_fractional_factory, camelCasifyObject as $b8hua$camelCasifyObject, make_random_classname as $b8hua$make_random_classname, n_col_styling_with_dist as $b8hua$n_col_styling_with_dist, layout_get_visible_recs_without_partial_rows as $b8hua$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $b8hua$layout_get_total_rec_amount_for_row, layout_media_query_header as $b8hua$layout_media_query_header, report as $b8hua$report, Amazing_Slider as $b8hua$Amazing_Slider, slider_snap_css as $b8hua$slider_snap_css, slider_fading_factory as $b8hua$slider_fading_factory, observer as $b8hua$observer, is_safari as $b8hua$is_safari, useExpandingContainer as $b8hua$useExpandingContainer, standard_price_format as $b8hua$standard_price_format, dlog as $b8hua$dlog, hex_to_rgb as $b8hua$hex_to_rgb, relative_luminance_from_rgb as $b8hua$relative_luminance_from_rgb, javascript_media_query as $b8hua$javascript_media_query, fetch_recs as $b8hua$fetch_recs, snakeCasifyObject as $b8hua$snakeCasifyObject, instant_exec_on_suspect_history_change as $b8hua$instant_exec_on_suspect_history_change, base_url as $b8hua$base_url, get_depict_id as $b8hua$get_depict_id, get_user_id as $b8hua$get_user_id, get_session_id as $b8hua$get_session_id, make_url_with_query_params as $b8hua$make_url_with_query_params, fetch_retry as $b8hua$fetch_retry, add_version_query_params as $b8hua$add_version_query_params, dwarn as $b8hua$dwarn, sort_obj as $b8hua$sort_obj, edit_current_page_meta_tags as $b8hua$edit_current_page_meta_tags, use_href_accessor as $b8hua$use_href_accessor, base64_encode_unicode as $b8hua$base64_encode_unicode, base64_decode_unicode as $b8hua$base64_decode_unicode, queueMacroTask as $b8hua$queueMacroTask, make_asyncIterable_exiter as $b8hua$make_asyncIterable_exiter, href_change_ipns as $b8hua$href_change_ipns, ContainedImage as $b8hua$ContainedImage, deparallelize_no_drop as $b8hua$deparallelize_no_drop, ListenableSet as $b8hua$ListenableSet, insert_surfaces as $b8hua$insert_surfaces } from "@depict-ai/utilishared/ES10";
2
+ import { createSignal as $b8hua$createSignal, onCleanup as $b8hua$onCleanup, createMemo as $b8hua$createMemo, createResource as $b8hua$createResource, Suspense as $b8hua$Suspense, Show as $b8hua$Show, createRenderEffect as $b8hua$createRenderEffect, createRoot as $b8hua$createRoot, For as $b8hua$For, getOwner as $b8hua$getOwner, runWithOwner as $b8hua$runWithOwner, createEffect as $b8hua$createEffect, createUniqueId as $b8hua$createUniqueId, untrack as $b8hua$untrack, createComputed as $b8hua$createComputed, ErrorBoundary as $b8hua$ErrorBoundary, Index as $b8hua$Index, on as $b8hua$on, batch as $b8hua$batch, createReaction as $b8hua$createReaction } from "solid-js";
3
3
  import { ssr as $b8hua$ssr, ssrHydrationKey as $b8hua$ssrHydrationKey, escape as $b8hua$escape, createComponent as $b8hua$createComponent, mergeProps as $b8hua$mergeProps, isServer as $b8hua$isServer, ssrElement as $b8hua$ssrElement, ssrClassList as $b8hua$ssrClassList, insert as $b8hua$insert, ssrAttribute as $b8hua$ssrAttribute, ssrStyle as $b8hua$ssrStyle, Dynamic as $b8hua$Dynamic } from "solid-js/web";
4
4
  import $b8hua$babelruntimehelpersclassPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet";
5
5
  import $b8hua$babelruntimehelpersclassPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
@@ -8,7 +8,7 @@ import $b8hua$babelruntimehelpersdefineProperty from "@babel/runtime/helpers/def
8
8
  /*! Depict.ai search and product listing SDK */
9
9
  import { register_es_version } from "../../multi_import_deduplicator.mjs";
10
10
  register_es_version("ui", "ES10");
11
- const $8db9a15135765c11$export$83d89fbfd8236492 = "2.0.7";
11
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "2.0.9";
12
12
 
13
13
  /** @jsxImportSource solid-js */
14
14
 
@@ -65,7 +65,7 @@ const $a9c7ba6087881ac2$export$6daf8749b65a1b77 = cols_at_size => {
65
65
  return $a9c7ba6087881ac2$var$transform_elements(sorted_cols_at_size);
66
66
  };
67
67
  function $ca55612a53dbbdd2$export$a2cc176055f8f08() {
68
- const text = "Please try setting `colsAtSize` on the `SearchPage`/`CategoryPage` components to change the grid before setting it with CSS. If you do with CSS, set `ColsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
68
+ const text = "Please try setting `columnsAtSize` on the `SearchPage`/`CategoryPage` components to change the grid before setting it with CSS. If you do with CSS, set `ColsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
69
69
  return (0, $b8hua$isServer) ? {
70
70
  t: "<!-- ".concat(text, " -->")
71
71
  } : document.createComment(text);
@@ -196,6 +196,7 @@ function $2d7bad8684bc7f44$export$7f8bd308237ab5a5(get_displays_) {
196
196
  });
197
197
  return displays_by_key_;
198
198
  }
199
+ const $2d7bad8684bc7f44$var$result_ids = ["search_result_id", "product_listing_result_id", "recommendation_id"];
199
200
  function $2d7bad8684bc7f44$export$43f0fb951fcb0c54(_ref) {
200
201
  let {
201
202
  displays_by_key_: displays_by_key_,
@@ -210,17 +211,25 @@ function $2d7bad8684bc7f44$export$43f0fb951fcb0c54(_ref) {
210
211
  },
211
212
  children: (product_id, index) => {
212
213
  const owner = $b8hua$getOwner();
213
- const display_accessor = $b8hua$createMemo(() => displays_by_key_().get(product_id));
214
- const [product_card_resource] = $b8hua$createResource(display_accessor,
215
- // re-render when the reference to the display object changes
216
- // this should only be the case when the merchant or market changes and the new request has completed
217
- display => {
214
+ const display_accessor = $b8hua$createMemo(prev => {
215
+ const new_display = displays_by_key_().get(product_id);
216
+ if (prev && $2d7bad8684bc7f44$var$deep_equal(prev, new_display))
217
+ // If displays are identical, they haven't changed due to merchant/market changing OR we made a new query and the displays are the same. Return the old display (same object reference) to avoid re-rendering.
218
+ // This doesn't work if people mutate the displays from within the template but we hope they don't
219
+ // (We can't know if the display changing is due to merchant/market changing or a new query otherwise and don't want to run into https://gitlab.com/depict-ai/depict.ai/-/merge_requests/6890/diffs)
220
+ return prev;
221
+ return new_display;
222
+ });
223
+ const [product_card_resource] = $b8hua$createResource(() => [merchant_(), market_(), display_accessor()],
224
+ // re-render when the reference to the display object changes or the merchant or market changes
225
+ // (We don't want to re-render if nothing has changed)
226
+ _ref2 => {
227
+ let [merchant, market, display] = _ref2;
218
228
  // get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
219
229
  return product_card_template_(display, {
220
230
  set_on_index_change: fn => $b8hua$runWithOwner(owner, () => $b8hua$createEffect(() => fn(index()))),
221
- merchant: $b8hua$untrack(merchant_),
222
- // 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
223
- market: $b8hua$untrack(market_) // recommendation_grid can provide a sneaky undefined here just FYI
231
+ merchant: merchant,
232
+ market: market // recommendation_grid can provide a sneaky undefined here just FYI
224
233
  });
225
234
  });
226
235
 
@@ -235,15 +244,13 @@ function $2d7bad8684bc7f44$export$43f0fb951fcb0c54(_ref) {
235
244
  elements.push(element);
236
245
  // Add tracking ids
237
246
  if (!(element instanceof HTMLElement)) continue; // Apparently only HTMLElements have dataset
238
- const {
239
- dataset: dataset
240
- } = element;
241
- const {
242
- search_result_id: search_result_id,
243
- product_listing_result_id: product_listing_result_id,
244
- recommendation_id: recommendation_id
245
- } = display;
246
- if (search_result_id) dataset.searchResultId = search_result_id;else if (product_listing_result_id) dataset.productListingResultId = product_listing_result_id;else if (recommendation_id) dataset.recommendationId = recommendation_id;
247
+ for (let i = 0; i < $2d7bad8684bc7f44$var$result_ids.length; i++) {
248
+ const id = $2d7bad8684bc7f44$var$result_ids[i];
249
+ const value = display[id];
250
+ if (value) Object.assign(element.dataset, $b8hua$camelCasifyObject({
251
+ [id]: value
252
+ }));
253
+ }
247
254
  }
248
255
  do_per_elements_ === null || do_per_elements_ === void 0 || do_per_elements_(elements, index);
249
256
  });
@@ -251,6 +258,23 @@ function $2d7bad8684bc7f44$export$43f0fb951fcb0c54(_ref) {
251
258
  }
252
259
  });
253
260
  }
261
+ // Source: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/
262
+ function $2d7bad8684bc7f44$var$deep_equal(object1, object2) {
263
+ const keys1 = Object.keys(object1);
264
+ const keys2 = Object.keys(object2);
265
+ if (keys1.length !== keys2.length) return false;
266
+ for (const key of keys1) {
267
+ if ($2d7bad8684bc7f44$var$result_ids.includes(key)) continue; // ignore result ids that change per response
268
+ const val1 = object1[key];
269
+ const val2 = object2[key];
270
+ const areObjects = $2d7bad8684bc7f44$var$is_object(val1) && $2d7bad8684bc7f44$var$is_object(val2);
271
+ if (areObjects && !$2d7bad8684bc7f44$var$deep_equal(val1, val2) || !areObjects && val1 !== val2) return false;
272
+ }
273
+ return true;
274
+ }
275
+ function $2d7bad8684bc7f44$var$is_object(object) {
276
+ return object != null && typeof object === "object";
277
+ }
254
278
 
255
279
  // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
256
280
  class $f3b7124b76123e44$export$e1d52e4f0c7557a1 extends Error {}
@@ -522,7 +546,14 @@ function $83e8cf2c0b87a58a$export$23fca46f3143581f(component, error_message) {
522
546
  return component_in_error_boundary(elements => {
523
547
  const have_multiple = Array.isArray(elements);
524
548
  if (have_multiple ? !(elements !== null && elements !== void 0 && elements.length) : !elements) return;
525
- (0, $b8hua$observer).onremoved(have_multiple ? elements[0] : elements, dispose);
549
+ (0, $b8hua$observer).onremoved(have_multiple ? elements[0] : elements, _ref => {
550
+ let {
551
+ element: element
552
+ } = _ref;
553
+ if (document.documentElement.contains(element)) return; // If element has instantly been re-inserted, don't dispose
554
+ // See https://depictaiworkspace.slack.com/archives/C050GHEPBTR/p1695809102791259?thread_ts=1695106805.459729&cid=C050GHEPBTR
555
+ dispose();
556
+ });
526
557
  });
527
558
  });else
528
559
  // we're already in a root so cleanups are handled
@@ -572,44 +603,43 @@ function $e3efeb558d952696$export$7da560f849543dff(_ref) {
572
603
  return recommendations_resource_.loading || ((_recommendations_reso = recommendations_resource_()) === null || _recommendations_reso === void 0 ? void 0 : _recommendations_reso.length);
573
604
  });
574
605
  const num_placeholders_ = () => 20;
575
- return $b8hua$createComponent((0, $b8hua$Show), {
576
- get when() {
577
- return is_showing_something();
606
+ const elements = $b8hua$ssr($e3efeb558d952696$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape($ca55612a53dbbdd2$export$a2cc176055f8f08()), $b8hua$escape($b8hua$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), $b8hua$mergeProps({
607
+ get rows() {
608
+ return rows_object_();
578
609
  },
610
+ layout: "grid",
611
+ element_attributes: {
612
+ class: "cards"
613
+ }
614
+ }, layout_options_, {
579
615
  get children() {
580
- return $b8hua$ssr($e3efeb558d952696$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape($ca55612a53dbbdd2$export$a2cc176055f8f08()), $b8hua$escape($b8hua$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), $b8hua$mergeProps({
581
- get rows() {
582
- return rows_object_();
616
+ return $b8hua$createComponent((0, $b8hua$Suspense), {
617
+ get fallback() {
618
+ return $bdd80c7862246dc2$export$f33414a4df0afd3f({
619
+ num_placeholders_: num_placeholders_,
620
+ product_card_template_: product_card_template_
621
+ });
583
622
  },
584
- layout: "grid",
585
- element_attributes: {
586
- class: "cards"
587
- }
588
- }, layout_options_, {
589
623
  get children() {
590
- return $b8hua$createComponent((0, $b8hua$Suspense), {
591
- get fallback() {
592
- return $bdd80c7862246dc2$export$f33414a4df0afd3f({
593
- num_placeholders_: num_placeholders_,
594
- product_card_template_: product_card_template_
595
- });
596
- },
597
- get children() {
598
- return (() => {
599
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
600
- const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($b8hua$createMemo(() => recommendations_resource_() || []));
601
- return $2d7bad8684bc7f44$export$43f0fb951fcb0c54({
602
- displays_by_key_: displays_by_key_,
603
- merchant_: merchant_,
604
- market_: market_,
605
- product_card_template_: product_card_template_
606
- });
607
- })();
608
- }
609
- });
624
+ return (() => {
625
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
626
+ const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($b8hua$createMemo(() => recommendations_resource_() || []));
627
+ return $2d7bad8684bc7f44$export$43f0fb951fcb0c54({
628
+ displays_by_key_: displays_by_key_,
629
+ merchant_: merchant_,
630
+ market_: market_,
631
+ product_card_template_: product_card_template_
632
+ });
633
+ })();
610
634
  }
611
- }))));
635
+ });
612
636
  }
637
+ }))));
638
+ return $b8hua$createComponent((0, $b8hua$Show), {
639
+ get when() {
640
+ return is_showing_something();
641
+ },
642
+ children: elements
613
643
  });
614
644
  }
615
645
  const $b432b11321ad4c97$var$_tmpl$ = ["<button", ' class="show-more major" type="button">', "</button>"],
@@ -3653,7 +3683,10 @@ function $45a8953d760b5e58$export$a1fd619a4743ca08(_ref) {
3653
3683
  const [get_extra_displays, set_extra_displays_] = $b8hua$createSignal([], {
3654
3684
  equals: false
3655
3685
  });
3656
- const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($b8hua$createMemo(() => [...plp_results_().displays, ...get_extra_displays()]));
3686
+ const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($b8hua$createMemo(() => {
3687
+ var _plp_results_;
3688
+ return [...(((_plp_results_ = plp_results_()) === null || _plp_results_ === void 0 ? void 0 : _plp_results_.displays) || []), ...get_extra_displays()];
3689
+ }));
3657
3690
  const percentage_in_view_ = $e6dd9dfff4603d8c$export$63dd0350f8559dda({
3658
3691
  get_last_result_in_viewport_: get_last_result_in_viewport_,
3659
3692
  displays_by_key_: displays_by_key_,
@@ -3773,18 +3806,18 @@ function $7faea0096f14b59b$export$3925f87b1545cfc6(_ref) {
3773
3806
  layout_options_: layout_options_,
3774
3807
  sort_or_filter_open_: sort_or_filter_open_
3775
3808
  });
3776
- $b8hua$createComputed(() => {
3777
- if (!is_loading_()) return;
3778
- set_should_have_placeholders_rendered(true);
3779
- set_suspense_is_blocked(false);
3780
- is_just_after_plp_results_update = true;
3781
- });
3782
3809
  const block_suspense_if_needed = () => {
3783
3810
  if (!is_just_after_plp_results_update) return;
3784
3811
  is_just_after_plp_results_update = false;
3785
3812
  fallback_is_alive = false;
3786
3813
  set_suspense_is_blocked(true);
3787
3814
  };
3815
+ $b8hua$createComputed(() => {
3816
+ if (!is_loading_()) return;
3817
+ set_should_have_placeholders_rendered(true);
3818
+ set_suspense_is_blocked(false);
3819
+ is_just_after_plp_results_update = true;
3820
+ });
3788
3821
  $b8hua$createEffect($b8hua$on(plp_results_, () => {
3789
3822
  if (!fallback_is_alive) {
3790
3823
  // if all product card rendering functions after the initial rendering are synchronous the suspense boundary will never go into the fallback, so we don't know when they have finished rendering, and we can't block the suspense. Therefore, we're just doing it with this effect
@@ -3794,6 +3827,48 @@ function $7faea0096f14b59b$export$3925f87b1545cfc6(_ref) {
3794
3827
  }, {
3795
3828
  defer: true
3796
3829
  }));
3830
+ /*
3831
+ This suspense ensures that if someone has async templates, we still show placeholders until the product cards actually have finished rendering (automagically since they're createResource's)
3832
+ We're creating it outside the <Show> so that we can benefit from <For>'s optimisation between changing results
3833
+ (For the whole idea of the displays being cached to work we can't tear down and re-run ProductCards for every new result.
3834
+ We have to keep ProductCards alive, but hidden, and feed them new data as soon as we had it)
3835
+ */
3836
+ const product_cards_when_data = $b8hua$createComponent((0, $b8hua$Suspense), {
3837
+ get fallback() {
3838
+ return (() => {
3839
+ fallback_is_alive = true;
3840
+ $b8hua$onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
3841
+ return $b8hua$createMemo(() => {
3842
+ // We need to be able to block the suspense since when async product cards are *rendering* we want to show the placeholders on initial load but not when loading more
3843
+ // In future we could have individual suspense's for each product card, but that's too much for now
3844
+ if (get_suspense_is_blocked()) return suspense_contents;
3845
+ set_should_have_placeholders_rendered(true); // just in case
3846
+ $b8hua$onCleanup(() => set_should_have_placeholders_rendered(false));
3847
+ return rendered_placeholders; // I lifted the placeholders into the memo since we don't want to re-render them when switching from <Show> to <Suspense>
3848
+ });
3849
+ })();
3850
+ },
3851
+
3852
+ get children() {
3853
+ return (() => {
3854
+ suspense_contents = $45a8953d760b5e58$export$a1fd619a4743ca08({
3855
+ product_card_template_: product_card_template_,
3856
+ plp_results_: plp_results_,
3857
+ last_result_in_viewport_: last_result_in_viewport_,
3858
+ first_result_in_viewport_: first_result_in_viewport_,
3859
+ market_: market_,
3860
+ merchant_: merchant_,
3861
+ all_products_loaded_: all_products_loaded_,
3862
+ min_products_to_fetch_: min_products_to_fetch_,
3863
+ query_base_: query_base_,
3864
+ depict_api_: depict_api_,
3865
+ is_loading_: is_loading_
3866
+ });
3867
+ $b8hua$onCleanup(() => suspense_contents = undefined);
3868
+ return suspense_contents;
3869
+ })();
3870
+ }
3871
+ });
3797
3872
  return [$ca55612a53dbbdd2$export$a2cc176055f8f08(), $b8hua$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), {
3798
3873
  get cols_at_size() {
3799
3874
  return modified_cols_at_size();
@@ -3817,44 +3892,7 @@ function $7faea0096f14b59b$export$3925f87b1545cfc6(_ref) {
3817
3892
  get fallback() {
3818
3893
  return rendered_placeholders();
3819
3894
  },
3820
- get children() {
3821
- return $b8hua$createComponent((0, $b8hua$Suspense), {
3822
- get fallback() {
3823
- return (() => {
3824
- fallback_is_alive = true;
3825
- $b8hua$onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
3826
- return $b8hua$createMemo(() => {
3827
- // We need to be able to block the suspense since when async product cards are *rendering* we want to show the placeholders on initial load but not when loading more
3828
- // In future we could have individual suspense's for each product card, but that's too much for now
3829
- if (get_suspense_is_blocked()) return suspense_contents;
3830
- set_should_have_placeholders_rendered(true); // just in case
3831
- $b8hua$onCleanup(() => set_should_have_placeholders_rendered(false));
3832
- return rendered_placeholders; // I lifted the placeholders into the memo since we don't want to re-render them when switching from <Show> to <Suspense>
3833
- });
3834
- })();
3835
- },
3836
-
3837
- get children() {
3838
- return (() => {
3839
- suspense_contents = $45a8953d760b5e58$export$a1fd619a4743ca08({
3840
- product_card_template_: product_card_template_,
3841
- plp_results_: plp_results_,
3842
- last_result_in_viewport_: last_result_in_viewport_,
3843
- first_result_in_viewport_: first_result_in_viewport_,
3844
- market_: market_,
3845
- merchant_: merchant_,
3846
- all_products_loaded_: all_products_loaded_,
3847
- min_products_to_fetch_: min_products_to_fetch_,
3848
- query_base_: query_base_,
3849
- depict_api_: depict_api_,
3850
- is_loading_: is_loading_
3851
- });
3852
- $b8hua$onCleanup(() => suspense_contents = undefined);
3853
- return suspense_contents;
3854
- })();
3855
- }
3856
- });
3857
- }
3895
+ children: product_cards_when_data
3858
3896
  });
3859
3897
  }
3860
3898
  })];
@@ -6544,7 +6582,8 @@ function $8ef6232475d44150$export$7de92c4c2205ebf3(_ref) {
6544
6582
  product_card_template_: product_card_template_,
6545
6583
  showing_recommendation_rows_: showing_recommendation_rows_,
6546
6584
  view_more_button_ = true,
6547
- layout_options_: layout_options_
6585
+ layout_options_: layout_options_,
6586
+ all_products_loaded_: all_products_loaded_
6548
6587
  } = _ref;
6549
6588
  const [get_showing_recommendation_rows] = showing_recommendation_rows_; // We reset this in after_submit in search.tsx FYI
6550
6589
  const rows_object = view_more_button_ ? $8ef6232475d44150$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
@@ -6557,42 +6596,42 @@ function $8ef6232475d44150$export$7de92c4c2205ebf3(_ref) {
6557
6596
  let [per_column] = _ref2;
6558
6597
  return per_column;
6559
6598
  })));
6560
- return $b8hua$createComponent((0, $b8hua$Show), {
6561
- get when() {
6562
- return is_showing_something();
6563
- },
6599
+ // Don't tear down elements every time one updates the page - don't put them within <Show>
6600
+ const elements = $b8hua$ssr($8ef6232475d44150$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(i18n_.search_recs_title_()), $b8hua$escape($ca55612a53dbbdd2$export$a2cc176055f8f08()), $b8hua$escape($b8hua$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), $b8hua$mergeProps({
6601
+ rows: rows_object,
6602
+ layout: "grid",
6603
+ element_attributes: {
6604
+ class: "cards"
6605
+ }
6606
+ }, layout_options_, {
6564
6607
  get children() {
6565
- return $b8hua$ssr($8ef6232475d44150$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(i18n_.search_recs_title_()), $b8hua$escape($ca55612a53dbbdd2$export$a2cc176055f8f08()), $b8hua$escape($b8hua$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), $b8hua$mergeProps({
6566
- rows: rows_object,
6567
- layout: "grid",
6568
- element_attributes: {
6569
- class: "cards"
6570
- }
6571
- }, layout_options_, {
6572
- get children() {
6573
- return $b8hua$createComponent((0, $b8hua$Suspense), {
6574
- get fallback() {
6575
- return $bdd80c7862246dc2$export$f33414a4df0afd3f({
6576
- num_placeholders_: num_placeholders_,
6577
- product_card_template_: product_card_template_
6578
- });
6579
- },
6580
- get children() {
6581
- return (() => {
6582
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
6583
- const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($b8hua$createMemo(() => recommendations_resource() || []));
6584
- return $2d7bad8684bc7f44$export$43f0fb951fcb0c54({
6585
- displays_by_key_: displays_by_key_,
6586
- merchant_: $b8hua$createMemo(() => search_query_base_().tenant),
6587
- market_: $b8hua$createMemo(() => search_query_base_().market),
6588
- product_card_template_: product_card_template_
6589
- });
6590
- })();
6591
- }
6608
+ return $b8hua$createComponent((0, $b8hua$Suspense), {
6609
+ get fallback() {
6610
+ return $bdd80c7862246dc2$export$f33414a4df0afd3f({
6611
+ num_placeholders_: num_placeholders_,
6612
+ product_card_template_: product_card_template_
6592
6613
  });
6614
+ },
6615
+ get children() {
6616
+ return (() => {
6617
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
6618
+ const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($b8hua$createMemo(() => recommendations_resource() || []));
6619
+ return $2d7bad8684bc7f44$export$43f0fb951fcb0c54({
6620
+ displays_by_key_: displays_by_key_,
6621
+ merchant_: $b8hua$createMemo(() => search_query_base_().tenant),
6622
+ market_: $b8hua$createMemo(() => search_query_base_().market),
6623
+ product_card_template_: product_card_template_
6624
+ });
6625
+ })();
6593
6626
  }
6594
- }))));
6627
+ });
6595
6628
  }
6629
+ }))));
6630
+ return $b8hua$createComponent((0, $b8hua$Show), {
6631
+ get when() {
6632
+ return is_showing_something() && all_products_loaded_();
6633
+ },
6634
+ children: elements
6596
6635
  });
6597
6636
  }
6598
6637
  function $8ef6232475d44150$var$make_state_saved_rows(_ref3, i18n_) {
@@ -8714,9 +8753,7 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
8714
8753
  });
8715
8754
  }
8716
8755
  })), $b8hua$escape($b8hua$createComponent((0, $b8hua$Show), {
8717
- get when() {
8718
- return get_all_products_loaded() && !disable_search_recommendations_;
8719
- },
8756
+ when: !disable_search_recommendations_,
8720
8757
  keyed: false,
8721
8758
  get children() {
8722
8759
  return $b8hua$createComponent((0, $74777e8fe65b3dcb$export$b69d0d92862de18b), {
@@ -8735,7 +8772,8 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
8735
8772
  },
8736
8773
  showing_recommendation_rows_: showing_recommendation_rows_,
8737
8774
  view_more_button_: search_recs_view_more_,
8738
- product_card_template_: product_card_template_
8775
+ product_card_template_: product_card_template_,
8776
+ all_products_loaded_: get_all_products_loaded
8739
8777
  });
8740
8778
  }
8741
8779
  });