@depict-ai/ui 2.1.1 → 2.1.3

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.
@@ -70,7 +70,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
70
70
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
71
71
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
72
72
  /*! Depict.ai search and product listing SDK */
73
- const $b757f75811f3261f$export$83d89fbfd8236492 = "2.1.1";
73
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "2.1.3";
74
74
  const $1ab22f2cd39b3061$var$fallback_operator = "in";
75
75
  const $1ab22f2cd39b3061$var$fallback_token = "";
76
76
  const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
@@ -3755,8 +3755,7 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
3755
3755
  query_base_: query_base_,
3756
3756
  depict_api_: depict_api_,
3757
3757
  is_loading_: is_loading_,
3758
- content_blocks_: content_blocks_,
3759
- set_number_loaded_displays_: set_number_loaded_displays_
3758
+ content_blocks_: content_blocks_
3760
3759
  }) {
3761
3760
  // The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator and knowing when to load more
3762
3761
  const target_to_index_map = new Map();
@@ -3800,7 +3799,6 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
3800
3799
  query_base_: query_base_,
3801
3800
  depict_api_: depict_api_
3802
3801
  });
3803
- $5vyXB$solidjs.createComputed(() => set_number_loaded_displays_(displays_by_key_().size));
3804
3802
  return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
3805
3803
  displays_by_key_: displays_by_key_,
3806
3804
  merchant_: merchant_,
