@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,11 +1,11 @@
1
- import { add_to_version_info as $i7OB2$add_to_version_info, catchify as $i7OB2$catchify, slider_fractional_factory as $i7OB2$slider_fractional_factory, make_random_classname as $i7OB2$make_random_classname, n_col_styling_with_dist as $i7OB2$n_col_styling_with_dist, layout_get_visible_recs_without_partial_rows as $i7OB2$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $i7OB2$layout_get_total_rec_amount_for_row, layout_media_query_header as $i7OB2$layout_media_query_header, report as $i7OB2$report, Amazing_Slider as $i7OB2$Amazing_Slider, slider_snap_css as $i7OB2$slider_snap_css, slider_fading_factory as $i7OB2$slider_fading_factory, observer as $i7OB2$observer, is_safari as $i7OB2$is_safari, useExpandingContainer as $i7OB2$useExpandingContainer, standard_price_format as $i7OB2$standard_price_format, dlog as $i7OB2$dlog, hex_to_rgb as $i7OB2$hex_to_rgb, relative_luminance_from_rgb as $i7OB2$relative_luminance_from_rgb, javascript_media_query as $i7OB2$javascript_media_query, fetch_recs as $i7OB2$fetch_recs, snakeCasifyObject as $i7OB2$snakeCasifyObject, instant_exec_on_suspect_history_change as $i7OB2$instant_exec_on_suspect_history_change, base_url as $i7OB2$base_url, get_depict_id as $i7OB2$get_depict_id, get_user_id as $i7OB2$get_user_id, get_session_id as $i7OB2$get_session_id, sort_obj as $i7OB2$sort_obj, fetch_retry as $i7OB2$fetch_retry, add_version_query_params as $i7OB2$add_version_query_params, dwarn as $i7OB2$dwarn, make_url_with_query_params as $i7OB2$make_url_with_query_params, edit_current_page_meta_tags as $i7OB2$edit_current_page_meta_tags, use_href_accessor as $i7OB2$use_href_accessor, base64_encode_unicode as $i7OB2$base64_encode_unicode, base64_decode_unicode as $i7OB2$base64_decode_unicode, queueMacroTask as $i7OB2$queueMacroTask, make_asyncIterable_exiter as $i7OB2$make_asyncIterable_exiter, href_change_ipns as $i7OB2$href_change_ipns, ContainedImage as $i7OB2$ContainedImage, deparallelize_no_drop as $i7OB2$deparallelize_no_drop, ListenableSet as $i7OB2$ListenableSet, insert_surfaces as $i7OB2$insert_surfaces } from "@depict-ai/utilishared/latest";
2
- import { createSignal as $i7OB2$createSignal, onCleanup as $i7OB2$onCleanup, createMemo as $i7OB2$createMemo, createResource as $i7OB2$createResource, Suspense as $i7OB2$Suspense, Show as $i7OB2$Show, createRenderEffect as $i7OB2$createRenderEffect, createRoot as $i7OB2$createRoot, For as $i7OB2$For, getOwner as $i7OB2$getOwner, runWithOwner as $i7OB2$runWithOwner, createEffect as $i7OB2$createEffect, untrack as $i7OB2$untrack, createUniqueId as $i7OB2$createUniqueId, createComputed as $i7OB2$createComputed, ErrorBoundary as $i7OB2$ErrorBoundary, Index as $i7OB2$Index, on as $i7OB2$on, batch as $i7OB2$batch, createReaction as $i7OB2$createReaction } from "solid-js";
1
+ import { add_to_version_info as $i7OB2$add_to_version_info, catchify as $i7OB2$catchify, slider_fractional_factory as $i7OB2$slider_fractional_factory, camelCasifyObject as $i7OB2$camelCasifyObject, make_random_classname as $i7OB2$make_random_classname, n_col_styling_with_dist as $i7OB2$n_col_styling_with_dist, layout_get_visible_recs_without_partial_rows as $i7OB2$layout_get_visible_recs_without_partial_rows, layout_get_total_rec_amount_for_row as $i7OB2$layout_get_total_rec_amount_for_row, layout_media_query_header as $i7OB2$layout_media_query_header, report as $i7OB2$report, Amazing_Slider as $i7OB2$Amazing_Slider, slider_snap_css as $i7OB2$slider_snap_css, slider_fading_factory as $i7OB2$slider_fading_factory, observer as $i7OB2$observer, is_safari as $i7OB2$is_safari, useExpandingContainer as $i7OB2$useExpandingContainer, standard_price_format as $i7OB2$standard_price_format, dlog as $i7OB2$dlog, hex_to_rgb as $i7OB2$hex_to_rgb, relative_luminance_from_rgb as $i7OB2$relative_luminance_from_rgb, javascript_media_query as $i7OB2$javascript_media_query, fetch_recs as $i7OB2$fetch_recs, snakeCasifyObject as $i7OB2$snakeCasifyObject, instant_exec_on_suspect_history_change as $i7OB2$instant_exec_on_suspect_history_change, base_url as $i7OB2$base_url, get_depict_id as $i7OB2$get_depict_id, get_user_id as $i7OB2$get_user_id, get_session_id as $i7OB2$get_session_id, sort_obj as $i7OB2$sort_obj, fetch_retry as $i7OB2$fetch_retry, add_version_query_params as $i7OB2$add_version_query_params, dwarn as $i7OB2$dwarn, make_url_with_query_params as $i7OB2$make_url_with_query_params, edit_current_page_meta_tags as $i7OB2$edit_current_page_meta_tags, use_href_accessor as $i7OB2$use_href_accessor, base64_encode_unicode as $i7OB2$base64_encode_unicode, base64_decode_unicode as $i7OB2$base64_decode_unicode, queueMacroTask as $i7OB2$queueMacroTask, make_asyncIterable_exiter as $i7OB2$make_asyncIterable_exiter, href_change_ipns as $i7OB2$href_change_ipns, ContainedImage as $i7OB2$ContainedImage, deparallelize_no_drop as $i7OB2$deparallelize_no_drop, ListenableSet as $i7OB2$ListenableSet, insert_surfaces as $i7OB2$insert_surfaces } from "@depict-ai/utilishared/latest";
2
+ import { createSignal as $i7OB2$createSignal, onCleanup as $i7OB2$onCleanup, createMemo as $i7OB2$createMemo, createResource as $i7OB2$createResource, Suspense as $i7OB2$Suspense, Show as $i7OB2$Show, createRenderEffect as $i7OB2$createRenderEffect, createRoot as $i7OB2$createRoot, For as $i7OB2$For, getOwner as $i7OB2$getOwner, runWithOwner as $i7OB2$runWithOwner, createEffect as $i7OB2$createEffect, createUniqueId as $i7OB2$createUniqueId, untrack as $i7OB2$untrack, createComputed as $i7OB2$createComputed, ErrorBoundary as $i7OB2$ErrorBoundary, Index as $i7OB2$Index, on as $i7OB2$on, batch as $i7OB2$batch, createReaction as $i7OB2$createReaction } from "solid-js";
3
3
  import { ssr as $i7OB2$ssr, ssrHydrationKey as $i7OB2$ssrHydrationKey, escape as $i7OB2$escape, createComponent as $i7OB2$createComponent, mergeProps as $i7OB2$mergeProps, isServer as $i7OB2$isServer, ssrElement as $i7OB2$ssrElement, ssrClassList as $i7OB2$ssrClassList, insert as $i7OB2$insert, ssrAttribute as $i7OB2$ssrAttribute, ssrStyle as $i7OB2$ssrStyle, Dynamic as $i7OB2$Dynamic } from "solid-js/web";
