@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.
package/ES10/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { add_to_version_info as $8tj43$add_to_version_info, catchify as $8tj43$catchify, slider_fractional_factory as $8tj43$slider_fractional_factory, make_random_classname as $8tj43$make_random_classname, n_col_styling_with_dist as $8tj43$n_col_styling_with_dist, layout_get_visible_recs_without_partial_rows as $8tj43$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $8tj43$layout_get_total_rec_amount_for_row, layout_media_query_header as $8tj43$layout_media_query_header, report as $8tj43$report, Amazing_Slider as $8tj43$Amazing_Slider, slider_snap_css as $8tj43$slider_snap_css, slider_fading_factory as $8tj43$slider_fading_factory, observer as $8tj43$observer, is_safari as $8tj43$is_safari, useExpandingContainer as $8tj43$useExpandingContainer, standard_price_format as $8tj43$standard_price_format, dlog as $8tj43$dlog, hex_to_rgb as $8tj43$hex_to_rgb, relative_luminance_from_rgb as $8tj43$relative_luminance_from_rgb, javascript_media_query as $8tj43$javascript_media_query, fetch_recs as $8tj43$fetch_recs, snakeCasifyObject as $8tj43$snakeCasifyObject, instant_exec_on_suspect_history_change as $8tj43$instant_exec_on_suspect_history_change, base_url as $8tj43$base_url, get_depict_id as $8tj43$get_depict_id, get_user_id as $8tj43$get_user_id, get_session_id as $8tj43$get_session_id, make_url_with_query_params as $8tj43$make_url_with_query_params, fetch_retry as $8tj43$fetch_retry, add_version_query_params as $8tj43$add_version_query_params, dwarn as $8tj43$dwarn, sort_obj as $8tj43$sort_obj, edit_current_page_meta_tags as $8tj43$edit_current_page_meta_tags, use_href_accessor as $8tj43$use_href_accessor, base64_encode_unicode as $8tj43$base64_encode_unicode, base64_decode_unicode as $8tj43$base64_decode_unicode, queueMacroTask as $8tj43$queueMacroTask, is_debug as $8tj43$is_debug, make_asyncIterable_exiter as $8tj43$make_asyncIterable_exiter, href_change_ipns as $8tj43$href_change_ipns, ContainedImage as $8tj43$ContainedImage, buildThresholdList as $8tj43$buildThresholdList, deparallelize_no_drop as $8tj43$deparallelize_no_drop, ListenableSet as $8tj43$ListenableSet, insert_surfaces as $8tj43$insert_surfaces } from "@depict-ai/utilishared/ES10";
2
- import { createSignal as $8tj43$createSignal, onCleanup as $8tj43$onCleanup, createMemo as $8tj43$createMemo, createResource as $8tj43$createResource, Suspense as $8tj43$Suspense, Show as $8tj43$Show, createRenderEffect as $8tj43$createRenderEffect, createRoot as $8tj43$createRoot, For as $8tj43$For, getOwner as $8tj43$getOwner, runWithOwner as $8tj43$runWithOwner, createEffect as $8tj43$createEffect, untrack as $8tj43$untrack, createUniqueId as $8tj43$createUniqueId, createComputed as $8tj43$createComputed, ErrorBoundary as $8tj43$ErrorBoundary, Index as $8tj43$Index, on as $8tj43$on, batch as $8tj43$batch, createReaction as $8tj43$createReaction } from "solid-js";
1
+ import { add_to_version_info as $8tj43$add_to_version_info, catchify as $8tj43$catchify, slider_fractional_factory as $8tj43$slider_fractional_factory, camelCasifyObject as $8tj43$camelCasifyObject, make_random_classname as $8tj43$make_random_classname, n_col_styling_with_dist as $8tj43$n_col_styling_with_dist, layout_get_visible_recs_without_partial_rows as $8tj43$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $8tj43$layout_get_total_rec_amount_for_row, layout_media_query_header as $8tj43$layout_media_query_header, report as $8tj43$report, Amazing_Slider as $8tj43$Amazing_Slider, slider_snap_css as $8tj43$slider_snap_css, slider_fading_factory as $8tj43$slider_fading_factory, observer as $8tj43$observer, is_safari as $8tj43$is_safari, useExpandingContainer as $8tj43$useExpandingContainer, standard_price_format as $8tj43$standard_price_format, dlog as $8tj43$dlog, hex_to_rgb as $8tj43$hex_to_rgb, relative_luminance_from_rgb as $8tj43$relative_luminance_from_rgb, javascript_media_query as $8tj43$javascript_media_query, fetch_recs as $8tj43$fetch_recs, snakeCasifyObject as $8tj43$snakeCasifyObject, instant_exec_on_suspect_history_change as $8tj43$instant_exec_on_suspect_history_change, base_url as $8tj43$base_url, get_depict_id as $8tj43$get_depict_id, get_user_id as $8tj43$get_user_id, get_session_id as $8tj43$get_session_id, make_url_with_query_params as $8tj43$make_url_with_query_params, fetch_retry as $8tj43$fetch_retry, add_version_query_params as $8tj43$add_version_query_params, dwarn as $8tj43$dwarn, sort_obj as $8tj43$sort_obj, edit_current_page_meta_tags as $8tj43$edit_current_page_meta_tags, use_href_accessor as $8tj43$use_href_accessor, base64_encode_unicode as $8tj43$base64_encode_unicode, base64_decode_unicode as $8tj43$base64_decode_unicode, queueMacroTask as $8tj43$queueMacroTask, is_debug as $8tj43$is_debug, make_asyncIterable_exiter as $8tj43$make_asyncIterable_exiter, href_change_ipns as $8tj43$href_change_ipns, ContainedImage as $8tj43$ContainedImage, buildThresholdList as $8tj43$buildThresholdList, deparallelize_no_drop as $8tj43$deparallelize_no_drop, ListenableSet as $8tj43$ListenableSet, insert_surfaces as $8tj43$insert_surfaces } from "@depict-ai/utilishared/ES10";
2
+ import { createSignal as $8tj43$createSignal, onCleanup as $8tj43$onCleanup, createMemo as $8tj43$createMemo, createResource as $8tj43$createResource, Suspense as $8tj43$Suspense, Show as $8tj43$Show, createRenderEffect as $8tj43$createRenderEffect, createRoot as $8tj43$createRoot, For as $8tj43$For, getOwner as $8tj43$getOwner, runWithOwner as $8tj43$runWithOwner, createEffect as $8tj43$createEffect, createUniqueId as $8tj43$createUniqueId, untrack as $8tj43$untrack, createComputed as $8tj43$createComputed, ErrorBoundary as $8tj43$ErrorBoundary, Index as $8tj43$Index, on as $8tj43$on, batch as $8tj43$batch, createReaction as $8tj43$createReaction } from "solid-js";
3
3
  import { template as $8tj43$template, getNextElement as $8tj43$getNextElement, insert as $8tj43$insert, createComponent as $8tj43$createComponent, mergeProps as $8tj43$mergeProps, isServer as $8tj43$isServer, spread as $8tj43$spread, runHydrationEvents as $8tj43$runHydrationEvents, addEventListener as $8tj43$addEventListener, className as $8tj43$className, memo as $8tj43$memo, delegateEvents as $8tj43$delegateEvents, effect as $8tj43$effect, classList as $8tj43$classList, setAttribute as $8tj43$setAttribute, getNextMarker as $8tj43$getNextMarker, style as $8tj43$style, Dynamic as $8tj43$Dynamic, use as $8tj43$use } from "solid-js/web";
