@depict-ai/ui 4.7.29 → 4.7.30

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/latest/index.cjs CHANGED
@@ -1,8 +1,8 @@
1
1
  var $gVhhF$depictaiutilishared = require("@depict-ai/utilishared/latest");
2
- var $gVhhF$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest");
3
- var $gVhhF$solidjs = require("solid-js");
4
2
  var $gVhhF$solidjsweb = require("solid-js/web");
3
+ var $gVhhF$solidjs = require("solid-js");
5
4
  var $gVhhF$solidjsstore = require("solid-js/store");
5
+ var $gVhhF$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest");
6
6
  require("../multi_import_deduplicator.cjs").register_es_version("ui", "latest");
7
7
  function $parcel$export(e, n, v, s) {
8
8
  Object.defineProperty(e, n, {
@@ -12,6 +12,7 @@ function $parcel$export(e, n, v, s) {
12
12
  configurable: true
13
13
  });
14
14
  }
15
+ $parcel$export(module.exports, "remap_blocks_to_index", () => $d92f338ba8f9da9b$export$92aa5d691d588f3f);
15
16
  $parcel$export(module.exports, "useMobileHover", () => $8bf678c45948a297$export$d4d96868197be50e);
16
17
  $parcel$export(module.exports, "useVisibilityState", () => $55cbacb79d3e0cea$export$54299a3c81f5425);
17
18
  $parcel$export(module.exports, "useSlidableInformation", () => $a0e53f99354809d9$export$eaa625fb39439e37);
@@ -104,7 +105,407 @@ $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7
104
105
  $parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
105
106
  $parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
106
107
  /*! Depict.ai search and product listing SDK */
107
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.7.29";
108
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.7.30";
109
+ function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
110
+ const signal = $gVhhF$solidjs.createSignal(false);
111
+ $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
112
+ matches: matches
113
+ }) => signal[1](matches)).remove);
114
+ return signal[0];
115
+ }
116
+ function $17d06b3bcb035500$export$a79e666719b3647c(cols_at_size_) {
117
+ const size_active = $gVhhF$solidjs.createMemo(() => cols_at_size_().map(([n_cols, min_width, max_width]) => {
118
+ const media_query = $gVhhF$depictaiutilishared.layout_media_query_header(min_width, max_width).replaceAll("@media", "");
119
+ const matches = $b54e6192d0caa293$export$d9f36cf74e24d595(media_query);
120
+ return [matches, n_cols];
121
+ }));
122
+ const n_cols_currently_showing = $gVhhF$solidjs.createMemo(() => {
123
+ try {
124
+ const [, n_cols_currently_showing] = size_active().find(([media_query]) => media_query());
125
+ return n_cols_currently_showing;
126
+ } catch (e) {
127
+ $gVhhF$depictaiutilishared.dwarn("No active size found in columnsAtSize - can't render content blocks or looks");
128
+ return null;
129
+ }
130
+ });
131
+ return n_cols_currently_showing;
132
+ }
133
+
134
+ // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
135
+ class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
136
+ class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 {
137
+ constructor(templateError) {
138
+ super("Uncaught error in product card template", {
139
+ cause: templateError
140
+ });
141
+ }
142
+ }
143
+ var $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/>`);
144
+ const $edafe91daf3091d7$var$ExtraInfoContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
145
+ function $edafe91daf3091d7$export$240ecf5363d76c0f(props) {
146
+ return $gVhhF$solidjsweb.createComponent($edafe91daf3091d7$var$ExtraInfoContext.Provider, {
147
+ get value() {
148
+ return props.getContext_;
149
+ },
150
+ get children() {
151
+ return props.children;
152
+ }
153
+ });
154
+ }
155
+ function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
156
+ const getContextFunction = $gVhhF$solidjs.useContext($edafe91daf3091d7$var$ExtraInfoContext);
157
+ return $gVhhF$solidjs.ErrorBoundary({
158
+ fallback(err, retry) {
159
+ const {
160
+ message_: message_,
161
+ severity_: severity_
162
+ } = props;
163
+ let message = message_;
164
+ if (err instanceof (0, $7dd1edb2ee2b43ad$export$aa14a9f43128f61f)) {
165
+ console.error(err.cause);
166
+ message = `${message}: ${err.message}`;
167
+ } else $gVhhF$depictaiutilishared.report([err, message_], severity_, getContextFunction?.());
168
+ return (() => {
169
+ var _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$),
170
+ _el$2 = _el$.firstChild,
171
+ [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
172
+ _el$4 = _el$3.nextSibling,
173
+ [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
174
+ $gVhhF$solidjsweb.insert(_el$, message, _el$3, _co$);
175
+ $gVhhF$solidjsweb.insert(_el$, () => props.on_error_?.(retry), _el$5, _co$2);
176
+ $gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.classList(_el$, Object.fromEntries(props.class_list_?.map(c => [c, true]) || []), _$p));
177
+ return _el$;
178
+ })();
179
+ },
180
+ get children() {
181
+ return props.children;
182
+ }
183
+ });
184
+ }
185
+ var $75777da1687ba3f6$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
186
+ $75777da1687ba3f6$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
187
+ const $75777da1687ba3f6$export$c500183c31c2b22e = "--spans-columns";
188
+ function $75777da1687ba3f6$export$ab6b147eec64fea5(props) {
189
+ const container_class = "x" + $gVhhF$solidjs.createUniqueId();
190
+ const container_element_ = (() => {
191
+ var _el$ = $gVhhF$solidjsweb.getNextElement($75777da1687ba3f6$var$_tmpl$);
192
+ $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(() => props.element_attributes, {
193
+ "classList": {
194
+ [container_class]: true
195
+ }
196
+ }), false, true);
197
+ $gVhhF$solidjsweb.insert(_el$, () => props.children);
198
+ $gVhhF$solidjsweb.runHydrationEvents();
199
+ return _el$;
200
+ })(); // Don't want this in the error boundary below, it should only be for the actual layouting
201
+ return $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
202
+ message_: "Failed calculating css grid layout",
203
+ severity_: "error",
204
+ get children() {
205
+ return $75777da1687ba3f6$export$e2f22da34aaf310a(props, container_element_, false, container_class);
206
+ }
207
+ });
208
+ }
209
+ function $75777da1687ba3f6$export$e2f22da34aaf310a(props, container_element, insert_after_container = false, container_class) {
210
+ if (!container_class) {
211
+ // only try to add if it wasn't provided, so that we have a code path without classList when doing SSR
212
+ container_class = $gVhhF$depictaiutilishared.make_random_classname();
213
+ container_element.classList.add(container_class);
214
+ }
215
+ const container_selector = `.depict .${container_class}`; // class so ppl can have id if needed
216
+ const col_styling = $gVhhF$solidjs.createMemo(() => $75777da1687ba3f6$var$generate_media_queried_declarations({
217
+ container_selector_: container_selector,
218
+ default_grid_spacing_text: props.grid_spacing,
219
+ cols_at_size_: props.cols_at_size,
220
+ override_vertical_spacing_: props.override_vertical_spacing,
221
+ top_row_shortened_by_: props.top_row_shortened_by_()
222
+ }));
223
+ const base_styling = $gVhhF$solidjs.createMemo(() => {
224
+ return `${container_selector}{display:grid;}`;
225
+ });
226
+ const get_styling = $gVhhF$solidjs.createMemo(() => base_styling() + col_styling());
227
+ const style_element = (() => {
228
+ var _el$2 = $gVhhF$solidjsweb.getNextElement($75777da1687ba3f6$var$_tmpl$2);
229
+ $gVhhF$solidjsweb.insert(_el$2, get_styling);
230
+ return _el$2;
231
+ })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
232
+ if (insert_after_container) container_element.after(style_element);
233
+ return [container_element, style_element];
234
+ }
235
+ function $75777da1687ba3f6$var$generate_media_queried_declarations({
236
+ container_selector_: container_selector_,
237
+ default_grid_spacing_text: default_grid_spacing_text,
238
+ cols_at_size_: cols_at_size_,
239
+ override_vertical_spacing_: override_vertical_spacing_,
240
+ top_row_shortened_by_: top_row_shortened_by_
241
+ }) {
242
+ return cols_at_size_.map(options => {
243
+ const [n_cols, min, max, grid_spacing_for_size] = options;
244
+ const main_spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
245
+ // See comment in else block below
246
+ 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);
247
+ let spacing_styling;
248
+ let additional_styling = ""; // outside the media query
249
+ if (can_use_gap) spacing_styling = `gap:${main_spacing_to_use};${override_vertical_spacing_ ? `row-gap:${override_vertical_spacing_};` : ``}`;else {
250
+ // 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)
251
+ // 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.
252
+ // Logical thought: use margins for the vertical spacing. But margins in grids are apparently relative to the size of the individual items in grids.
253
+ // 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.
254
+ const vertical_spacing_to_use = override_vertical_spacing_ ?? main_spacing_to_use;
255
+ const width_multiplier = `var(${$75777da1687ba3f6$export$c500183c31c2b22e}, 1)`; // How many cards wide the current item is (needed because content blocks)
256
+ 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
257
+ // Equation from layout.tsx, also used in CheckboxGrid. Needs half spacing for some reason
258
+ const this_item_width_meat = `calc(${one_item_width_exclusing_gaps} * ${width_multiplier})`; // Width of just the card
259
+ const this_item_width_gaps = `calc(calc(${width_multiplier} - 1) * ${$75777da1687ba3f6$var$strip_percent_unit(vertical_spacing_to_use)})`; // Width of the gaps
260
+ const this_item_width = `calc(${this_item_width_meat} + ${this_item_width_gaps})`; // Width of this item including gaps
261
+ // 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
262
+ 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)
263
+ spacing_styling = `column-gap:${main_spacing_to_use};`; // Still use gaps in the horizontal direction because that works flawlessly
264
+ // Re-use old layout code to get the correct :nth-child declarations for the top margins
265
+ additional_styling = $gVhhF$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_);
266
+ }
267
+ const media_query_body = `${container_selector_}{${spacing_styling}grid-template-columns:repeat(${n_cols},minmax(0,1fr));}`;
268
+ return `${$gVhhF$depictaiutilishared.layout_media_query_header(min, max)}{${media_query_body}}${additional_styling}`;
269
+ }).join("");
270
+ }
271
+ function $75777da1687ba3f6$var$can_use_gap_for_unit(spacing) {
272
+ const trimmed_spacing = spacing.trim();
273
+ return !trimmed_spacing.includes("%");
274
+ }
275
+ function $75777da1687ba3f6$var$strip_percent_unit(css_value) {
276
+ return css_value.replaceAll("%", "");
277
+ }
278
+ var $9fe9883b1d8ecccc$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
279
+ function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
280
+ // Work around https://github.com/solidjs/solid/issues/1980
281
+ return (() => {
282
+ var _el$ = $gVhhF$solidjsweb.getNextElement($9fe9883b1d8ecccc$var$_tmpl$);
283
+ $gVhhF$solidjsweb.effect(_p$ => {
284
+ var _v$ = `${props.class || ""} depict-placeholder`,
285
+ _v$2 = props.style;
286
+ _v$ !== _p$.e && $gVhhF$solidjsweb.className(_el$, _p$.e = _v$);
287
+ _p$.t = $gVhhF$solidjsweb.style(_el$, _v$2, _p$.t);
288
+ return _p$;
289
+ }, {
290
+ e: undefined,
291
+ t: undefined
292
+ });
293
+ return _el$;
294
+ })();
295
+ }
296
+ function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
297
+ const style = $gVhhF$solidjs.createMemo(() => {
298
+ const {
299
+ style: style,
300
+ height: height,
301
+ width: width,
302
+ aspectRatio: aspectRatio
303
+ } = props;
304
+ const is_image = aspectRatio != undefined;
305
+ const size_data = is_image ? {
306
+ width: "100%",
307
+ "padding-bottom": `calc(calc(1 / ${aspectRatio}) * 100%)`
308
+ } : {
309
+ width: width,
310
+ height: height
311
+ };
312
+ return {
313
+ display: "block",
314
+ ...(style || {}),
315
+ ...size_data
316
+ };
317
+ });
318
+ return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
319
+ get style() {
320
+ return style();
321
+ },
322
+ get ["class"]() {
323
+ return props.class;
324
+ }
325
+ });
326
+ }
327
+ var $d92f338ba8f9da9b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=content-block-wrapper>`);
328
+ function $d92f338ba8f9da9b$export$791ef57e62e21c3f({
329
+ content_blocks_: incoming_content_blocks,
330
+ cols_at_size_: cols_at_size_,
331
+ set_top_row_shortened_by_: set_top_row_shortened_by_
332
+ }) {
333
+ // these are by row
334
+ const [content_blocks, set_content_blocks] = $gVhhF$solidjsstore.createStore([]);
335
+ const n_cols_currently_showing_ = $17d06b3bcb035500$export$a79e666719b3647c(cols_at_size_);
336
+ $gVhhF$solidjs.createEffect(() => {
337
+ const incoming_value = incoming_content_blocks();
338
+ if (!incoming_value) {
339
+ set_content_blocks([]);
340
+ return;
341
+ }
342
+ set_content_blocks($gVhhF$solidjsstore.reconcile(incoming_value, {
343
+ key: "content"
344
+ })); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
345
+ });
346
+
347
+ const get_wrapped_blocks_ = $d92f338ba8f9da9b$var$wrap_blocks_in_div(content_blocks, n_cols_currently_showing_);
348
+ $gVhhF$solidjs.createComputed(() => {
349
+ // Update our styling if a content block forces some items that should be in the top row into a lower one, so we can generate margin-top declarations for them
350
+ const top_row_block = get_wrapped_blocks_()[0];
351
+ const blocks_in_top_row_taken = top_row_block?.span_columns;
352
+ if (blocks_in_top_row_taken == undefined) {
353
+ // Fall back to zero if no content block in top row, since then no blocks in top row are taken
354
+ set_top_row_shortened_by_(0);
355
+ return;
356
+ }
357
+ set_top_row_shortened_by_(blocks_in_top_row_taken - 1); // minus one because the content block wrapper also is an element
358
+ });
359
+
360
+ return $gVhhF$solidjs.createMemo(() => $d92f338ba8f9da9b$export$92aa5d691d588f3f({
361
+ wrapped_blocks_: get_wrapped_blocks_(),
362
+ n_cols_currently_showing_: n_cols_currently_showing_()
363
+ }));
364
+ }
365
+ function $d92f338ba8f9da9b$export$92aa5d691d588f3f({
366
+ wrapped_blocks_: wrapped_blocks_,
367
+ n_cols_currently_showing_: n_cols_currently_showing_
368
+ }) {
369
+ // This computation should be quite cheap since it just moves around things into an array
370
+ const content_blocks_by_index = [];
371
+ const constructed_block_arrays = new WeakSet();
372
+ // Need to keep track of products displaced by blocks above when mapping rows to indexes in the actual grid
373
+ const displaced_products = []; // undefined = is product, true = is content block if number instead of tuple number indicates content blocks in that row. Index in first array is row, index in second array is column
374
+ if (!n_cols_currently_showing_)
375
+ // Nope out of here if we don't know how many columns are showing
376
+ return content_blocks_by_index;
377
+ for (let i = 0; i < wrapped_blocks_.length; i++) {
378
+ // i = row to show at
379
+ const block = wrapped_blocks_[i];
380
+ if (!block) continue; // Array can have holes/not defined places
381
+ const index_of_first_item_in_row = i * n_cols_currently_showing_;
382
+ const index_of_last_item_in_row = index_of_first_item_in_row + n_cols_currently_showing_;
383
+ const {
384
+ span_rows: span_rows,
385
+ position: position,
386
+ span_columns: span_columns
387
+ } = block; // span columns is already capped in the block wrapping step (wrap_blocks_in_div)
388
+ let target_index;
389
+ if (position === "left") target_index = index_of_first_item_in_row;else if (position === "right") target_index = index_of_last_item_in_row - span_columns;else if (position === "center") target_index = index_of_first_item_in_row + Math.floor((n_cols_currently_showing_ - span_columns) / 2);else throw new Error("Invalid position for content block - must be left, right or center: " + JSON.stringify(position));
390
+ // Calculate displacement of us by content blocks above us
391
+ let displacement_by_added_blocks = 0;
392
+ for (let j = 0; j < i; j++) {
393
+ const row = displaced_products[j];
394
+ if (row === undefined) continue; // there were no blocks in this row
395
+ let displaced_items_in_row;
396
+ if (typeof row === "number") displaced_items_in_row = row;else {
397
+ displaced_items_in_row = row.filter(item => item).length;
398
+ displaced_products[j] = displaced_items_in_row;
399
+ }
400
+ displacement_by_added_blocks += displaced_items_in_row;
401
+ }
402
+ const index_of_us_in_row = target_index - index_of_first_item_in_row;
403
+ for (let j = 0; j < index_of_us_in_row; j++) if (displaced_products[i]?.[j])
404
+ // Add blocks in our *current* row to the displacement, but only the ones to our left
405
+ displacement_by_added_blocks++;
406
+ // Add block to output array at the correct index
407
+ const final_target_index = target_index - displacement_by_added_blocks;
408
+ const existing_block = content_blocks_by_index[final_target_index];
409
+ const block_content = block.content;
410
+ // If two blocks want to exist at the same location (can happen, for example if one block wants to be at the end of a row and the other one at the start of the next row) add an array with both
411
+ if (existing_block) {
412
+ if (constructed_block_arrays.has(existing_block))
413
+ // Only push to arrays we have created to not create funky bugs when there's an array in JSX.Element
414
+ existing_block.push(block_content);else {
415
+ const array = [existing_block, block_content];
416
+ constructed_block_arrays.add(array);
417
+ content_blocks_by_index[final_target_index] = array;
418
+ }
419
+ } else content_blocks_by_index[final_target_index] = block_content;
420
+ // Update displacement
421
+ for (let j = 0; j < span_rows; j++) {
422
+ const row = displaced_products[i + j] ||= [];
423
+ for (let k = index_of_us_in_row; k < index_of_us_in_row + span_columns; k++) row[k] = true;
424
+ }
425
+ }
426
+ return content_blocks_by_index;
427
+ }
428
+ /**
429
+ * Takes a store that contains an array from where index is number of row and value is the result of executing the content block rendering function.
430
+ * Then renders the content and wraps it into a div with the correct styling.
431
+ * Also caps span_columns to max available columns
432
+ */
433
+ function $d92f338ba8f9da9b$var$wrap_blocks_in_div(rendered_content_blocks, max_span_columns) {
434
+ const get_wrapped_blocks = $gVhhF$solidjs.mapArray(() => rendered_content_blocks, block => {
435
+ if (!block) return;
436
+ const final_span_columns = $gVhhF$solidjs.createMemo(() => Math.min(block.span_columns, max_span_columns() ?? Infinity));
437
+ // If the item spans an entire row, limit the height to 1 row since there's no concept of "rows" if there are no products beside the block
438
+ const final_span_rows = $gVhhF$solidjs.createMemo(() => final_span_columns() === max_span_columns() ? 1 : block.span_rows);
439
+ const [rendering_delayed, set_rendering_delayed_] = $gVhhF$solidjs.createSignal(true);
440
+ const content = $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
441
+ get when() {
442
+ return !rendering_delayed();
443
+ },
444
+ get children() {
445
+ var _el$ = $gVhhF$solidjsweb.getNextElement($d92f338ba8f9da9b$var$_tmpl$);
446
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent($d92f338ba8f9da9b$var$RenderContent, {
447
+ get content() {
448
+ return block.content;
449
+ }
450
+ }));
451
+ $gVhhF$solidjsweb.effect(_p$ => {
452
+ var _v$ = {
453
+ [(0, $75777da1687ba3f6$export$c500183c31c2b22e)]: final_span_columns()
454
+ },
455
+ _v$2 = `span ${final_span_columns()}`,
456
+ _v$3 = `span ${final_span_rows()}`;
457
+ _p$.e = $gVhhF$solidjsweb.style(_el$, _v$, _p$.e);
458
+ _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("grid-column", _v$2) : _el$.style.removeProperty("grid-column"));
459
+ _v$3 !== _p$.a && ((_p$.a = _v$3) != null ? _el$.style.setProperty("grid-row", _v$3) : _el$.style.removeProperty("grid-row"));
460
+ return _p$;
461
+ }, {
462
+ e: undefined,
463
+ t: undefined,
464
+ a: undefined
465
+ });
466
+ return _el$;
467
+ }
468
+ });
469
+ return $gVhhF$solidjs.mergeProps(block, {
470
+ // Create content divs for the blocks with as much fine-grained diffing as possible?
471
+ content: () => {
472
+ // 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
473
+ // 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
474
+ set_rendering_delayed_(false);
475
+ return content;
476
+ },
477
+ get span_columns() {
478
+ // Cap max width of block to the number of columns available, for everyone downstream
479
+ return final_span_columns();
480
+ },
481
+ get span_rows() {
482
+ return final_span_rows();
483
+ }
484
+ });
485
+ });
486
+ return get_wrapped_blocks;
487
+ }
488
+ /**
489
+ * Basically adds support for async content block functions and shows a rudimentary placeholder if rendering is delayed. Required due to react having a rendering delay.
490
+ */
491
+ function $d92f338ba8f9da9b$var$RenderContent(props) {
492
+ const [resource] = $gVhhF$solidjs.createResource(() => props.content,
493
+ // Could be reactive
494
+ fn => fn());
495
+ $gVhhF$solidjs.createEffect(() => {
496
+ if (resource.error) console.error("Error in content block rendering", resource.error);
497
+ });
498
+ // The suspense is for when there's an async content block (which we have to support due to react having a rendering delay) so that we can show some height while it's loading (should kinda never be visible)
499
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
500
+ get fallback() {
501
+ return $gVhhF$solidjsweb.createComponent((0, $3bc4a89b971a3af5$export$3f37af283f8fb843), {
502
+ width: "100%",
503
+ height: "max(100%, 400px)"
504
+ });
505
+ },
506
+ children: resource
507
+ });
508
+ }
108
509
  let $8bf678c45948a297$var$elementsHoveredSignal;