4
4
 
5
5
  /*! Depict.ai search and product listing SDK */
6
6
  import { register_es_version } from "../../multi_import_deduplicator.mjs";
7
7
  register_es_version("ui", "latest");
8
- const $ec291e0010116877$export$83d89fbfd8236492 = "2.0.7";
8
+ const $ec291e0010116877$export$83d89fbfd8236492 = "2.0.9";
9
9
 
10
10
  /** @jsxImportSource solid-js */
11
11
 
@@ -57,7 +57,7 @@ const $b5cccc8ee7d24677$export$6daf8749b65a1b77 = cols_at_size => {
57
57
  return $b5cccc8ee7d24677$var$transform_elements(sorted_cols_at_size);
58
58
  };
59
59
  function $a458486f22b22f63$export$a2cc176055f8f08() {
60
- 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.";
60
+ 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.";
61
61
  return (0, $i7OB2$isServer) ? {
62
62
  t: `<!-- ${text} -->`
63
63
  } : document.createComment(text);
@@ -182,6 +182,7 @@ function $29ec7cddbe1d3484$export$7f8bd308237ab5a5(get_displays_) {
182
182
  });
183
183
  return displays_by_key_;
184
184
  }
185
+ const $29ec7cddbe1d3484$var$result_ids = ["search_result_id", "product_listing_result_id", "recommendation_id"];
185
186
  function $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