4
4
  import $8tj43$babelruntimehelpersclassPrivateFieldSet from "@babel/runtime/helpers/classPrivateFieldSet";
5
5
  import $8tj43$babelruntimehelpersclassPrivateFieldGet from "@babel/runtime/helpers/classPrivateFieldGet";
@@ -8,7 +8,7 @@ import $8tj43$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, $8tj43$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 = $8tj43$getOwner();
213
- const display_accessor = $8tj43$createMemo(() => displays_by_key_().get(product_id));
214
- const [product_card_resource] = $8tj43$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 = $8tj43$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] = $8tj43$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 => $8tj43$runWithOwner(owner, () => $8tj43$createEffect(() => fn(index()))),
221
- merchant: $8tj43$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: $8tj43$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, $8tj43$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 {}
@@ -581,7 +605,14 @@ function $83e8cf2c0b87a58a$export$23fca46f3143581f(component, error_message) {
581
605
  return component_in_error_boundary(elements => {
582
606
  const have_multiple = Array.isArray(elements);
583
607
  if (have_multiple ? !(elements !== null && elements !== void 0 && elements.length) : !elements) return;
584
- (0, $8tj43$observer).onremoved(have_multiple ? elements[0] : elements, dispose);
608
+ (0, $8tj43$observer).onremoved(have_multiple ? elements[0] : elements, _ref => {
609
+ let {
610
+ element: element
611
+ } = _ref;
612
+ if (document.documentElement.contains(element)) return; // If element has instantly been re-inserted, don't dispose
613
+ // See https://depictaiworkspace.slack.com/archives/C050GHEPBTR/p1695809102791259?thread_ts=1695106805.459729&cid=C050GHEPBTR
614
+ dispose();
615
+ });
585
616
  });
586
617
  });else