109
510
  let $8bf678c45948a297$var$consumersSignal;
110
511
  function $8bf678c45948a297$export$d4d96868197be50e() {
@@ -762,57 +1163,6 @@ function $0caf87eaa19079da$var$Placeholder({
762
1163
  });
763
1164
  }
764
1165
 
765
- // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
766
- class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
767
- class $7dd1edb2ee2b43ad$export$aa14a9f43128f61f extends $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 {
768
- constructor(templateError) {
769
- super("Uncaught error in product card template", {
770
- cause: templateError
771
- });
772
- }
773
- }
774
- var $edafe91daf3091d7$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/>`);
775
- const $edafe91daf3091d7$var$ExtraInfoContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
776
- function $edafe91daf3091d7$export$240ecf5363d76c0f(props) {
777
- return $gVhhF$solidjsweb.createComponent($edafe91daf3091d7$var$ExtraInfoContext.Provider, {
778
- get value() {
779
- return props.getContext_;
780
- },
781
- get children() {
782
- return props.children;
783
- }
784
- });
785
- }
786
- function $edafe91daf3091d7$export$b69d0d92862de18b(props) {
787
- const getContextFunction = $gVhhF$solidjs.useContext($edafe91daf3091d7$var$ExtraInfoContext);
788
- return $gVhhF$solidjs.ErrorBoundary({
789
- fallback(err, retry) {
790
- const {
791
- message_: message_,
792
- severity_: severity_
793
- } = props;
794
- let message = message_;
795
- if (err instanceof (0, $7dd1edb2ee2b43ad$export$aa14a9f43128f61f)) {
796
- console.error(err.cause);
797
- message = `${message}: ${err.message}`;
798
- } else $gVhhF$depictaiutilishared.report([err, message_], severity_, getContextFunction?.());
799
- return (() => {
800
- var _el$ = $gVhhF$solidjsweb.getNextElement($edafe91daf3091d7$var$_tmpl$),
801
- _el$2 = _el$.firstChild,
802
- [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
803
- _el$4 = _el$3.nextSibling,
804
- [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
805
- $gVhhF$solidjsweb.insert(_el$, message, _el$3, _co$);
806
- $gVhhF$solidjsweb.insert(_el$, () => props.on_error_?.(retry), _el$5, _co$2);
807
- $gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.classList(_el$, Object.fromEntries(props.class_list_?.map(c => [c, true]) || []), _$p));
808
- return _el$;
809
- })();
810
- },
811
- get children() {
812
- return props.children;
813
- }
814
- });
815
- }
816
1166
  var $f48d0fbb00835aaa$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
817
1167
  $f48d0fbb00835aaa$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
818
1168
  function $f48d0fbb00835aaa$export$d21e32dfedac04be(props) {
@@ -1057,76 +1407,20 @@ function $95837413165cc2df$export$23fca46f3143581f(component, error_message) {
1057
1407
  });
1058
1408
  });else
1059
1409
  // we're already in a root so cleanups are handled
1060
- return component_in_error_boundary();
1061
- }
1062
- const $84798aaa863a4909$var$ListingContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
1063
- function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
1064
- const our_object = {};
1065
- return $gVhhF$solidjsweb.createComponent($84798aaa863a4909$var$ListingContext.Provider, {
1066
- value: our_object,
1067
- get children() {
1068
- return props.children;
1069
- }
1070
- });
1071
- }
1072
- function $84798aaa863a4909$export$8d0c4fdbb05a2f2e() {
1073
- return $gVhhF$solidjs.useContext($84798aaa863a4909$var$ListingContext);
1074
- }
1075
- var $9fe9883b1d8ecccc$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span>`);
1076
- function $9fe9883b1d8ecccc$export$acb3eaade4b23afd(props) {
1077
- // Work around https://github.com/solidjs/solid/issues/1980
1078
- return (() => {
1079
- var _el$ = $gVhhF$solidjsweb.getNextElement($9fe9883b1d8ecccc$var$_tmpl$);
1080
- $gVhhF$solidjsweb.effect(_p$ => {
1081
- var _v$ = `${props.class || ""} depict-placeholder`,
1082
- _v$2 = props.style;
1083
- _v$ !== _p$.e && $gVhhF$solidjsweb.className(_el$, _p$.e = _v$);
1084
- _p$.t = $gVhhF$solidjsweb.style(_el$, _v$2, _p$.t);
1085
- return _p$;
1086
- }, {
1087
- e: undefined,
1088
- t: undefined
1089
- });
1090
- return _el$;
1091
- })();
1092
- }
1093
- function $3bc4a89b971a3af5$export$3f37af283f8fb843(props) {
1094
- const style = $gVhhF$solidjs.createMemo(() => {
1095
- const {
1096
- style: style,
1097
- height: height,
1098
- width: width,
1099
- aspectRatio: aspectRatio
1100
- } = props;
1101
- const is_image = aspectRatio != undefined;
1102
- const size_data = is_image ? {
1103
- width: "100%",
1104
- "padding-bottom": `calc(calc(1 / ${aspectRatio}) * 100%)`
1105
- } : {
1106
- width: width,
1107
- height: height
1108
- };
1109
- return {
1110
- display: "block",
1111
- ...(style || {}),
1112
- ...size_data
1113
- };
1114
- });
1115
- return $gVhhF$solidjsweb.createComponent((0, $9fe9883b1d8ecccc$export$acb3eaade4b23afd), {
1116
- get style() {
1117
- return style();
1118
- },
1119
- get ["class"]() {
1120
- return props.class;
1410
+ return component_in_error_boundary();
1411
+ }
1412
+ const $84798aaa863a4909$var$ListingContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
1413
+ function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
1414
+ const our_object = {};
1415
+ return $gVhhF$solidjsweb.createComponent($84798aaa863a4909$var$ListingContext.Provider, {
1416
+ value: our_object,
1417
+ get children() {
1418
+ return props.children;
1121
1419
  }
1122
1420
  });
1123
1421
  }
1124
- function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
1125
- const signal = $gVhhF$solidjs.createSignal(false);
1126
- $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
1127
- matches: matches
1128
- }) => signal[1](matches)).remove);
1129
- return signal[0];
1422
+ function $84798aaa863a4909$export$8d0c4fdbb05a2f2e() {
1423
+ return $gVhhF$solidjs.useContext($84798aaa863a4909$var$ListingContext);
1130
1424
  }