186
187
  displays_by_key_: displays_by_key_,
187
188
  merchant_: merchant_,
@@ -195,17 +196,24 @@ function $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
195
196
  },
196
197
  children: (product_id, index) => {
197
198
  const owner = $i7OB2$getOwner();
198
- const display_accessor = $i7OB2$createMemo(() => displays_by_key_().get(product_id));
199
- const [product_card_resource] = $i7OB2$createResource(display_accessor,
200
- // re-render when the reference to the display object changes
201
- // this should only be the case when the merchant or market changes and the new request has completed
202
- display => {
199
+ const display_accessor = $i7OB2$createMemo(prev => {
200
+ const new_display = displays_by_key_().get(product_id);
201
+ if (prev && $29ec7cddbe1d3484$var$deep_equal(prev, new_display))
202
+ // 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.
203
+ // This doesn't work if people mutate the displays from within the template but we hope they don't
204
+ // (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)
205
+ return prev;
206
+ return new_display;
207
+ });
208
+ const [product_card_resource] = $i7OB2$createResource(() => [merchant_(), market_(), display_accessor()],
209
+ // re-render when the reference to the display object changes or the merchant or market changes
210
+ // (We don't want to re-render if nothing has changed)
211
+ ([merchant, market, display]) => {
203
212
  // get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
204
213
  return product_card_template_(display, {
205
214
  set_on_index_change: fn => $i7OB2$runWithOwner(owner, () => $i7OB2$createEffect(() => fn(index()))),
206
- merchant: $i7OB2$untrack(merchant_),
207
- // 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
208
- market: $i7OB2$untrack(market_) // recommendation_grid can provide a sneaky undefined here just FYI
215
+ merchant: merchant,
216
+ market: market // recommendation_grid can provide a sneaky undefined here just FYI
209
217
  });
210
218
  });
211
219
 
@@ -220,15 +228,13 @@ function $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
220
228
  elements.push(element);
221
229
  // Add tracking ids
222
230
  if (!(element instanceof HTMLElement)) continue; // Apparently only HTMLElements have dataset
223
- const {
224
- dataset: dataset
225
- } = element;
226
- const {
227
- search_result_id: search_result_id,
228
- product_listing_result_id: product_listing_result_id,
229
- recommendation_id: recommendation_id
230
- } = display;
231
- 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;
231
+ for (let i = 0; i < $29ec7cddbe1d3484$var$result_ids.length; i++) {
232
+ const id = $29ec7cddbe1d3484$var$result_ids[i];
233
+ const value = display[id];
234
+ if (value) Object.assign(element.dataset, $i7OB2$camelCasifyObject({
235
+ [id]: value
236
+ }));
237
+ }
232
238
  }
233
239
  do_per_elements_?.(elements, index);
234
240
  });
@@ -236,6 +242,23 @@ function $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
236
242
  }
237
243
  });
238
244
  }
245
+ // Source: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/
246
+ function $29ec7cddbe1d3484$var$deep_equal(object1, object2) {
247
+ const keys1 = Object.keys(object1);
248
+ const keys2 = Object.keys(object2);
249
+ if (keys1.length !== keys2.length) return false;
250
+ for (const key of keys1) {
251
+ if ($29ec7cddbe1d3484$var$result_ids.includes(key)) continue; // ignore result ids that change per response
252
+ const val1 = object1[key];
253
+ const val2 = object2[key];
254
+ const areObjects = $29ec7cddbe1d3484$var$is_object(val1) && $29ec7cddbe1d3484$var$is_object(val2);
255
+ if (areObjects && !$29ec7cddbe1d3484$var$deep_equal(val1, val2) || !areObjects && val1 !== val2) return false;
256
+ }
257
+ return true;
258
+ }
259
+ function $29ec7cddbe1d3484$var$is_object(object) {
260
+ return object != null && typeof object === "object";
261
+ }
239
262
 