587
618
  // we're already in a root so cleanups are handled
@@ -635,51 +666,52 @@ function $e3efeb558d952696$export$7da560f849543dff(_ref) {
635
666
  return recommendations_resource_.loading || ((_recommendations_reso = recommendations_resource_()) === null || _recommendations_reso === void 0 ? void 0 : _recommendations_reso.length);
636
667
  });
637
668
  const num_placeholders_ = () => 20;
669
+ const elements = (() => {
670
+ const _el$ = $8tj43$getNextElement($e3efeb558d952696$var$_tmpl$),
671
+ _el$2 = _el$.firstChild,
672
+ [_el$3, _co$] = $8tj43$getNextMarker(_el$2.nextSibling),
673
+ _el$4 = _el$3.nextSibling,
674
+ [_el$5, _co$2] = $8tj43$getNextMarker(_el$4.nextSibling);
675
+ $8tj43$insert(_el$, (0, $ca55612a53dbbdd2$export$a2cc176055f8f08), _el$3, _co$);
676
+ $8tj43$insert(_el$, $8tj43$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), $8tj43$mergeProps({
677
+ get rows() {
678
+ return rows_object_();
679
+ },
680
+ layout: "grid",
681
+ element_attributes: {
682
+ class: "cards"
683
+ }
684
+ }, layout_options_, {
685
+ get children() {
686
+ return $8tj43$createComponent((0, $8tj43$Suspense), {
687
+ get fallback() {
688
+ return $bdd80c7862246dc2$export$f33414a4df0afd3f({
689
+ num_placeholders_: num_placeholders_,
690
+ product_card_template_: product_card_template_
691
+ });
692
+ },
693
+ get children() {
694
+ return (() => {
695
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
696
+ const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($8tj43$createMemo(() => recommendations_resource_() || []));
697
+ return $2d7bad8684bc7f44$export$43f0fb951fcb0c54({
698
+ displays_by_key_: displays_by_key_,
699
+ merchant_: merchant_,
700
+ market_: market_,
701
+ product_card_template_: product_card_template_
702
+ });
703
+ })();
704
+ }
705
+ });
706
+ }
707
+ })), _el$5, _co$2);
708
+ return _el$;
709
+ })();
638
710
  return $8tj43$createComponent((0, $8tj43$Show), {
639
711
  get when() {
640
712
  return is_showing_something();
641
713
  },
642
- get children() {
643
- const _el$ = $8tj43$getNextElement($e3efeb558d952696$var$_tmpl$),
644
- _el$2 = _el$.firstChild,
645
- [_el$3, _co$] = $8tj43$getNextMarker(_el$2.nextSibling),
646
- _el$4 = _el$3.nextSibling,
647
- [_el$5, _co$2] = $8tj43$getNextMarker(_el$4.nextSibling);
648
- $8tj43$insert(_el$, (0, $ca55612a53dbbdd2$export$a2cc176055f8f08), _el$3, _co$);
649
- $8tj43$insert(_el$, $8tj43$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), $8tj43$mergeProps({
650
- get rows() {
651
- return rows_object_();
652
- },
653
- layout: "grid",
654
- element_attributes: {
655
- class: "cards"
656
- }
657
- }, layout_options_, {
658
- get children() {
659
- return $8tj43$createComponent((0, $8tj43$Suspense), {
660
- get fallback() {
661
- return $bdd80c7862246dc2$export$f33414a4df0afd3f({
662
- num_placeholders_: num_placeholders_,
663
- product_card_template_: product_card_template_
664
- });
665
- },
666
- get children() {
667
- return (() => {
668
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
669
- const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($8tj43$createMemo(() => recommendations_resource_() || []));
670
- return $2d7bad8684bc7f44$export$43f0fb951fcb0c54({
671
- displays_by_key_: displays_by_key_,
672
- merchant_: merchant_,
673
- market_: market_,
674
- product_card_template_: product_card_template_
675
- });
676
- })();
677
- }
678
- });
679
- }
680
- })), _el$5, _co$2);
681
- return _el$;
682
- }
714
+ children: elements
683
715
  });