1131
1425
  function $061ff5b4c3d36171$export$89c6019e4baa40b1(props) {
1132
1426
  const style = $gVhhF$solidjs.createMemo(() => {
@@ -1958,7 +2252,7 @@ function $bda357ff87c46163$export$44809a8a3e867e30({
1958
2252
  [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
1959
2253
  _el$4 = _el$3.nextSibling,
1960
2254
  [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
1961
- $gVhhF$solidjsweb.addEventListener(_el$, "click", $gVhhF$depictaiutilishared.catchify(() => setUserWantsExpanded(prev => display_() ? !prev : false)), true);
2255
+ $gVhhF$solidjsweb.addEventListener(_el$, "click", $gVhhF$depictaiutilishared.catchify(() => display_() && setUserWantsExpanded(prev => !prev)), true);
1962
2256
  $gVhhF$solidjsweb.use(el => {
1963
2257
  container = el;
1964
2258
  const ro = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
@@ -11017,99 +11311,6 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
11017
11311
  });
11018
11312
  return renderedDisplays_;
11019
11313
  }
11020
- var $75777da1687ba3f6$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
11021
- $75777da1687ba3f6$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
11022
- const $75777da1687ba3f6$export$c500183c31c2b22e = "--spans-columns";
11023
- function $75777da1687ba3f6$export$ab6b147eec64fea5(props) {
11024
- const container_class = "x" + $gVhhF$solidjs.createUniqueId();
11025
- const container_element_ = (() => {
11026
- var _el$ = $gVhhF$solidjsweb.getNextElement($75777da1687ba3f6$var$_tmpl$);
11027
- $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(() => props.element_attributes, {
11028
- "classList": {
11029
- [container_class]: true
11030
- }
11031
- }), false, true);
11032
- $gVhhF$solidjsweb.insert(_el$, () => props.children);
11033
- $gVhhF$solidjsweb.runHydrationEvents();
11034
- return _el$;
11035
- })(); // Don't want this in the error boundary below, it should only be for the actual layouting
11036
- return $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
11037
- message_: "Failed calculating css grid layout",
11038
- severity_: "error",
11039
- get children() {
11040
- return $75777da1687ba3f6$export$e2f22da34aaf310a(props, container_element_, false, container_class);
11041
- }
11042
- });
11043
- }
11044
- function $75777da1687ba3f6$export$e2f22da34aaf310a(props, container_element, insert_after_container = false, container_class) {
11045
- if (!container_class) {
11046
- // only try to add if it wasn't provided, so that we have a code path without classList when doing SSR
11047
- container_class = $gVhhF$depictaiutilishared.make_random_classname();
11048
- container_element.classList.add(container_class);
11049
- }
11050
- const container_selector = `.depict .${container_class}`; // class so ppl can have id if needed
11051
- const col_styling = $gVhhF$solidjs.createMemo(() => $75777da1687ba3f6$var$generate_media_queried_declarations({
11052
- container_selector_: container_selector,
11053
- default_grid_spacing_text: props.grid_spacing,
11054
- cols_at_size_: props.cols_at_size,
11055
- override_vertical_spacing_: props.override_vertical_spacing,
11056
- top_row_shortened_by_: props.top_row_shortened_by_()
11057
- }));
11058
- const base_styling = $gVhhF$solidjs.createMemo(() => {
11059
- return `${container_selector}{display:grid;}`;
11060
- });
11061
- const get_styling = $gVhhF$solidjs.createMemo(() => base_styling() + col_styling());
11062
- const style_element = (() => {
11063
- var _el$2 = $gVhhF$solidjsweb.getNextElement($75777da1687ba3f6$var$_tmpl$2);
11064
- $gVhhF$solidjsweb.insert(_el$2, get_styling);
11065
- return _el$2;
11066
- })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
11067
- if (insert_after_container) container_element.after(style_element);
11068
- return [container_element, style_element];
11069
- }
11070
- function $75777da1687ba3f6$var$generate_media_queried_declarations({
11071
- container_selector_: container_selector_,
11072
- default_grid_spacing_text: default_grid_spacing_text,
11073
- cols_at_size_: cols_at_size_,
11074
- override_vertical_spacing_: override_vertical_spacing_,
11075
- top_row_shortened_by_: top_row_shortened_by_
11076
- }) {
11077
- return cols_at_size_.map(options => {
11078
- const [n_cols, min, max, grid_spacing_for_size] = options;
11079
- const main_spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
11080
- // See comment in else block below
11081
- 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);
11082
- let spacing_styling;
11083
- let additional_styling = ""; // outside the media query
11084
- if (can_use_gap) spacing_styling = `gap:${main_spacing_to_use};${override_vertical_spacing_ ? `row-gap:${override_vertical_spacing_};` : ``}`;else {
11085
- // 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)
11086
- // 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.
11087
- // Logical thought: use margins for the vertical spacing. But margins in grids are apparently relative to the size of the individual items in grids.
11088
- // 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.
11089
- const vertical_spacing_to_use = override_vertical_spacing_ ?? main_spacing_to_use;
11090
- const width_multiplier = `var(${$75777da1687ba3f6$export$c500183c31c2b22e}, 1)`; // How many cards wide the current item is (needed because content blocks)
11091
- 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
11092
- // Equation from layout.tsx, also used in CheckboxGrid. Needs half spacing for some reason
11093
- const this_item_width_meat = `calc(${one_item_width_exclusing_gaps} * ${width_multiplier})`; // Width of just the card
11094
- const this_item_width_gaps = `calc(calc(${width_multiplier} - 1) * ${$75777da1687ba3f6$var$strip_percent_unit(vertical_spacing_to_use)})`; // Width of the gaps
11095
- const this_item_width = `calc(${this_item_width_meat} + ${this_item_width_gaps})`; // Width of this item including gaps
11096
- // 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
11097
- 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)
11098
- spacing_styling = `column-gap:${main_spacing_to_use};`; // Still use gaps in the horizontal direction because that works flawlessly
11099
- // Re-use old layout code to get the correct :nth-child declarations for the top margins
11100
- additional_styling = $gVhhF$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_);
11101
- }
11102
- const media_query_body = `${container_selector_}{${spacing_styling}grid-template-columns:repeat(${n_cols},minmax(0,1fr));}`;
11103
- return `${$gVhhF$depictaiutilishared.layout_media_query_header(min, max)}{${media_query_body}}${additional_styling}`;
11104
- }).join("");
11105
- }
11106
- function $75777da1687ba3f6$var$can_use_gap_for_unit(spacing) {
11107
- const trimmed_spacing = spacing.trim();
11108
- return !trimmed_spacing.includes("%");
11109
- }
11110
- function $75777da1687ba3f6$var$strip_percent_unit(css_value) {
11111
- return css_value.replaceAll("%", "");
11112
- }
11113
11314
  function $738c3a81fc46a340$export$cb5808ba002cdeed({
11114
11315
  layout_options_: layout_options_,
11115
11316
  sort_or_filter_open_: sort_or_filter_open_
@@ -11132,213 +11333,6 @@ function $738c3a81fc46a340$export$cb5808ba002cdeed({
11132
11333
  }) : when_filters_closed_cols;
11133
11334
  });