240
263
  // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
241
264
  class $4fd48cb976bf1789$export$e1d52e4f0c7557a1 extends Error {}
@@ -494,7 +517,13 @@ function $16b52438165aafe2$export$23fca46f3143581f(component, error_message) {
494
517
  return component_in_error_boundary(elements => {
495
518
  const have_multiple = Array.isArray(elements);
496
519
  if (have_multiple ? !elements?.length : !elements) return;
497
- (0, $i7OB2$observer).onremoved(have_multiple ? elements[0] : elements, dispose);
520
+ (0, $i7OB2$observer).onremoved(have_multiple ? elements[0] : elements, ({
521
+ element: element
522
+ }) => {
523
+ if (document.documentElement.contains(element)) return; // If element has instantly been re-inserted, don't dispose
524
+ // See https://depictaiworkspace.slack.com/archives/C050GHEPBTR/p1695809102791259?thread_ts=1695106805.459729&cid=C050GHEPBTR
525
+ dispose();
526
+ });
498
527
  });
499
528
  });else
500
529
  // we're already in a root so cleanups are handled
@@ -538,44 +567,43 @@ function $3da8afe3ed57cf34$export$7da560f849543dff({
538
567
  }) {
539
568
  const is_showing_something = $i7OB2$createMemo(() => recommendations_resource_.loading || recommendations_resource_()?.length);
540
569
  const num_placeholders_ = () => 20;
541
- return $i7OB2$createComponent((0, $i7OB2$Show), {
542
- get when() {
543
- return is_showing_something();
570
+ const elements = $i7OB2$ssr($3da8afe3ed57cf34$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape($a458486f22b22f63$export$a2cc176055f8f08()), $i7OB2$escape($i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), $i7OB2$mergeProps({
571
+ get rows() {
572
+ return rows_object_();
544
573
  },
574
+ layout: "grid",
575
+ element_attributes: {
576
+ class: "cards"
577
+ }
578
+ }, layout_options_, {
545
579
  get children() {
546
- return $i7OB2$ssr($3da8afe3ed57cf34$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape($a458486f22b22f63$export$a2cc176055f8f08()), $i7OB2$escape($i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), $i7OB2$mergeProps({
547
- get rows() {
548
- return rows_object_();
580
+ return $i7OB2$createComponent((0, $i7OB2$Suspense), {
581
+ get fallback() {
582
+ return $6e41f1fde994db72$export$f33414a4df0afd3f({
583
+ num_placeholders_: num_placeholders_,
584
+ product_card_template_: product_card_template_
585
+ });
549
586
  },
550
- layout: "grid",
551
- element_attributes: {
552
- class: "cards"
553
- }
554
- }, layout_options_, {
555
587
  get children() {
556
- return $i7OB2$createComponent((0, $i7OB2$Suspense), {
557
- get fallback() {
558
- return $6e41f1fde994db72$export$f33414a4df0afd3f({
559
- num_placeholders_: num_placeholders_,
560
- product_card_template_: product_card_template_
561
- });
562
- },
563
- get children() {
564
- return (() => {
565
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
566
- const displays_by_key_ = $29ec7cddbe1d3484$export$7f8bd308237ab5a5($i7OB2$createMemo(() => recommendations_resource_() || []));
567
- return $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
568
- displays_by_key_: displays_by_key_,
569
- merchant_: merchant_,
570
- market_: market_,
571
- product_card_template_: product_card_template_
572
- });
573
- })();
574
- }
575
- });
588
+ return (() => {
589
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
590
+ const displays_by_key_ = $29ec7cddbe1d3484$export$7f8bd308237ab5a5($i7OB2$createMemo(() => recommendations_resource_() || []));
591
+ return $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
592
+ displays_by_key_: displays_by_key_,
593
+ merchant_: merchant_,
594
+ market_: market_,
595
+ product_card_template_: product_card_template_
596
+ });
597
+ })();
576
598
  }
577
- }))));
599
+ });
578
600
  }
601
+ }))));
602
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
603
+ get when() {
604
+ return is_showing_something();
605
+ },
606
+ children: elements
579
607
  });