684
716
  }
685
717
  const $b432b11321ad4c97$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<button class="show-more major" type="button"></button>`, 2),
@@ -4558,7 +4590,10 @@ function $45a8953d760b5e58$export$a1fd619a4743ca08(_ref) {
4558
4590
  const [get_extra_displays, set_extra_displays_] = $8tj43$createSignal([], {
4559
4591
  equals: false
4560
4592
  });
4561
- const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($8tj43$createMemo(() => [...plp_results_().displays, ...get_extra_displays()]));
4593
+ const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($8tj43$createMemo(() => {
4594
+ var _plp_results_;
4595
+ return [...(((_plp_results_ = plp_results_()) === null || _plp_results_ === void 0 ? void 0 : _plp_results_.displays) || []), ...get_extra_displays()];
4596
+ }));
4562
4597
  const percentage_in_view_ = $e6dd9dfff4603d8c$export$63dd0350f8559dda({
4563
4598
  get_last_result_in_viewport_: get_last_result_in_viewport_,
4564
4599
  displays_by_key_: displays_by_key_,
@@ -4684,18 +4719,18 @@ function $7faea0096f14b59b$export$3925f87b1545cfc6(_ref) {
4684
4719
  layout_options_: layout_options_,
4685
4720
  sort_or_filter_open_: sort_or_filter_open_
4686
4721
  });
4687
- $8tj43$createComputed(() => {
4688
- if (!is_loading_()) return;
4689
- set_should_have_placeholders_rendered(true);
4690
- set_suspense_is_blocked(false);
4691
- is_just_after_plp_results_update = true;
4692
- });
4693
4722
  const block_suspense_if_needed = () => {
4694
4723
  if (!is_just_after_plp_results_update) return;
4695
4724
  is_just_after_plp_results_update = false;
4696
4725
  fallback_is_alive = false;
4697
4726
  set_suspense_is_blocked(true);
4698
4727
  };
4728
+ $8tj43$createComputed(() => {
4729
+ if (!is_loading_()) return;
4730
+ set_should_have_placeholders_rendered(true);
4731
+ set_suspense_is_blocked(false);
4732
+ is_just_after_plp_results_update = true;
4733
+ });
4699
4734
  $8tj43$createEffect($8tj43$on(plp_results_, () => {
4700
4735
  if (!fallback_is_alive) {
4701
4736
  // 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
@@ -4705,6 +4740,48 @@ function $7faea0096f14b59b$export$3925f87b1545cfc6(_ref) {
4705
4740
  }, {
4706
4741
  defer: true
4707
4742
  }));
4743
+ /*
4744
+ 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)
4745
+ We're creating it outside the <Show> so that we can benefit from <For>'s optimisation between changing results
4746
+ (For the whole idea of the displays being cached to work we can't tear down and re-run ProductCards for every new result.
4747
+ We have to keep ProductCards alive, but hidden, and feed them new data as soon as we had it)
4748
+ */
4749
+ const product_cards_when_data = $8tj43$createComponent((0, $8tj43$Suspense), {
4750
+ get fallback() {
4751
+ return (() => {
4752
+ fallback_is_alive = true;
4753
+ $8tj43$onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
4754
+ return $8tj43$createMemo(() => {
4755
+ // 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
4756
+ // In future we could have individual suspense's for each product card, but that's too much for now
4757
+ if (get_suspense_is_blocked()) return suspense_contents;
4758
+ set_should_have_placeholders_rendered(true); // just in case
4759
+ $8tj43$onCleanup(() => set_should_have_placeholders_rendered(false));
4760
+ 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>
4761
+ });
4762
+ })();
4763
+ },
4764
+
4765
+ get children() {
4766
+ return (() => {
4767
+ suspense_contents = $45a8953d760b5e58$export$a1fd619a4743ca08({
4768
+ product_card_template_: product_card_template_,
4769
+ plp_results_: plp_results_,
4770
+ last_result_in_viewport_: last_result_in_viewport_,
4771
+ first_result_in_viewport_: first_result_in_viewport_,
4772
+ market_: market_,
4773
+ merchant_: merchant_,
4774
+ all_products_loaded_: all_products_loaded_,
4775
+ min_products_to_fetch_: min_products_to_fetch_,
4776
+ query_base_: query_base_,
4777
+ depict_api_: depict_api_,
4778
+ is_loading_: is_loading_
4779
+ });
4780
+ $8tj43$onCleanup(() => suspense_contents = undefined);
4781
+ return suspense_contents;
4782
+ })();
4783
+ }
4784
+ });
4708
4785
  return [$8tj43$memo((0, $ca55612a53dbbdd2$export$a2cc176055f8f08)), $8tj43$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), {
4709
4786
  get cols_at_size() {
4710
4787
  return modified_cols_at_size();
@@ -4728,44 +4805,7 @@ function $7faea0096f14b59b$export$3925f87b1545cfc6(_ref) {
4728
4805
  get fallback() {
4729
4806
  return rendered_placeholders();
4730
4807
  },
4731
- get children() {
4732
- return $8tj43$createComponent((0, $8tj43$Suspense), {
4733
- get fallback() {
4734
- return (() => {
4735
- fallback_is_alive = true;
4736
- $8tj43$onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
4737
- return $8tj43$createMemo(() => {
4738
- // 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
4739
- // In future we could have individual suspense's for each product card, but that's too much for now
4740
- if (get_suspense_is_blocked()) return suspense_contents;
4741
- set_should_have_placeholders_rendered(true); // just in case
4742
- $8tj43$onCleanup(() => set_should_have_placeholders_rendered(false));
4743
- 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>
4744
- });
4745
- })();
4746
- },
4747
-
4748
- get children() {
4749
- return (() => {
4750
- suspense_contents = $45a8953d760b5e58$export$a1fd619a4743ca08({
4751
- product_card_template_: product_card_template_,
4752
- plp_results_: plp_results_,
4753
- last_result_in_viewport_: last_result_in_viewport_,
4754
- first_result_in_viewport_: first_result_in_viewport_,
4755
- market_: market_,
4756
- merchant_: merchant_,
4757
- all_products_loaded_: all_products_loaded_,
4758
- min_products_to_fetch_: min_products_to_fetch_,
4759
- query_base_: query_base_,
4760
- depict_api_: depict_api_,
4761
- is_loading_: is_loading_
4762
- });
4763
- $8tj43$onCleanup(() => suspense_contents = undefined);
4764
- return suspense_contents;
4765
- })();
4766
- }
4767
- });
4768
- }
4808
+ children: product_cards_when_data
4769
4809
  });
4770
4810
  }
4771
4811
  })];
@@ -8040,7 +8080,8 @@ function $8ef6232475d44150$export$7de92c4c2205ebf3(_ref) {
8040
8080
  product_card_template_: product_card_template_,
8041
8081
  showing_recommendation_rows_: showing_recommendation_rows_,
8042
8082
  view_more_button_ = true,
8043
- layout_options_: layout_options_
8083
+ layout_options_: layout_options_,
8084
+ all_products_loaded_: all_products_loaded_
8044
8085
  } = _ref;
8045
8086
  const [get_showing_recommendation_rows] = showing_recommendation_rows_; // We reset this in after_submit in search.tsx FYI
8046
8087
  const rows_object = view_more_button_ ? $8ef6232475d44150$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
@@ -8053,51 +8094,53 @@ function $8ef6232475d44150$export$7de92c4c2205ebf3(_ref) {
8053
8094
  let [per_column] = _ref2;
8054
8095
  return per_column;
8055
8096
  })));
8097
+ // Don't tear down elements every time one updates the page - don't put them within <Show>
8098
+ const elements = (() => {
8099
+ const _el$ = $8tj43$getNextElement($8ef6232475d44150$var$_tmpl$),
8100
+ _el$2 = _el$.firstChild,
8101
+ _el$3 = _el$2.nextSibling,
8102
+ [_el$4, _co$] = $8tj43$getNextMarker(_el$3.nextSibling),
8103
+ _el$5 = _el$4.nextSibling,
8104
+ [_el$6, _co$2] = $8tj43$getNextMarker(_el$5.nextSibling);
8105
+ $8tj43$insert(_el$2, () => i18n_.search_recs_title_());
8106
+ $8tj43$insert(_el$, (0, $ca55612a53dbbdd2$export$a2cc176055f8f08), _el$4, _co$);
8107
+ $8tj43$insert(_el$, $8tj43$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), $8tj43$mergeProps({
8108
+ rows: rows_object,
8109
+ layout: "grid",
8110
+ element_attributes: {
8111
+ class: "cards"
8112
+ }
8113
+ }, layout_options_, {
8114
+ get children() {
8115
+ return $8tj43$createComponent((0, $8tj43$Suspense), {
8116
+ get fallback() {
8117
+ return $bdd80c7862246dc2$export$f33414a4df0afd3f({
8118
+ num_placeholders_: num_placeholders_,
8119
+ product_card_template_: product_card_template_
8120
+ });
8121
+ },
8122
+ get children() {
8123
+ return (() => {
8124
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
8125
+ const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($8tj43$createMemo(() => recommendations_resource() || []));
8126
+ return $2d7bad8684bc7f44$export$43f0fb951fcb0c54({
8127
+ displays_by_key_: displays_by_key_,
8128
+ merchant_: $8tj43$createMemo(() => search_query_base_().tenant),
8129
+ market_: $8tj43$createMemo(() => search_query_base_().market),
8130
+ product_card_template_: product_card_template_
8131
+ });
8132
+ })();
8133
+ }
8134
+ });
8135
+ }
8136
+ })), _el$6, _co$2);
8137
+ return _el$;
8138
+ })();
8056
8139
  return $8tj43$createComponent((0, $8tj43$Show), {
8057
8140
  get when() {
8058
- return is_showing_something();
8141
+ return $8tj43$memo(() => !!is_showing_something())() && all_products_loaded_();
8059
8142
  },
8060
- get children() {
8061
- const _el$ = $8tj43$getNextElement($8ef6232475d44150$var$_tmpl$),
8062
- _el$2 = _el$.firstChild,
8063
- _el$3 = _el$2.nextSibling,
8064
- [_el$4, _co$] = $8tj43$getNextMarker(_el$3.nextSibling),
8065
- _el$5 = _el$4.nextSibling,
8066
- [_el$6, _co$2] = $8tj43$getNextMarker(_el$5.nextSibling);
8067
- $8tj43$insert(_el$2, () => i18n_.search_recs_title_());
8068
- $8tj43$insert(_el$, (0, $ca55612a53dbbdd2$export$a2cc176055f8f08), _el$4, _co$);
8069
- $8tj43$insert(_el$, $8tj43$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), $8tj43$mergeProps({
8070
- rows: rows_object,
8071
- layout: "grid",
8072
- element_attributes: {
8073
- class: "cards"
8074
- }
8075
- }, layout_options_, {
8076
- get children() {
8077
- return $8tj43$createComponent((0, $8tj43$Suspense), {
8078
- get fallback() {
8079
- return $bdd80c7862246dc2$export$f33414a4df0afd3f({
8080
- num_placeholders_: num_placeholders_,
8081
- product_card_template_: product_card_template_
8082
- });
8083
- },
8084
- get children() {
8085
- return (() => {
8086
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
8087
- const displays_by_key_ = $2d7bad8684bc7f44$export$7f8bd308237ab5a5($8tj43$createMemo(() => recommendations_resource() || []));
8088
- return $2d7bad8684bc7f44$export$43f0fb951fcb0c54({
8089
- displays_by_key_: displays_by_key_,
8090
- merchant_: $8tj43$createMemo(() => search_query_base_().tenant),
8091
- market_: $8tj43$createMemo(() => search_query_base_().market),
8092
- product_card_template_: product_card_template_
8093
- });
8094
- })();
8095
- }
8096
- });
8097
- }
8098
- })), _el$6, _co$2);
8099
- return _el$;
8100
- }
8143
+ children: elements
8101
8144
  });
8102
8145
  }
8103
8146
  function $8ef6232475d44150$var$make_state_saved_rows(_ref3, i18n_) {
@@ -10670,9 +10713,7 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
10670
10713
  }
10671
10714
  }), _el$19, _co$8);
10672
10715
  $8tj43$insert(_el$7, $8tj43$createComponent((0, $8tj43$Show), {
10673
- get when() {
10674
- return get_all_products_loaded() && !disable_search_recommendations_;
10675
- },
10716
+ when: !disable_search_recommendations_,
10676
10717
  keyed: false,
10677
10718
  get children() {
10678
10719
  return $8tj43$createComponent((0, $74777e8fe65b3dcb$export$b69d0d92862de18b), {
@@ -10691,7 +10732,8 @@ function $da279c5a540c6846$export$a54ec244c8863715(_ref) {
10691
10732
  },
10692
10733
  showing_recommendation_rows_: showing_recommendation_rows_,
10693
10734
  view_more_button_: search_recs_view_more_,
10694
- product_card_template_: product_card_template_
10735
+ product_card_template_: product_card_template_,
10736
+ all_products_loaded_: get_all_products_loaded
10695
10737
  });
10696
10738
  }
10697
10739
  });