@@ -3876,25 +3874,26 @@ function $75777da1687ba3f6$var$generate_media_queried_declarations({
3876
3874
  }) {
3877
3875
  return cols_at_size_.map(options => {
3878
3876
  const [n_cols, min, max, grid_spacing_for_size] = options;
3879
- const spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
3877
+ const main_spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
3880
3878
  // See comment in else block below
3881
- const can_use_gap = $75777da1687ba3f6$var$can_use_gap_for_unit(spacing_to_use) && (!override_vertical_spacing_ || $75777da1687ba3f6$var$can_use_gap_for_unit(override_vertical_spacing_));
3879
+ const can_use_gap = override_vertical_spacing_ ? $75777da1687ba3f6$var$can_use_gap_for_unit(override_vertical_spacing_) : $75777da1687ba3f6$var$can_use_gap_for_unit(main_spacing_to_use);
3882
3880
  let spacing_styling;
3883
3881
  let additional_styling = ""; // outside the media query
3884
- if (can_use_gap) spacing_styling = `gap:${spacing_to_use};${override_vertical_spacing_ ? `row-gap:${override_vertical_spacing_};` : ``}`;else {
3882
+ if (can_use_gap) spacing_styling = `gap:${main_spacing_to_use};${override_vertical_spacing_ ? `row-gap:${override_vertical_spacing_};` : ``}`;else {
3885
3883
  // When using percent units, which our default styling does (because convenient) and our interface relies on (hard to specify different gaps for different screen sizes)
3886
3884
  // row gaps in grids are relative to the whole height of the grid, maybe see also https://stackoverflow.com/a/53563865. The issue with that is that as we load more products, the gap grows. Also, it breaks existing integrations.
3887
3885
  // Logical thought: use margins for the vertical spacing. But margins in grids are apparently relative to the size of the individual items in grids.
3888
3886
  // Given that, and that content blocks can be of different width, we have to do some complicated calculations to convert the provided gap, which is in gap of the total container width, to a margin of the individual items.
3887
+ const vertical_spacing_to_use = override_vertical_spacing_ ?? main_spacing_to_use;
3889
3888
  const width_multiplier = `var(${$75777da1687ba3f6$export$c500183c31c2b22e}, 1)`; // How many cards wide the current item is (needed because content blocks)
3890
- const one_item_width_exclusing_gaps = `calc(calc(100 / ${n_cols}) - calc(calc(${n_cols * 2 - 2} * calc(${$75777da1687ba3f6$var$strip_percent_unit(spacing_to_use)} / 2)) / ${n_cols}))`; // Width of one item in percent of the whole
3889
+ const one_item_width_exclusing_gaps = `calc(calc(100 / ${n_cols}) - calc(calc(${n_cols * 2 - 2} * calc(${$75777da1687ba3f6$var$strip_percent_unit(vertical_spacing_to_use)} / 2)) / ${n_cols}))`; // Width of one item in percent of the whole
3891
3890
  // Equation from layout.tsx, also used in CheckboxGrid. Needs half spacing for some reason
3892
3891
  const this_item_width_meat = `calc(${one_item_width_exclusing_gaps} * ${width_multiplier})`; // Width of just the card
3893
- const this_item_width_gaps = `calc(calc(${width_multiplier} - 1) * ${$75777da1687ba3f6$var$strip_percent_unit(spacing_to_use)})`; // Width of the gaps
3892
+ const this_item_width_gaps = `calc(calc(${width_multiplier} - 1) * ${$75777da1687ba3f6$var$strip_percent_unit(vertical_spacing_to_use)})`; // Width of the gaps
3894
3893
  const this_item_width = `calc(${this_item_width_meat} + ${this_item_width_gaps})`; // Width of this item including gaps
3895
3894
  // this_item_width needs to be unitless, and since plain css can't do calc(40% / 5%) which would become unitless we need to strip all units in the calculations before
3896
3895
  const convert_top_spacing_to_item_width_percentage = spacing => `calc(calc(100 / ${this_item_width}) * ${spacing})`; // Now finally we can convert the desired spacing to a percentage of this individual item's width (including gaps that would be there but aren't because content blocks span them)
3897
- spacing_styling = `column-gap:${spacing_to_use};`; // Still use gaps in the horizontal direction because that works flawlessly
3896
+ spacing_styling = `column-gap:${main_spacing_to_use};`; // Still use gaps in the horizontal direction because that works flawlessly
3898
3897
  // Re-use old layout code to get the correct :nth-child declarations for the top margins
3899
3898
  additional_styling = $5vyXB$depictaiutilishared.n_col_styling_with_dist(container_selector_ + ">", convert_top_spacing_to_item_width_percentage(default_grid_spacing_text), [[n_cols, min, max, grid_spacing_for_size ? convert_top_spacing_to_item_width_percentage(grid_spacing_for_size) : null]], "grid", override_vertical_spacing_ ? convert_top_spacing_to_item_width_percentage(override_vertical_spacing_) : override_vertical_spacing_, top_row_shortened_by_);
3900
3899
  }
@@ -3983,26 +3982,18 @@ const $d92f338ba8f9da9b$var$_tmpl$ = ["<div", ' class="content-block-wrapper" st
3983
3982
  function $d92f338ba8f9da9b$export$791ef57e62e21c3f({
3984
3983
  content_blocks_: incoming_content_blocks,
3985
3984
  cols_at_size_: cols_at_size_,
3986
- number_of_items_shown_: number_of_items_shown_,
3987
3985
  set_top_row_shortened_by_: set_top_row_shortened_by_
3988
3986
  }) {
3989
3987
  // these are by row
3990
3988
  const [content_blocks, set_content_blocks] = $5vyXB$solidjsstore.createStore([]);
3991
3989
  const n_cols_currently_showing_ = $055384b985678603$export$a79e666719b3647c(cols_at_size_);
3992
- const products_to_rows = products => {
3993
- const cols_currently_showing = n_cols_currently_showing_();
3994
- if (cols_currently_showing === null) return 0;
3995
- return Math.ceil(products / cols_currently_showing);
3996
- };
3997
- const showing_rows = $5vyXB$solidjs.createMemo(() => products_to_rows(number_of_items_shown_()));
3998
3990
  $5vyXB$solidjs.createEffect(() => {
3999
3991
  const incoming_value = incoming_content_blocks();
4000
3992
  if (!incoming_value) {
4001
3993
  set_content_blocks([]);
4002
3994
  return;
4003
3995
  }
4004
- const capped_value = incoming_value.slice(0, showing_rows()); // Don't show more content blocks than we have rows
4005
- set_content_blocks($5vyXB$solidjsstore.reconcile(capped_value, {
3996
+ set_content_blocks($5vyXB$solidjsstore.reconcile(incoming_value, {
4006
3997
  key: "content"
4007
3998
  })); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
4008
3999
  });
@@ -4059,12 +4050,12 @@ function $d92f338ba8f9da9b$var$remap_blocks_to_index({
4059
4050
  for (let j = 0; j < i; j++) {
4060
4051
  const row = displaced_products[j];
4061
4052
  if (row === undefined) continue; // there were no blocks in this row
4062
- let items_in_row;
4063
- if (typeof row === "number") items_in_row = row;else {
4064
- items_in_row = row.filter(item => item).length;
4065
- displaced_products[j] = items_in_row;
4053
+ let displaced_items_in_row;
4054
+ if (typeof row === "number") displaced_items_in_row = row;else {
4055
+ displaced_items_in_row = row.filter(item => item).length;
4056
+ displaced_products[j] = displaced_items_in_row;
4066
4057
  }
4067
- displacement_by_added_blocks += items_in_row;
4058
+ displacement_by_added_blocks += displaced_items_in_row;
4068
4059
  }
4069
4060
  const index_of_us_in_row = target_index - index_of_first_item_in_row;
4070
4061
  for (let j = 0; j < index_of_us_in_row; j++) if (displaced_products[i]?.[j])
@@ -4102,13 +4093,27 @@ function $d92f338ba8f9da9b$var$wrap_blocks_in_div(rendered_content_blocks, max_s
4102
4093
  const get_wrapped_blocks = $5vyXB$solidjs.mapArray(() => rendered_content_blocks, block => {
4103
4094
  if (!block) return;
4104
4095
  const get_span_columns = () => Math.min(block.span_columns, max_span_columns() ?? Infinity);
4096
+ const [rendering_delayed, set_rendering_delayed_] = $5vyXB$solidjs.createSignal(true);
4097
+ const content = $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
4098
+ get when() {
4099
+ return !rendering_delayed();
4100
+ },
4101
+ get children() {
4102
+ return $5vyXB$solidjsweb.ssr($d92f338ba8f9da9b$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), "grid-column:" + `span ${$5vyXB$solidjsweb.escape(get_span_columns(), true)}` + (";grid-row:" + `span ${$5vyXB$solidjsweb.escape(block.span_rows, true)}`) + (";spans_columns_variable_name:" + $5vyXB$solidjsweb.escape(get_span_columns(), true)), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent($d92f338ba8f9da9b$var$RenderContent, {
4103
+ get content() {
4104
+ return block.content;
4105
+ }
4106
+ })));
4107
+ }
4108
+ });
4105
4109
  return $5vyXB$solidjs.mergeProps(block, {
4106
4110
  // Create content divs for the blocks with as much fine-grained diffing as possible?
4107
- content: $5vyXB$solidjsweb.ssr($d92f338ba8f9da9b$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), "grid-column:" + `span ${$5vyXB$solidjsweb.escape(get_span_columns(), true)}` + (";grid-row:" + `span ${$5vyXB$solidjsweb.escape(block.span_rows, true)}`) + (";spans_columns_variable_name:" + $5vyXB$solidjsweb.escape(get_span_columns(), true)), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent($d92f338ba8f9da9b$var$RenderContent, {
4108
- get content() {
4109
- return block.content;
4110
- }
4111
- }))),
4111
+ content: () => {
4112
+ // Sneaky on-demand rendering, so we don't render more blocks than we can show: we have the rendered value here and don't return a function that renders because if our block would be moved around we'd be guaranteed to re-render
4113
+ // However, no need to count products to know if we should render: the <For> loops in Placeholders and render_displays will only call this function if there's actually a product here that wants to display this block
4114
+ set_rendering_delayed_(false);
4115
+ return content;
4116
+ },
4112
4117
  get span_columns() {
4113
4118
  // Cap max width of block to the number of columns available, for everyone downstream
4114
4119
  return get_span_columns();
@@ -4196,8 +4201,7 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
4196
4201
  let fallback_is_alive = false;
4197
4202
  const [get_should_have_placeholders_rendered, set_should_have_placeholders_rendered] = $5vyXB$solidjs.createSignal(true);
4198
4203
  const [top_row_shortened_by_, set_top_row_shortened_by_] = $5vyXB$solidjs.createSignal(0);
4199
- const [product_card_suspense_is_in_fallback, set_product_card_suspense_is_in_fallback] = $5vyXB$solidjs.createSignal(false);
4200
- const [number_loaded_displays, set_number_loaded_displays_] = $5vyXB$solidjs.createSignal(0);
4204
+ $5vyXB$solidjs.createSignal(false);
4201
4205
  const modified_cols_at_size = $738c3a81fc46a340$export$cb5808ba002cdeed({
4202
4206
  layout_options_: layout_options_,
4203
4207
  sort_or_filter_open_: sort_or_filter_open_
@@ -4208,12 +4212,10 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
4208
4212
  for_id: for_id
4209
4213
  }) => for_id === id_currently_querying_for_())?.min_results_loaded ?? min_products_to_fetch_);
4210
4214
  });
4211
- const number_of_items_shown_ = $5vyXB$solidjs.createMemo(() => is_loading_() || product_card_suspense_is_in_fallback() ? num_placeholders_() : number_loaded_displays());
4212
4215
  const doesnt_have_content_blocks = $5vyXB$solidjs.createMemo(() => !content_blocks_by_row_());
4213
4216
  const content_blocks_ = $5vyXB$solidjs.createMemo(() => doesnt_have_content_blocks() ? () => [] : $d92f338ba8f9da9b$export$791ef57e62e21c3f({
4214
4217
  content_blocks_: content_blocks_by_row_,
4215
4218
  cols_at_size_: modified_cols_at_size,
4216
- number_of_items_shown_: number_of_items_shown_,
4217
4219
  set_top_row_shortened_by_: set_top_row_shortened_by_
4218
4220
  }));
4219
4221
  const rendered_placeholders = $5vyXB$solidjs.createMemo(() => get_should_have_placeholders_rendered() ? $0caf87eaa19079da$export$f33414a4df0afd3f({
@@ -4253,8 +4255,6 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
4253
4255
  get fallback() {
4254
4256
  fallback_is_alive = true;
4255
4257
  $5vyXB$solidjs.onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
4256
- set_product_card_suspense_is_in_fallback(true); // Here for the content block code that needs to know how many items we're displaying
4257
- $5vyXB$solidjs.onCleanup(() => set_product_card_suspense_is_in_fallback(false));
4258
4258
  return $5vyXB$solidjs.createMemo(() => {
4259
4259
  // 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
4260
4260
  // In future we could have individual suspense's for each product card, but that's too much for now
@@ -4279,8 +4279,7 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
4279
4279
  query_base_: query_base_,
4280
4280
  depict_api_: depict_api_,
4281
4281
  is_loading_: is_loading_,
4282
- content_blocks_: content_blocks_,
4283
- set_number_loaded_displays_: set_number_loaded_displays_
4282
+ content_blocks_: content_blocks_
4284
4283
  });
4285
4284
  $5vyXB$solidjs.onCleanup(() => suspense_contents = undefined);
4286
4285
  return suspense_contents;
@@ -6,8 +6,8 @@ import { BaseCategoryDisplay, ProductListingResponse } from "@depict-ai/types/ap
6
6
  import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/api/SearchSuggestionsResponse";
7
7
  import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
8
8
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
9
- import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
10
- export const version = "2.1.1";
9
+ import { ProductListingRequestV2 } from "@depict-ai/types/api/ProductListingRequestV2";
10
+ export const version = "2.1.3";
11
11
  /**
12
12
  * Use `javascript_media_query` but return a reactive accessor instead of taking a callback function
13
13
  */
@@ -55,7 +55,7 @@ export function ImagePlaceholder(props: ImagePlaceholderBaseOptions & (ImagePlac
55
55
  * The interface for a content block.
56
56
  * Please make sure that you don't have content blocks overlap as that will cause undefined behavior.
57
57
  * The height of the content block will be the height of the tallest item in a row, so if there are no products in a row the content block needs to "bring its own height".
58
- * If you need to load any data in the content block, please make sure to return a placeholder while you're doing so, to avoid layout shifts and ensure scroll restoration works correctly.
58
+ * If you need to load any data in the content block, please make sure to return a placeholder while you're doing so (see `ImagePlaceholder`), to avoid layout shifts and ensure scroll restoration works correctly.
59
59
  *
60
60
  * - `span_columns`: How many columns the block should span. This will be capped to the number of columns available.
61
61
  * - `span_rows`: How many rows the block should span.
@@ -670,7 +670,7 @@ export class DepictAPI<InputDisplay extends Display, OutputDisplay extends Moder
670
670
  query(input_req: SearchRequest): Promise<SearchResponseAfterURLCreator & {
671
671
  failed?: true;
672
672
  }>;
673
- list(input_req: ProductListingRequest): Promise<ProductListingResponseAfterURLCreator & {
673
+ list(input_req: ProductListingRequestV2): Promise<ProductListingResponseAfterURLCreator & {
674
674
  failed?: true;
675
675
  }>;
676
676
  get_recommended<T extends Display>(input_req: BaseSearchRequest): Promise<{
@@ -6,7 +6,7 @@ import { createStore as $i7OB2$createStore, reconcile as $i7OB2$reconcile } from
6
6
  /*! Depict.ai search and product listing SDK */
7
7
  import { register_es_version } from "../../multi_import_deduplicator.mjs";
8
8
  register_es_version("ui", "latest");
9
- const $ec291e0010116877$export$83d89fbfd8236492 = "2.1.1";
9
+ const $ec291e0010116877$export$83d89fbfd8236492 = "2.1.3";
10
10
  const $4147651646da990a$var$fallback_operator = "in";
11
11
  const $4147651646da990a$var$fallback_token = "";
12
12
  const $4147651646da990a$var$legacy_filter_prefix = "filter_";
@@ -3691,8 +3691,7 @@ function $0449e7d49398c077$export$a1fd619a4743ca08({
3691
3691
  query_base_: query_base_,
3692
3692
  depict_api_: depict_api_,
3693
3693
  is_loading_: is_loading_,
3694
- content_blocks_: content_blocks_,
3695
- set_number_loaded_displays_: set_number_loaded_displays_
3694
+ content_blocks_: content_blocks_
3696
3695
  }) {
3697
3696
  // The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator and knowing when to load more
3698
3697
  const target_to_index_map = new Map();
@@ -3736,7 +3735,6 @@ function $0449e7d49398c077$export$a1fd619a4743ca08({
3736
3735
  query_base_: query_base_,
3737
3736
  depict_api_: depict_api_
3738
3737
  });
3739
- $i7OB2$createComputed(() => set_number_loaded_displays_(displays_by_key_().size));
3740
3738
  return $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
3741
3739
  displays_by_key_: displays_by_key_,
3742
3740
  merchant_: merchant_,
@@ -3812,25 +3810,26 @@ function $6dee9211e57ac31a$var$generate_media_queried_declarations({
3812
3810
  }) {
3813
3811
  return cols_at_size_.map(options => {
3814
3812
  const [n_cols, min, max, grid_spacing_for_size] = options;
3815
- const spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
3813
+ const main_spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
3816
3814
  // See comment in else block below
3817
- const can_use_gap = $6dee9211e57ac31a$var$can_use_gap_for_unit(spacing_to_use) && (!override_vertical_spacing_ || $6dee9211e57ac31a$var$can_use_gap_for_unit(override_vertical_spacing_));
3815
+ const can_use_gap = override_vertical_spacing_ ? $6dee9211e57ac31a$var$can_use_gap_for_unit(override_vertical_spacing_) : $6dee9211e57ac31a$var$can_use_gap_for_unit(main_spacing_to_use);
3818
3816
  let spacing_styling;
3819
3817
  let additional_styling = ""; // outside the media query
3820
- if (can_use_gap) spacing_styling = `gap:${spacing_to_use};${override_vertical_spacing_ ? `row-gap:${override_vertical_spacing_};` : ``}`;else {
3818
+ if (can_use_gap) spacing_styling = `gap:${main_spacing_to_use};${override_vertical_spacing_ ? `row-gap:${override_vertical_spacing_};` : ``}`;else {
3821
3819
  // When using percent units, which our default styling does (because convenient) and our interface relies on (hard to specify different gaps for different screen sizes)
3822
3820
  // row gaps in grids are relative to the whole height of the grid, maybe see also https://stackoverflow.com/a/53563865. The issue with that is that as we load more products, the gap grows. Also, it breaks existing integrations.
3823
3821
  // Logical thought: use margins for the vertical spacing. But margins in grids are apparently relative to the size of the individual items in grids.
3824
3822
  // Given that, and that content blocks can be of different width, we have to do some complicated calculations to convert the provided gap, which is in gap of the total container width, to a margin of the individual items.
3823
+ const vertical_spacing_to_use = override_vertical_spacing_ ?? main_spacing_to_use;
3825
3824
  const width_multiplier = `var(${$6dee9211e57ac31a$export$c500183c31c2b22e}, 1)`; // How many cards wide the current item is (needed because content blocks)
3826
- const one_item_width_exclusing_gaps = `calc(calc(100 / ${n_cols}) - calc(calc(${n_cols * 2 - 2} * calc(${$6dee9211e57ac31a$var$strip_percent_unit(spacing_to_use)} / 2)) / ${n_cols}))`; // Width of one item in percent of the whole
3825
+ const one_item_width_exclusing_gaps = `calc(calc(100 / ${n_cols}) - calc(calc(${n_cols * 2 - 2} * calc(${$6dee9211e57ac31a$var$strip_percent_unit(vertical_spacing_to_use)} / 2)) / ${n_cols}))`; // Width of one item in percent of the whole
3827
3826
  // Equation from layout.tsx, also used in CheckboxGrid. Needs half spacing for some reason
3828
3827
  const this_item_width_meat = `calc(${one_item_width_exclusing_gaps} * ${width_multiplier})`; // Width of just the card
3829
- const this_item_width_gaps = `calc(calc(${width_multiplier} - 1) * ${$6dee9211e57ac31a$var$strip_percent_unit(spacing_to_use)})`; // Width of the gaps
3828
+ const this_item_width_gaps = `calc(calc(${width_multiplier} - 1) * ${$6dee9211e57ac31a$var$strip_percent_unit(vertical_spacing_to_use)})`; // Width of the gaps
3830
3829
  const this_item_width = `calc(${this_item_width_meat} + ${this_item_width_gaps})`; // Width of this item including gaps
3831
3830
  // this_item_width needs to be unitless, and since plain css can't do calc(40% / 5%) which would become unitless we need to strip all units in the calculations before
3832
3831
  const convert_top_spacing_to_item_width_percentage = spacing => `calc(calc(100 / ${this_item_width}) * ${spacing})`; // Now finally we can convert the desired spacing to a percentage of this individual item's width (including gaps that would be there but aren't because content blocks span them)
3833
- spacing_styling = `column-gap:${spacing_to_use};`; // Still use gaps in the horizontal direction because that works flawlessly
3832
+ spacing_styling = `column-gap:${main_spacing_to_use};`; // Still use gaps in the horizontal direction because that works flawlessly
3834
3833
  // Re-use old layout code to get the correct :nth-child declarations for the top margins
3835
3834
  additional_styling = $i7OB2$n_col_styling_with_dist(container_selector_ + ">", convert_top_spacing_to_item_width_percentage(default_grid_spacing_text), [[n_cols, min, max, grid_spacing_for_size ? convert_top_spacing_to_item_width_percentage(grid_spacing_for_size) : null]], "grid", override_vertical_spacing_ ? convert_top_spacing_to_item_width_percentage(override_vertical_spacing_) : override_vertical_spacing_, top_row_shortened_by_);
3836
3835
  }
@@ -3919,26 +3918,18 @@ const $e7a7eb102ddc0c79$var$_tmpl$ = ["<div", ' class="content-block-wrapper" st
3919
3918
  function $e7a7eb102ddc0c79$export$791ef57e62e21c3f({
3920
3919
  content_blocks_: incoming_content_blocks,
3921
3920
  cols_at_size_: cols_at_size_,
3922
- number_of_items_shown_: number_of_items_shown_,
3923
3921
  set_top_row_shortened_by_: set_top_row_shortened_by_
3924
3922
  }) {
3925
3923
  // these are by row
3926
3924
  const [content_blocks, set_content_blocks] = $i7OB2$createStore([]);
3927
3925
  const n_cols_currently_showing_ = $bed740eef1769419$export$a79e666719b3647c(cols_at_size_);
3928
- const products_to_rows = products => {
3929
- const cols_currently_showing = n_cols_currently_showing_();
3930
- if (cols_currently_showing === null) return 0;
3931
- return Math.ceil(products / cols_currently_showing);
3932
- };
3933
- const showing_rows = $i7OB2$createMemo(() => products_to_rows(number_of_items_shown_()));
3934
3926
  $i7OB2$createEffect(() => {
3935
3927
  const incoming_value = incoming_content_blocks();
3936
3928
  if (!incoming_value) {
3937
3929
  set_content_blocks([]);
3938
3930
  return;
3939
3931
  }
3940
- const capped_value = incoming_value.slice(0, showing_rows()); // Don't show more content blocks than we have rows
3941
- set_content_blocks($i7OB2$reconcile(capped_value, {
3932
+ set_content_blocks($i7OB2$reconcile(incoming_value, {
3942
3933
  key: "content"
3943
3934
  })); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
3944
3935
  });
@@ -3995,12 +3986,12 @@ function $e7a7eb102ddc0c79$var$remap_blocks_to_index({
3995
3986
  for (let j = 0; j < i; j++) {
3996
3987
  const row = displaced_products[j];
3997
3988
  if (row === undefined) continue; // there were no blocks in this row
3998
- let items_in_row;
3999
- if (typeof row === "number") items_in_row = row;else {
4000
- items_in_row = row.filter(item => item).length;
4001
- displaced_products[j] = items_in_row;
3989
+ let displaced_items_in_row;
3990
+ if (typeof row === "number") displaced_items_in_row = row;else {
3991
+ displaced_items_in_row = row.filter(item => item).length;
3992
+ displaced_products[j] = displaced_items_in_row;
4002
3993
  }
4003
- displacement_by_added_blocks += items_in_row;
3994
+ displacement_by_added_blocks += displaced_items_in_row;
4004
3995
  }
4005
3996
  const index_of_us_in_row = target_index - index_of_first_item_in_row;
4006
3997
  for (let j = 0; j < index_of_us_in_row; j++) if (displaced_products[i]?.[j])
@@ -4038,13 +4029,27 @@ function $e7a7eb102ddc0c79$var$wrap_blocks_in_div(rendered_content_blocks, max_s
4038
4029
  const get_wrapped_blocks = $i7OB2$mapArray(() => rendered_content_blocks, block => {
4039
4030
  if (!block) return;
4040
4031
  const get_span_columns = () => Math.min(block.span_columns, max_span_columns() ?? Infinity);
4032
+ const [rendering_delayed, set_rendering_delayed_] = $i7OB2$createSignal(true);
4033
+ const content = $i7OB2$createComponent((0, $i7OB2$Show), {
4034
+ get when() {
4035
+ return !rendering_delayed();
4036
+ },
4037
+ get children() {
4038
+ return $i7OB2$ssr($e7a7eb102ddc0c79$var$_tmpl$, $i7OB2$ssrHydrationKey(), "grid-column:" + `span ${$i7OB2$escape(get_span_columns(), true)}` + (";grid-row:" + `span ${$i7OB2$escape(block.span_rows, true)}`) + (";spans_columns_variable_name:" + $i7OB2$escape(get_span_columns(), true)), $i7OB2$escape($i7OB2$createComponent($e7a7eb102ddc0c79$var$RenderContent, {
4039
+ get content() {
4040
+ return block.content;
4041
+ }
4042
+ })));
4043
+ }
4044
+ });
4041
4045
  return $i7OB2$mergeProps1(block, {
4042
4046
  // Create content divs for the blocks with as much fine-grained diffing as possible?
4043
- content: $i7OB2$ssr($e7a7eb102ddc0c79$var$_tmpl$, $i7OB2$ssrHydrationKey(), "grid-column:" + `span ${$i7OB2$escape(get_span_columns(), true)}` + (";grid-row:" + `span ${$i7OB2$escape(block.span_rows, true)}`) + (";spans_columns_variable_name:" + $i7OB2$escape(get_span_columns(), true)), $i7OB2$escape($i7OB2$createComponent($e7a7eb102ddc0c79$var$RenderContent, {
4044
- get content() {
4045
- return block.content;
4046
- }
4047
- }))),
4047
+ content: () => {
4048
+ // Sneaky on-demand rendering, so we don't render more blocks than we can show: we have the rendered value here and don't return a function that renders because if our block would be moved around we'd be guaranteed to re-render
4049
+ // However, no need to count products to know if we should render: the <For> loops in Placeholders and render_displays will only call this function if there's actually a product here that wants to display this block
4050
+ set_rendering_delayed_(false);
4051
+ return content;
4052
+ },
4048
4053
  get span_columns() {
4049
4054
  // Cap max width of block to the number of columns available, for everyone downstream
4050
4055
  return get_span_columns();
@@ -4132,8 +4137,7 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
4132
4137
  let fallback_is_alive = false;
4133
4138
  const [get_should_have_placeholders_rendered, set_should_have_placeholders_rendered] = $i7OB2$createSignal(true);
4134
4139
  const [top_row_shortened_by_, set_top_row_shortened_by_] = $i7OB2$createSignal(0);
4135
- const [product_card_suspense_is_in_fallback, set_product_card_suspense_is_in_fallback] = $i7OB2$createSignal(false);
4136
- const [number_loaded_displays, set_number_loaded_displays_] = $i7OB2$createSignal(0);
4140
+ $i7OB2$createSignal(false);
4137
4141
  const modified_cols_at_size = $15aa76e6da02e5c2$export$cb5808ba002cdeed({
4138
4142
  layout_options_: layout_options_,
4139
4143
  sort_or_filter_open_: sort_or_filter_open_
@@ -4144,12 +4148,10 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
4144
4148
  for_id: for_id
4145
4149
  }) => for_id === id_currently_querying_for_())?.min_results_loaded ?? min_products_to_fetch_);
4146
4150
  });
4147
- const number_of_items_shown_ = $i7OB2$createMemo(() => is_loading_() || product_card_suspense_is_in_fallback() ? num_placeholders_() : number_loaded_displays());
4148
4151
  const doesnt_have_content_blocks = $i7OB2$createMemo(() => !content_blocks_by_row_());
4149
4152
  const content_blocks_ = $i7OB2$createMemo(() => doesnt_have_content_blocks() ? () => [] : $e7a7eb102ddc0c79$export$791ef57e62e21c3f({
4150
4153
  content_blocks_: content_blocks_by_row_,
4151
4154
  cols_at_size_: modified_cols_at_size,
4152
- number_of_items_shown_: number_of_items_shown_,
4153
4155
  set_top_row_shortened_by_: set_top_row_shortened_by_
4154
4156
  }));
4155
4157
  const rendered_placeholders = $i7OB2$createMemo(() => get_should_have_placeholders_rendered() ? $6e41f1fde994db72$export$f33414a4df0afd3f({
@@ -4189,8 +4191,6 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
4189
4191
  get fallback() {
4190
4192
  fallback_is_alive = true;
4191
4193
  $i7OB2$onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
4192
- set_product_card_suspense_is_in_fallback(true); // Here for the content block code that needs to know how many items we're displaying
4193
- $i7OB2$onCleanup(() => set_product_card_suspense_is_in_fallback(false));
4194
4194
  return $i7OB2$createMemo(() => {
4195
4195
  // 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
4196
4196
  // In future we could have individual suspense's for each product card, but that's too much for now
@@ -4215,8 +4215,7 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
4215
4215
  query_base_: query_base_,
4216
4216
  depict_api_: depict_api_,
4217
4217
  is_loading_: is_loading_,
4218
- content_blocks_: content_blocks_,
4219
- set_number_loaded_displays_: set_number_loaded_displays_
4218
+ content_blocks_: content_blocks_
4220
4219
  });
4221
4220
  $i7OB2$onCleanup(() => suspense_contents = undefined);
4222
4221
  return suspense_contents;