580
608
  }
581
609
  const $9ea5383493360761$var$_tmpl$ = ["<button", ' class="show-more major" type="button">', "</button>"],
@@ -3374,7 +3402,7 @@ function $0449e7d49398c077$export$a1fd619a4743ca08({
3374
3402
  const [get_extra_displays, set_extra_displays_] = $i7OB2$createSignal([], {
3375
3403
  equals: false
3376
3404
  });
3377
- const displays_by_key_ = $29ec7cddbe1d3484$export$7f8bd308237ab5a5($i7OB2$createMemo(() => [...plp_results_().displays, ...get_extra_displays()]));
3405
+ const displays_by_key_ = $29ec7cddbe1d3484$export$7f8bd308237ab5a5($i7OB2$createMemo(() => [...(plp_results_()?.displays || []), ...get_extra_displays()]));
3378
3406
  const percentage_in_view_ = $0e0b96a8dc1ad492$export$63dd0350f8559dda({
3379
3407
  get_last_result_in_viewport_: get_last_result_in_viewport_,
3380
3408
  displays_by_key_: displays_by_key_,
@@ -3487,18 +3515,18 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
3487
3515
  layout_options_: layout_options_,
3488
3516
  sort_or_filter_open_: sort_or_filter_open_
3489
3517
  });
3490
- $i7OB2$createComputed(() => {
3491
- if (!is_loading_()) return;
3492
- set_should_have_placeholders_rendered(true);
3493
- set_suspense_is_blocked(false);
3494
- is_just_after_plp_results_update = true;
3495
- });
3496
3518
  const block_suspense_if_needed = () => {
3497
3519
  if (!is_just_after_plp_results_update) return;
3498
3520
  is_just_after_plp_results_update = false;
3499
3521
  fallback_is_alive = false;
3500
3522
  set_suspense_is_blocked(true);
3501
3523
  };
3524
+ $i7OB2$createComputed(() => {
3525
+ if (!is_loading_()) return;
3526
+ set_should_have_placeholders_rendered(true);
3527
+ set_suspense_is_blocked(false);
3528
+ is_just_after_plp_results_update = true;
3529
+ });
3502
3530
  $i7OB2$createEffect($i7OB2$on(plp_results_, () => {
3503
3531
  if (!fallback_is_alive) {
3504
3532
  // 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
@@ -3508,6 +3536,48 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
3508
3536
  }, {
3509
3537
  defer: true
3510
3538
  }));
3539
+ /*
3540
+ 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)
3541
+ We're creating it outside the <Show> so that we can benefit from <For>'s optimisation between changing results
3542
+ (For the whole idea of the displays being cached to work we can't tear down and re-run ProductCards for every new result.
3543
+ We have to keep ProductCards alive, but hidden, and feed them new data as soon as we had it)
3544
+ */
3545
+ const product_cards_when_data = $i7OB2$createComponent((0, $i7OB2$Suspense), {
3546
+ get fallback() {
3547
+ return (() => {
3548
+ fallback_is_alive = true;
3549
+ $i7OB2$onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
3550
+ return $i7OB2$createMemo(() => {
3551
+ // 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
3552
+ // In future we could have individual suspense's for each product card, but that's too much for now
3553
+ if (get_suspense_is_blocked()) return suspense_contents;
3554
+ set_should_have_placeholders_rendered(true); // just in case
3555
+ $i7OB2$onCleanup(() => set_should_have_placeholders_rendered(false));
3556
+ 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>
3557
+ });
3558
+ })();
3559
+ },
3560
+
3561
+ get children() {
3562
+ return (() => {
3563
+ suspense_contents = $0449e7d49398c077$export$a1fd619a4743ca08({
3564
+ product_card_template_: product_card_template_,
3565
+ plp_results_: plp_results_,
3566
+ last_result_in_viewport_: last_result_in_viewport_,
3567
+ first_result_in_viewport_: first_result_in_viewport_,
3568
+ market_: market_,
3569
+ merchant_: merchant_,
3570
+ all_products_loaded_: all_products_loaded_,
3571
+ min_products_to_fetch_: min_products_to_fetch_,
3572
+ query_base_: query_base_,
3573
+ depict_api_: depict_api_,
3574
+ is_loading_: is_loading_
3575
+ });
3576
+ $i7OB2$onCleanup(() => suspense_contents = undefined);
3577
+ return suspense_contents;
3578
+ })();
3579
+ }
3580
+ });
3511
3581
  return [$a458486f22b22f63$export$a2cc176055f8f08(), $i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), {
3512
3582
  get cols_at_size() {
3513
3583
  return modified_cols_at_size();
@@ -3531,44 +3601,7 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
3531
3601
  get fallback() {
3532
3602
  return rendered_placeholders();
3533
3603
  },
3534
- get children() {
3535
- return $i7OB2$createComponent((0, $i7OB2$Suspense), {
3536
- get fallback() {
3537
- return (() => {
3538
- fallback_is_alive = true;
3539
- $i7OB2$onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
3540
- return $i7OB2$createMemo(() => {
3541
- // 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
3542
- // In future we could have individual suspense's for each product card, but that's too much for now
3543
- if (get_suspense_is_blocked()) return suspense_contents;
3544
- set_should_have_placeholders_rendered(true); // just in case
3545
- $i7OB2$onCleanup(() => set_should_have_placeholders_rendered(false));
3546
- 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>
3547
- });
3548
- })();
3549
- },
3550
-
3551
- get children() {
3552
- return (() => {
3553
- suspense_contents = $0449e7d49398c077$export$a1fd619a4743ca08({
3554
- product_card_template_: product_card_template_,
3555
- plp_results_: plp_results_,
3556
- last_result_in_viewport_: last_result_in_viewport_,
3557
- first_result_in_viewport_: first_result_in_viewport_,
3558
- market_: market_,
3559
- merchant_: merchant_,
3560
- all_products_loaded_: all_products_loaded_,
3561
- min_products_to_fetch_: min_products_to_fetch_,
3562
- query_base_: query_base_,
3563
- depict_api_: depict_api_,
3564
- is_loading_: is_loading_
3565
- });
3566
- $i7OB2$onCleanup(() => suspense_contents = undefined);
3567
- return suspense_contents;
3568
- })();
3569
- }
3570
- });
3571
- }
3604
+ children: product_cards_when_data
3572
3605
  });
3573
3606
  }
3574
3607
  })];