11134
11335
  }
11135
- function $17d06b3bcb035500$export$a79e666719b3647c(cols_at_size_) {
11136
- const size_active = $gVhhF$solidjs.createMemo(() => cols_at_size_().map(([n_cols, min_width, max_width]) => {
11137
- const media_query = $gVhhF$depictaiutilishared.layout_media_query_header(min_width, max_width).replaceAll("@media", "");
11138
- const matches = $b54e6192d0caa293$export$d9f36cf74e24d595(media_query);
11139
- return [matches, n_cols];
11140
- }));
11141
- const n_cols_currently_showing = $gVhhF$solidjs.createMemo(() => {
11142
- try {
11143
- const [, n_cols_currently_showing] = size_active().find(([media_query]) => media_query());
11144
- return n_cols_currently_showing;
11145
- } catch (e) {
11146
- $gVhhF$depictaiutilishared.dwarn("No active size found in columnsAtSize - can't render content blocks or looks");
11147
- return null;
11148
- }
11149
- });
11150
- return n_cols_currently_showing;
11151
- }
11152
- var $d92f338ba8f9da9b$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=content-block-wrapper>`);
11153
- function $d92f338ba8f9da9b$export$791ef57e62e21c3f({
11154
- content_blocks_: incoming_content_blocks,
11155
- cols_at_size_: cols_at_size_,
11156
- set_top_row_shortened_by_: set_top_row_shortened_by_
11157
- }) {
11158
- // these are by row
11159
- const [content_blocks, set_content_blocks] = $gVhhF$solidjsstore.createStore([]);
11160
- const n_cols_currently_showing_ = $17d06b3bcb035500$export$a79e666719b3647c(cols_at_size_);
11161
- $gVhhF$solidjs.createEffect(() => {
11162
- const incoming_value = incoming_content_blocks();
11163
- if (!incoming_value) {
11164
- set_content_blocks([]);
11165
- return;
11166
- }
11167
- set_content_blocks($gVhhF$solidjsstore.reconcile(incoming_value, {
11168
- key: "content"
11169
- })); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
11170
- });
11171
-
11172
- const get_wrapped_blocks_ = $d92f338ba8f9da9b$var$wrap_blocks_in_div(content_blocks, n_cols_currently_showing_);
11173
- $gVhhF$solidjs.createComputed(() => {
11174
- // Update our styling if a content block forces some items that should be in the top row into a lower one, so we can generate margin-top declarations for them
11175
- const top_row_block = get_wrapped_blocks_()[0];
11176
- const blocks_in_top_row_taken = top_row_block?.span_columns;
11177
- if (blocks_in_top_row_taken == undefined) {
11178
- // Fall back to zero if no content block in top row, since then no blocks in top row are taken
11179
- set_top_row_shortened_by_(0);
11180
- return;
11181
- }
11182
- set_top_row_shortened_by_(blocks_in_top_row_taken - 1); // minus one because the content block wrapper also is an element
11183
- });
11184
-
11185
- return $d92f338ba8f9da9b$var$remap_blocks_to_index({
11186
- get_wrapped_blocks_: get_wrapped_blocks_,
11187
- n_cols_currently_showing_: n_cols_currently_showing_
11188
- });
11189
- }
11190
- /**
11191
- * Calculate where to put each of the finished wrapped content blocks. Also limit blocks' max width.
11192
- * @returns an array where index is index of the blocks in the "displays array" and value is the content block (elements) to show at that index
11193
- */
11194
- function $d92f338ba8f9da9b$var$remap_blocks_to_index({
11195
- get_wrapped_blocks_: get_wrapped_blocks_,
11196
- n_cols_currently_showing_: n_cols_currently_showing_
11197
- }) {
11198
- return $gVhhF$solidjs.createMemo(() => {
11199
- // This computation should be quite cheap since it just moves around things into an array
11200
- const content_blocks_by_index = [];
11201
- const constructed_block_arrays = new WeakSet();
11202
- const wrapped_blocks = get_wrapped_blocks_();
11203
- const cols_showing = n_cols_currently_showing_();
11204
- // Need to keep track of products displaced by blocks above when mapping rows to indexes in the actual grid
11205
- const displaced_products = []; // undefined = is product, true = is content block if number instead of tuple number indicates content blocks in that row. Index in first array is row, index in second array is column
11206
- if (!cols_showing)
11207
- // Nope out of here if we don't know how many columns are showing
11208
- return content_blocks_by_index;
11209
- for (let i = 0; i < wrapped_blocks.length; i++) {
11210
- // i = row to show at
11211
- const block = wrapped_blocks[i];
11212
- if (!block) continue; // Array can have holes/not defined places
11213
- const index_of_first_item_in_row = i * cols_showing;
11214
- const index_of_last_item_in_row = index_of_first_item_in_row + cols_showing;
11215
- const {
11216
- span_rows: span_rows,
11217
- position: position,
11218
- span_columns: span_columns
11219
- } = block; // span columns is already capped in the block wrapping step (wrap_blocks_in_div)
11220
- let target_index;
11221
- if (position === "left") target_index = index_of_first_item_in_row;else if (position === "right") target_index = index_of_last_item_in_row - span_columns;else if (position === "center") target_index = index_of_first_item_in_row + Math.floor((cols_showing - span_columns) / 2);else throw new Error("Invalid position for content block - must be left, right or center: " + JSON.stringify(position));
11222
- // Calculate displacement of us by content blocks above us
11223
- let displacement_by_added_blocks = 0;
11224
- for (let j = 0; j < i; j++) {
11225
- const row = displaced_products[j];
11226
- if (row === undefined) continue; // there were no blocks in this row
11227
- let displaced_items_in_row;
11228
- if (typeof row === "number") displaced_items_in_row = row;else {
11229
- displaced_items_in_row = row.filter(item => item).length;
11230
- displaced_products[j] = displaced_items_in_row;
11231
- }
11232
- displacement_by_added_blocks += displaced_items_in_row;
11233
- }
11234
- const index_of_us_in_row = target_index - index_of_first_item_in_row;
11235
- for (let j = 0; j < index_of_us_in_row; j++) if (displaced_products[i]?.[j])
11236
- // Add blocks in our *current* row to the displacement, but only the ones to our left
11237
- displacement_by_added_blocks++;
11238
- // Add block to output array at the correct index
11239
- const final_target_index = target_index - displacement_by_added_blocks;
11240
- const existing_block = content_blocks_by_index[final_target_index];
11241
- const block_content = block.content;
11242
- // If two blocks want to exist at the same location (can happen, for example if one block wants to be at the end of a row and the other one at the start of the next row) add an array with both
11243
- if (existing_block) {
11244
- if (constructed_block_arrays.has(existing_block))
11245
- // Only push to arrays we have created to not create funky bugs when there's an array in JSX.Element
11246
- existing_block.push(block_content);else {
11247
- const array = [existing_block, block_content];
11248
- constructed_block_arrays.add(array);
11249
- content_blocks_by_index[final_target_index] = array;
11250
- }
11251
- } else content_blocks_by_index[final_target_index] = block_content;
11252
- // Update displacement
11253
- for (let j = 0; j < span_rows; j++) {
11254
- const row = displaced_products[i + j] ||= [];
11255
- for (let k = index_of_us_in_row; k < index_of_us_in_row + span_columns; k++) row[k] = true;
11256
- }
11257
- }
11258
- return content_blocks_by_index;
11259
- });
11260
- }
11261
- /**
11262
- * Takes a store that contains an array from where index is number of row and value is the result of executing the content block rendering function.
11263
- * Then renders the content and wraps it into a div with the correct styling.
11264
- * Also caps span_columns to max available columns
11265
- */
11266
- function $d92f338ba8f9da9b$var$wrap_blocks_in_div(rendered_content_blocks, max_span_columns) {
11267
- const get_wrapped_blocks = $gVhhF$solidjs.mapArray(() => rendered_content_blocks, block => {
11268
- if (!block) return;
11269
- const final_span_columns = $gVhhF$solidjs.createMemo(() => Math.min(block.span_columns, max_span_columns() ?? Infinity));
11270
- // If the item spans an entire row, limit the height to 1 row since there's no concept of "rows" if there are no products beside the block
11271
- const final_span_rows = $gVhhF$solidjs.createMemo(() => final_span_columns() === max_span_columns() ? 1 : block.span_rows);
11272
- const [rendering_delayed, set_rendering_delayed_] = $gVhhF$solidjs.createSignal(true);
11273
- const content = $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
11274
- get when() {
11275
- return !rendering_delayed();
11276
- },
11277
- get children() {
11278
- var _el$ = $gVhhF$solidjsweb.getNextElement($d92f338ba8f9da9b$var$_tmpl$);
11279
- $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent($d92f338ba8f9da9b$var$RenderContent, {
11280
- get content() {
11281
- return block.content;
11282
- }
11283
- }));
11284
- $gVhhF$solidjsweb.effect(_p$ => {
11285
- var _v$ = {
11286
- [(0, $75777da1687ba3f6$export$c500183c31c2b22e)]: final_span_columns()
11287
- },
11288
- _v$2 = `span ${final_span_columns()}`,
11289
- _v$3 = `span ${final_span_rows()}`;
11290
- _p$.e = $gVhhF$solidjsweb.style(_el$, _v$, _p$.e);
11291
- _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("grid-column", _v$2) : _el$.style.removeProperty("grid-column"));
11292
- _v$3 !== _p$.a && ((_p$.a = _v$3) != null ? _el$.style.setProperty("grid-row", _v$3) : _el$.style.removeProperty("grid-row"));
11293
- return _p$;
11294
- }, {
11295
- e: undefined,
11296
- t: undefined,
11297
- a: undefined
11298
- });
11299
- return _el$;
11300
- }
11301
- });
11302
- return $gVhhF$solidjs.mergeProps(block, {
11303
- // Create content divs for the blocks with as much fine-grained diffing as possible?
11304
- content: () => {
11305
- // 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
11306
- // 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
11307
- set_rendering_delayed_(false);
11308
- return content;
11309
- },
11310
- get span_columns() {
11311
- // Cap max width of block to the number of columns available, for everyone downstream
11312
- return final_span_columns();
11313
- },
11314
- get span_rows() {
11315
- return final_span_rows();
11316
- }
11317
- });
11318
- });
11319
- return get_wrapped_blocks;
11320
- }
11321
- /**
11322
- * Basically adds support for async content block functions and shows a rudimentary placeholder if rendering is delayed. Required due to react having a rendering delay.
11323
- */
11324
- function $d92f338ba8f9da9b$var$RenderContent(props) {
11325
- const [resource] = $gVhhF$solidjs.createResource(() => props.content,
11326
- // Could be reactive
11327
- fn => fn());
11328
- $gVhhF$solidjs.createEffect(() => {
11329
- if (resource.error) console.error("Error in content block rendering", resource.error);
11330
- });
11331
- // The suspense is for when there's an async content block (which we have to support due to react having a rendering delay) so that we can show some height while it's loading (should kinda never be visible)
11332
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
11333
- get fallback() {
11334
- return $gVhhF$solidjsweb.createComponent((0, $3bc4a89b971a3af5$export$3f37af283f8fb843), {
11335
- width: "100%",
11336
- height: "max(100%, 400px)"
11337
- });
11338
- },
11339
- children: resource
11340
- });
11341
- }
11342
11336
  var $fe76fb463cc60b89$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=PLP-results><!$><!/><!$><!/>`);
11343
11337
  function $fe76fb463cc60b89$export$3925f87b1545cfc6({
11344
11338
  plp_results_: plp_results_,