@@ -6015,49 +6048,50 @@ function $172e1b898d457050$export$7de92c4c2205ebf3({
6015
6048
  product_card_template_: product_card_template_,
6016
6049
  showing_recommendation_rows_: showing_recommendation_rows_,
6017
6050
  view_more_button_ = true,
6018
- layout_options_: layout_options_
6051
+ layout_options_: layout_options_,
6052
+ all_products_loaded_: all_products_loaded_
6019
6053
  }) {
6020
6054
  const [get_showing_recommendation_rows] = showing_recommendation_rows_; // We reset this in after_submit in search.tsx FYI
6021
6055
  const rows_object = view_more_button_ ? $172e1b898d457050$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
6022
6056
  const [recommendations_resource] = $i7OB2$createResource(search_query_base_, query => depict_api_.get_recommended(query).then(r => r.displays));
6023
6057
  const is_showing_something = $i7OB2$createMemo(() => recommendations_resource.loading || recommendations_resource()?.length);
6024
6058
  const num_placeholders_ = $i7OB2$createMemo(() => (0, $7747fe1a8c5652e3$export$6c9030e511152266) + get_showing_recommendation_rows() * Math.max(...layout_options_().cols_at_size.map(([per_column]) => per_column)));
6025
- return $i7OB2$createComponent((0, $i7OB2$Show), {
6026
- get when() {
6027
- return is_showing_something();
6028
- },
6059
+ // Don't tear down elements every time one updates the page - don't put them within <Show>
6060
+ const elements = $i7OB2$ssr($172e1b898d457050$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(i18n_.search_recs_title_()), $i7OB2$escape($a458486f22b22f63$export$a2cc176055f8f08()), $i7OB2$escape($i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), $i7OB2$mergeProps({
6061
+ rows: rows_object,
6062
+ layout: "grid",
6063
+ element_attributes: {
6064
+ class: "cards"
6065
+ }
6066
+ }, layout_options_, {
6029
6067
  get children() {
6030
- return $i7OB2$ssr($172e1b898d457050$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(i18n_.search_recs_title_()), $i7OB2$escape($a458486f22b22f63$export$a2cc176055f8f08()), $i7OB2$escape($i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), $i7OB2$mergeProps({
6031
- rows: rows_object,
6032
- layout: "grid",
6033
- element_attributes: {
6034
- class: "cards"
6035
- }
6036
- }, layout_options_, {
6037
- get children() {
6038
- return $i7OB2$createComponent((0, $i7OB2$Suspense), {
6039
- get fallback() {
6040
- return $6e41f1fde994db72$export$f33414a4df0afd3f({
6041
- num_placeholders_: num_placeholders_,
6042
- product_card_template_: product_card_template_
6043
- });
6044
- },
6045
- get children() {
6046
- return (() => {
6047
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
6048
- const displays_by_key_ = $29ec7cddbe1d3484$export$7f8bd308237ab5a5($i7OB2$createMemo(() => recommendations_resource() || []));
6049
- return $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
6050
- displays_by_key_: displays_by_key_,
6051
- merchant_: $i7OB2$createMemo(() => search_query_base_().tenant),
6052
- market_: $i7OB2$createMemo(() => search_query_base_().market),
6053
- product_card_template_: product_card_template_
6054
- });
6055
- })();
6056
- }
6068
+ return $i7OB2$createComponent((0, $i7OB2$Suspense), {
6069
+ get fallback() {
6070
+ return $6e41f1fde994db72$export$f33414a4df0afd3f({
6071
+ num_placeholders_: num_placeholders_,
6072
+ product_card_template_: product_card_template_
6057
6073
  });
6074
+ },
6075
+ get children() {
6076
+ return (() => {
6077
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
6078
+ const displays_by_key_ = $29ec7cddbe1d3484$export$7f8bd308237ab5a5($i7OB2$createMemo(() => recommendations_resource() || []));
6079
+ return $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
6080
+ displays_by_key_: displays_by_key_,
6081
+ merchant_: $i7OB2$createMemo(() => search_query_base_().tenant),
6082
+ market_: $i7OB2$createMemo(() => search_query_base_().market),
6083
+ product_card_template_: product_card_template_
6084
+ });
6085
+ })();
6058
6086
  }
6059
- }))));
6087
+ });
6060
6088
  }
6089
+ }))));
6090
+ return $i7OB2$createComponent((0, $i7OB2$Show), {
6091
+ get when() {
6092
+ return is_showing_something() && all_products_loaded_();
6093
+ },
6094
+ children: elements
6061
6095
  });
6062
6096
  }
6063
6097
  function $172e1b898d457050$var$make_state_saved_rows([get_showing_recommendation_rows, set_showing_recommendation_rows], i18n_) {
@@ -8046,9 +8080,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
8046
8080
  });
8047
8081
  }
8048
8082
  })), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
8049
- get when() {
8050
- return get_all_products_loaded() && !disable_search_recommendations_;
8051
- },
8083
+ when: !disable_search_recommendations_,
8052
8084
  keyed: false,
8053
8085
  get children() {
8054
8086
  return $i7OB2$createComponent((0, $b7436a6d1fd64e3b$export$b69d0d92862de18b), {
@@ -8064,7 +8096,8 @@ function $7097477c78a89208$export$a54ec244c8863715({
8064
8096
  },
8065
8097
  showing_recommendation_rows_: showing_recommendation_rows_,
8066
8098
  view_more_button_: search_recs_view_more_,
8067
- product_card_template_: product_card_template_
8099
+ product_card_template_: product_card_template_,
8100
+ all_products_loaded_: get_all_products_loaded
8068
8101
  });
8069
8102
  }
8070
8103
  });