@depict-ai/ui 4.7.28 → 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/ES10/index.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  var $52FdA$depictaiutilishared = require("@depict-ai/utilishared/ES10");
2
- var $52FdA$depictaiutilisharedlatest = require("@depict-ai/utilishared/ES10");
3
- var $52FdA$solidjs = require("solid-js");
4
2
  var $52FdA$solidjsweb = require("solid-js/web");
3
+ var $52FdA$solidjs = require("solid-js");
4
+ var $52FdA$solidjsstore = require("solid-js/store");
5
+ var $52FdA$depictaiutilisharedlatest = require("@depict-ai/utilishared/ES10");
5
6
  var $52FdA$babelruntimehelpersdefineProperty = require("@babel/runtime/helpers/defineProperty");
6
7
  var $52FdA$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
7
8
  var $52FdA$babelruntimehelpersclassPrivateFieldGet = require("@babel/runtime/helpers/classPrivateFieldGet");
8
- var $52FdA$solidjsstore = require("solid-js/store");
9
9
  require("../multi_import_deduplicator.cjs").register_es_version("ui", "ES10");
10
10
  function $parcel$export(e, n, v, s) {
11
11
  Object.defineProperty(e, n, {
@@ -18,6 +18,7 @@ function $parcel$export(e, n, v, s) {
18
18
  function $parcel$interopDefault(a) {
19
19
  return a && a.__esModule ? a.default : a;
20
20
  }
21
+ $parcel$export(module.exports, "remap_blocks_to_index", () => $f8f375d6245ffff2$export$92aa5d691d588f3f);
21
22
  $parcel$export(module.exports, "useMobileHover", () => $0deb6ff75e3d67c6$export$d4d96868197be50e);
22
23
  $parcel$export(module.exports, "useVisibilityState", () => $e7a7d2fe8a8217d8$export$54299a3c81f5425);
23
24
  $parcel$export(module.exports, "useSlidableInformation", () => $ad8ec7729fffeb9c$export$eaa625fb39439e37);
@@ -110,7 +111,432 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
110
111
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
111
112
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
112
113
  /*! Depict.ai search and product listing SDK */
113
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.7.28";
114
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.7.30";
115
+ function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
116
+ const signal = $52FdA$solidjs.createSignal(false);
117
+ $52FdA$solidjs.onCleanup($52FdA$depictaiutilishared.javascript_media_query(media_query, _ref => {
118
+ let {
119
+ matches: matches
120
+ } = _ref;
121
+ return signal[1](matches);
122
+ }).remove);
123
+ return signal[0];
124
+ }
125
+ function $478e5a09664da64c$export$a79e666719b3647c(cols_at_size_) {
126
+ const size_active = $52FdA$solidjs.createMemo(() => cols_at_size_().map(_ref => {
127
+ let [n_cols, min_width, max_width] = _ref;
128
+ const media_query = $52FdA$depictaiutilishared.layout_media_query_header(min_width, max_width).replaceAll("@media", "");
129
+ const matches = $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query);
130
+ return [matches, n_cols];
131
+ }));
132
+ const n_cols_currently_showing = $52FdA$solidjs.createMemo(() => {
133
+ try {
134
+ const [, n_cols_currently_showing] = size_active().find(_ref2 => {
135
+ let [media_query] = _ref2;
136
+ return media_query();
137
+ });
138
+ return n_cols_currently_showing;
139
+ } catch (e) {
140
+ $52FdA$depictaiutilishared.dwarn("No active size found in columnsAtSize - can't render content blocks or looks");
141
+ return null;
142
+ }
143
+ });
144
+ return n_cols_currently_showing;
145
+ }
146
+
147
+ // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
148
+ class $95e4006e1dcb5b72$export$e1d52e4f0c7557a1 extends Error {}
149
+ class $95e4006e1dcb5b72$export$aa14a9f43128f61f extends $95e4006e1dcb5b72$export$e1d52e4f0c7557a1 {
150
+ constructor(templateError) {
151
+ super("Uncaught error in product card template", {
152
+ cause: templateError
153
+ });
154
+ }
155
+ }
156
+ var $1b3cf201cdd38687$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div><!$><!/><!$><!/>`);
157
+ const $1b3cf201cdd38687$var$ExtraInfoContext = /*@__PURE__*/$52FdA$solidjs.createContext();
158
+ function $1b3cf201cdd38687$export$240ecf5363d76c0f(props) {
159
+ return $52FdA$solidjsweb.createComponent($1b3cf201cdd38687$var$ExtraInfoContext.Provider, {
160
+ get value() {
161
+ return props.getContext_;
162
+ },
163
+ get children() {
164
+ return props.children;
165
+ }
166
+ });
167
+ }
168
+ function $1b3cf201cdd38687$export$b69d0d92862de18b(props) {
169
+ const getContextFunction = $52FdA$solidjs.useContext($1b3cf201cdd38687$var$ExtraInfoContext);
170
+ return $52FdA$solidjs.ErrorBoundary({
171
+ fallback(err, retry) {
172
+ const {
173
+ message_: message_,
174
+ severity_: severity_
175
+ } = props;
176
+ let message = message_;
177
+ if (err instanceof (0, $95e4006e1dcb5b72$export$aa14a9f43128f61f)) {
178
+ console.error(err.cause);
179
+ message = "".concat(message, ": ").concat(err.message);
180
+ } else $52FdA$depictaiutilishared.report([err, message_], severity_, getContextFunction === null || getContextFunction === void 0 ? void 0 : getContextFunction());
181
+ return (() => {
182
+ var _el$ = $52FdA$solidjsweb.getNextElement($1b3cf201cdd38687$var$_tmpl$),
183
+ _el$2 = _el$.firstChild,
184
+ [_el$3, _co$] = $52FdA$solidjsweb.getNextMarker(_el$2.nextSibling),
185
+ _el$4 = _el$3.nextSibling,
186
+ [_el$5, _co$2] = $52FdA$solidjsweb.getNextMarker(_el$4.nextSibling);
187
+ $52FdA$solidjsweb.insert(_el$, message, _el$3, _co$);
188
+ $52FdA$solidjsweb.insert(_el$, () => {
189
+ var _props$on_error_;
190
+ return (_props$on_error_ = props.on_error_) === null || _props$on_error_ === void 0 ? void 0 : _props$on_error_.call(props, retry);
191
+ }, _el$5, _co$2);
192
+ $52FdA$solidjsweb.effect(_$p => {
193
+ var _props$class_list_;
194
+ return $52FdA$solidjsweb.classList(_el$, Object.fromEntries(((_props$class_list_ = props.class_list_) === null || _props$class_list_ === void 0 ? void 0 : _props$class_list_.map(c => [c, true])) || []), _$p);
195
+ });
196
+ return _el$;
197
+ })();
198
+ },
199
+ get children() {
200
+ return props.children;
201
+ }
202
+ });
203
+ }
204
+ var $830518481649feb1$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div>`),
205
+ $830518481649feb1$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<style type=text/css>`);
206
+ const $830518481649feb1$export$c500183c31c2b22e = "--spans-columns";
207
+ function $830518481649feb1$export$ab6b147eec64fea5(props) {
208
+ const container_class = "x" + $52FdA$solidjs.createUniqueId();
209
+ const container_element_ = (() => {
210
+ var _el$ = $52FdA$solidjsweb.getNextElement($830518481649feb1$var$_tmpl$);
211
+ $52FdA$solidjsweb.spread(_el$, $52FdA$solidjsweb.mergeProps(() => props.element_attributes, {
212
+ "classList": {
213
+ [container_class]: true
214
+ }
215
+ }), false, true);
216
+ $52FdA$solidjsweb.insert(_el$, () => props.children);
217
+ $52FdA$solidjsweb.runHydrationEvents();
218
+ return _el$;
219
+ })(); // Don't want this in the error boundary below, it should only be for the actual layouting
220
+ return $52FdA$solidjsweb.createComponent((0, $1b3cf201cdd38687$export$b69d0d92862de18b), {
221
+ message_: "Failed calculating css grid layout",
222
+ severity_: "error",
223
+ get children() {
224
+ return $830518481649feb1$export$e2f22da34aaf310a(props, container_element_, false, container_class);
225
+ }
226
+ });
227
+ }
228
+ function $830518481649feb1$export$e2f22da34aaf310a(props, container_element) {
229
+ let insert_after_container = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
230
+ let container_class = arguments.length > 3 ? arguments[3] : undefined;
231
+ if (!container_class) {
232
+ // only try to add if it wasn't provided, so that we have a code path without classList when doing SSR
233
+ container_class = $52FdA$depictaiutilishared.make_random_classname();
234
+ container_element.classList.add(container_class);
235
+ }
236
+ const container_selector = ".depict .".concat(container_class); // class so ppl can have id if needed
237
+ const col_styling = $52FdA$solidjs.createMemo(() => $830518481649feb1$var$generate_media_queried_declarations({
238
+ container_selector_: container_selector,
239
+ default_grid_spacing_text: props.grid_spacing,
240
+ cols_at_size_: props.cols_at_size,
241
+ override_vertical_spacing_: props.override_vertical_spacing,
242
+ top_row_shortened_by_: props.top_row_shortened_by_()
243
+ }));
244
+ const base_styling = $52FdA$solidjs.createMemo(() => {
245
+ return "".concat(container_selector, "{display:grid;}");
246
+ });
247
+ const get_styling = $52FdA$solidjs.createMemo(() => base_styling() + col_styling());
248
+ const style_element = (() => {
249
+ var _el$2 = $52FdA$solidjsweb.getNextElement($830518481649feb1$var$_tmpl$2);
250
+ $52FdA$solidjsweb.insert(_el$2, get_styling);
251
+ return _el$2;
252
+ })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
253
+ if (insert_after_container) container_element.after(style_element);
254
+ return [container_element, style_element];
255
+ }
256
+ function $830518481649feb1$var$generate_media_queried_declarations(_ref) {
257
+ let {
258
+ container_selector_: container_selector_,
259
+ default_grid_spacing_text: default_grid_spacing_text,
260
+ cols_at_size_: cols_at_size_,
261
+ override_vertical_spacing_: override_vertical_spacing_,
262
+ top_row_shortened_by_: top_row_shortened_by_
263
+ } = _ref;
264
+ return cols_at_size_.map(options => {
265
+ const [n_cols, min, max, grid_spacing_for_size] = options;
266
+ const main_spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
267
+ // See comment in else block below
268
+ const can_use_gap = override_vertical_spacing_ ? $830518481649feb1$var$can_use_gap_for_unit(override_vertical_spacing_) : $830518481649feb1$var$can_use_gap_for_unit(main_spacing_to_use);
269
+ let spacing_styling;
270
+ let additional_styling = ""; // outside the media query
271
+ if (can_use_gap) spacing_styling = "gap:".concat(main_spacing_to_use, ";").concat(override_vertical_spacing_ ? "row-gap:".concat(override_vertical_spacing_, ";") : "");else {
272
+ // 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)
273
+ // 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.
274
+ // Logical thought: use margins for the vertical spacing. But margins in grids are apparently relative to the size of the individual items in grids.
275
+ // 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.
276
+ const vertical_spacing_to_use = override_vertical_spacing_ !== null && override_vertical_spacing_ !== void 0 ? override_vertical_spacing_ : main_spacing_to_use;
277
+ const width_multiplier = "var(".concat($830518481649feb1$export$c500183c31c2b22e, ", 1)"); // How many cards wide the current item is (needed because content blocks)
278
+ const one_item_width_exclusing_gaps = "calc(calc(100 / ".concat(n_cols, ") - calc(calc(").concat(n_cols * 2 - 2, " * calc(").concat($830518481649feb1$var$strip_percent_unit(vertical_spacing_to_use), " / 2)) / ").concat(n_cols, "))"); // Width of one item in percent of the whole
279
+ // Equation from layout.tsx, also used in CheckboxGrid. Needs half spacing for some reason
280
+ const this_item_width_meat = "calc(".concat(one_item_width_exclusing_gaps, " * ").concat(width_multiplier, ")"); // Width of just the card
281
+ const this_item_width_gaps = "calc(calc(".concat(width_multiplier, " - 1) * ").concat($830518481649feb1$var$strip_percent_unit(vertical_spacing_to_use), ")"); // Width of the gaps
282
+ const this_item_width = "calc(".concat(this_item_width_meat, " + ").concat(this_item_width_gaps, ")"); // Width of this item including gaps
283
+ // 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
284
+ const convert_top_spacing_to_item_width_percentage = spacing => "calc(calc(100 / ".concat(this_item_width, ") * ").concat(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)
285
+ spacing_styling = "column-gap:".concat(main_spacing_to_use, ";"); // Still use gaps in the horizontal direction because that works flawlessly
286
+ // Re-use old layout code to get the correct :nth-child declarations for the top margins
287
+ additional_styling = $52FdA$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_);
288
+ }
289
+ const media_query_body = "".concat(container_selector_, "{").concat(spacing_styling, "grid-template-columns:repeat(").concat(n_cols, ",minmax(0,1fr));}");
290
+ return "".concat($52FdA$depictaiutilishared.layout_media_query_header(min, max), "{").concat(media_query_body, "}").concat(additional_styling);
291
+ }).join("");
292
+ }
293
+ function $830518481649feb1$var$can_use_gap_for_unit(spacing) {
294
+ const trimmed_spacing = spacing.trim();
295
+ return !trimmed_spacing.includes("%");
296
+ }
297
+ function $830518481649feb1$var$strip_percent_unit(css_value) {
298
+ return css_value.replaceAll("%", "");
299
+ }
300
+ var $e3d733f899558f40$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<span>`);
301
+ function $e3d733f899558f40$export$acb3eaade4b23afd(props) {
302
+ // Work around https://github.com/solidjs/solid/issues/1980
303
+ return (() => {
304
+ var _el$ = $52FdA$solidjsweb.getNextElement($e3d733f899558f40$var$_tmpl$);
305
+ $52FdA$solidjsweb.effect(_p$ => {
306
+ var _v$ = "".concat(props.class || "", " depict-placeholder"),
307
+ _v$2 = props.style;
308
+ _v$ !== _p$.e && $52FdA$solidjsweb.className(_el$, _p$.e = _v$);
309
+ _p$.t = $52FdA$solidjsweb.style(_el$, _v$2, _p$.t);
310
+ return _p$;
311
+ }, {
312
+ e: undefined,
313
+ t: undefined
314
+ });
315
+ return _el$;
316
+ })();
317
+ }
318
+ function $b8a8d61b3ec5f5ac$export$3f37af283f8fb843(props) {
319
+ const style = $52FdA$solidjs.createMemo(() => {
320
+ const {
321
+ style: style,
322
+ height: height,
323
+ width: width,
324
+ aspectRatio: aspectRatio
325
+ } = props;
326
+ const is_image = aspectRatio != undefined;
327
+ const size_data = is_image ? {
328
+ width: "100%",
329
+ "padding-bottom": "calc(calc(1 / ".concat(aspectRatio, ") * 100%)")
330
+ } : {
331
+ width: width,
332
+ height: height
333
+ };
334
+ return {
335
+ display: "block",
336
+ ...(style || {}),
337
+ ...size_data
338
+ };
339
+ });
340
+ return $52FdA$solidjsweb.createComponent((0, $e3d733f899558f40$export$acb3eaade4b23afd), {
341
+ get style() {
342
+ return style();
343
+ },
344
+ get ["class"]() {
345
+ return props.class;
346
+ }
347
+ });
348
+ }
349
+ var $f8f375d6245ffff2$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class=content-block-wrapper>`);
350
+ function $f8f375d6245ffff2$export$791ef57e62e21c3f(_ref) {
351
+ let {
352
+ content_blocks_: incoming_content_blocks,
353
+ cols_at_size_: cols_at_size_,
354
+ set_top_row_shortened_by_: set_top_row_shortened_by_
355
+ } = _ref;
356
+ // these are by row
357
+ const [content_blocks, set_content_blocks] = $52FdA$solidjsstore.createStore([]);
358
+ const n_cols_currently_showing_ = $478e5a09664da64c$export$a79e666719b3647c(cols_at_size_);
359
+ $52FdA$solidjs.createEffect(() => {
360
+ const incoming_value = incoming_content_blocks();
361
+ if (!incoming_value) {
362
+ set_content_blocks([]);
363
+ return;
364
+ }
365
+ set_content_blocks($52FdA$solidjsstore.reconcile(incoming_value, {
366
+ key: "content"
367
+ })); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
368
+ });
369
+
370
+ const get_wrapped_blocks_ = $f8f375d6245ffff2$var$wrap_blocks_in_div(content_blocks, n_cols_currently_showing_);
371
+ $52FdA$solidjs.createComputed(() => {
372
+ // 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
373
+ const top_row_block = get_wrapped_blocks_()[0];
374
+ const blocks_in_top_row_taken = top_row_block === null || top_row_block === void 0 ? void 0 : top_row_block.span_columns;
375
+ if (blocks_in_top_row_taken == undefined) {
376
+ // Fall back to zero if no content block in top row, since then no blocks in top row are taken
377
+ set_top_row_shortened_by_(0);
378
+ return;
379
+ }
380
+ set_top_row_shortened_by_(blocks_in_top_row_taken - 1); // minus one because the content block wrapper also is an element
381
+ });
382
+
383
+ return $52FdA$solidjs.createMemo(() => $f8f375d6245ffff2$export$92aa5d691d588f3f({
384
+ wrapped_blocks_: get_wrapped_blocks_(),
385
+ n_cols_currently_showing_: n_cols_currently_showing_()
386
+ }));
387
+ }
388
+ function $f8f375d6245ffff2$export$92aa5d691d588f3f(_ref2) {
389
+ let {
390
+ wrapped_blocks_: wrapped_blocks_,
391
+ n_cols_currently_showing_: n_cols_currently_showing_
392
+ } = _ref2;
393
+ // This computation should be quite cheap since it just moves around things into an array
394
+ const content_blocks_by_index = [];
395
+ const constructed_block_arrays = new WeakSet();
396
+ // Need to keep track of products displaced by blocks above when mapping rows to indexes in the actual grid
397
+ 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
398
+ if (!n_cols_currently_showing_)
399
+ // Nope out of here if we don't know how many columns are showing
400
+ return content_blocks_by_index;
401
+ for (let i = 0; i < wrapped_blocks_.length; i++) {
402
+ // i = row to show at
403
+ const block = wrapped_blocks_[i];
404
+ if (!block) continue; // Array can have holes/not defined places
405
+ const index_of_first_item_in_row = i * n_cols_currently_showing_;
406
+ const index_of_last_item_in_row = index_of_first_item_in_row + n_cols_currently_showing_;
407
+ const {
408
+ span_rows: span_rows,
409
+ position: position,
410
+ span_columns: span_columns
411
+ } = block; // span columns is already capped in the block wrapping step (wrap_blocks_in_div)
412
+ let target_index;
413
+ 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));
414
+ // Calculate displacement of us by content blocks above us
415
+ let displacement_by_added_blocks = 0;
416
+ for (let j = 0; j < i; j++) {
417
+ const row = displaced_products[j];
418
+ if (row === undefined) continue; // there were no blocks in this row
419
+ let displaced_items_in_row;
420
+ if (typeof row === "number") displaced_items_in_row = row;else {
421
+ displaced_items_in_row = row.filter(item => item).length;
422
+ displaced_products[j] = displaced_items_in_row;
423
+ }
424
+ displacement_by_added_blocks += displaced_items_in_row;
425
+ }
426
+ const index_of_us_in_row = target_index - index_of_first_item_in_row;
427
+ for (let j = 0; j < index_of_us_in_row; j++) {
428
+ var _displaced_products$i;
429
+ if ((_displaced_products$i = displaced_products[i]) !== null && _displaced_products$i !== void 0 && _displaced_products$i[j])
430
+ // Add blocks in our *current* row to the displacement, but only the ones to our left
431
+ displacement_by_added_blocks++;
432
+ }
433
+ // Add block to output array at the correct index
434
+ const final_target_index = target_index - displacement_by_added_blocks;
435
+ const existing_block = content_blocks_by_index[final_target_index];
436
+ const block_content = block.content;
437
+ // 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
438
+ if (existing_block) {
439
+ if (constructed_block_arrays.has(existing_block))
440
+ // Only push to arrays we have created to not create funky bugs when there's an array in JSX.Element
441
+ existing_block.push(block_content);else {
442
+ const array = [existing_block, block_content];
443
+ constructed_block_arrays.add(array);
444
+ content_blocks_by_index[final_target_index] = array;
445
+ }
446
+ } else content_blocks_by_index[final_target_index] = block_content;
447
+ // Update displacement
448
+ for (let j = 0; j < span_rows; j++) {
449
+ var _ref3;
450
+ const row = displaced_products[_ref3 = i + j] || (displaced_products[_ref3] = []);
451
+ for (let k = index_of_us_in_row; k < index_of_us_in_row + span_columns; k++) row[k] = true;
452
+ }
453
+ }
454
+ return content_blocks_by_index;
455
+ }
456
+ /**
457
+ * 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.
458
+ * Then renders the content and wraps it into a div with the correct styling.
459
+ * Also caps span_columns to max available columns
460
+ */
461
+ function $f8f375d6245ffff2$var$wrap_blocks_in_div(rendered_content_blocks, max_span_columns) {
462
+ const get_wrapped_blocks = $52FdA$solidjs.mapArray(() => rendered_content_blocks, block => {
463
+ if (!block) return;
464
+ const final_span_columns = $52FdA$solidjs.createMemo(() => {
465
+ var _max_span_columns;
466
+ return Math.min(block.span_columns, (_max_span_columns = max_span_columns()) !== null && _max_span_columns !== void 0 ? _max_span_columns : Infinity);
467
+ });
468
+ // 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
469
+ const final_span_rows = $52FdA$solidjs.createMemo(() => final_span_columns() === max_span_columns() ? 1 : block.span_rows);
470
+ const [rendering_delayed, set_rendering_delayed_] = $52FdA$solidjs.createSignal(true);
471
+ const content = $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Show), {
472
+ get when() {
473
+ return !rendering_delayed();
474
+ },
475
+ get children() {
476
+ var _el$ = $52FdA$solidjsweb.getNextElement($f8f375d6245ffff2$var$_tmpl$);
477
+ $52FdA$solidjsweb.insert(_el$, $52FdA$solidjsweb.createComponent($f8f375d6245ffff2$var$RenderContent, {
478
+ get content() {
479
+ return block.content;
480
+ }
481
+ }));
482
+ $52FdA$solidjsweb.effect(_p$ => {
483
+ var _v$ = {
484
+ [(0, $830518481649feb1$export$c500183c31c2b22e)]: final_span_columns()
485
+ },
486
+ _v$2 = "span ".concat(final_span_columns()),
487
+ _v$3 = "span ".concat(final_span_rows());
488
+ _p$.e = $52FdA$solidjsweb.style(_el$, _v$, _p$.e);
489
+ _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("grid-column", _v$2) : _el$.style.removeProperty("grid-column"));
490
+ _v$3 !== _p$.a && ((_p$.a = _v$3) != null ? _el$.style.setProperty("grid-row", _v$3) : _el$.style.removeProperty("grid-row"));
491
+ return _p$;
492
+ }, {
493
+ e: undefined,
494
+ t: undefined,
495
+ a: undefined
496
+ });
497
+ return _el$;
498
+ }
499
+ });
500
+ return $52FdA$solidjs.mergeProps(block, {
501
+ // Create content divs for the blocks with as much fine-grained diffing as possible?
502
+ content: () => {
503
+ // 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
504
+ // 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
505
+ set_rendering_delayed_(false);
506
+ return content;
507
+ },
508
+ get span_columns() {
509
+ // Cap max width of block to the number of columns available, for everyone downstream
510
+ return final_span_columns();
511
+ },
512
+ get span_rows() {
513
+ return final_span_rows();
514
+ }
515
+ });
516
+ });
517
+ return get_wrapped_blocks;
518
+ }
519
+ /**
520
+ * 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.
521
+ */
522
+ function $f8f375d6245ffff2$var$RenderContent(props) {
523
+ const [resource] = $52FdA$solidjs.createResource(() => props.content,
524
+ // Could be reactive
525
+ fn => fn());
526
+ $52FdA$solidjs.createEffect(() => {
527
+ if (resource.error) console.error("Error in content block rendering", resource.error);
528
+ });
529
+ // 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)
530
+ return $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Suspense), {
531
+ get fallback() {
532
+ return $52FdA$solidjsweb.createComponent((0, $b8a8d61b3ec5f5ac$export$3f37af283f8fb843), {
533
+ width: "100%",
534
+ height: "max(100%, 400px)"
535
+ });
536
+ },
537
+ children: resource
538
+ });
539
+ }
114
540
  let $0deb6ff75e3d67c6$var$elementsHoveredSignal;
115
541
  let $0deb6ff75e3d67c6$var$consumersSignal;
116
542
  function $0deb6ff75e3d67c6$export$d4d96868197be50e() {
@@ -790,63 +1216,6 @@ function $e3915574cfd3466c$var$Placeholder(_ref2) {
790
1216
  });
791
1217
  }
792
1218
 
793
- // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
794
- class $95e4006e1dcb5b72$export$e1d52e4f0c7557a1 extends Error {}
795
- class $95e4006e1dcb5b72$export$aa14a9f43128f61f extends $95e4006e1dcb5b72$export$e1d52e4f0c7557a1 {
796
- constructor(templateError) {
797
- super("Uncaught error in product card template", {
798
- cause: templateError
799
- });
800
- }
801
- }
802
- var $1b3cf201cdd38687$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div><!$><!/><!$><!/>`);
803
- const $1b3cf201cdd38687$var$ExtraInfoContext = /*@__PURE__*/$52FdA$solidjs.createContext();
804
- function $1b3cf201cdd38687$export$240ecf5363d76c0f(props) {
805
- return $52FdA$solidjsweb.createComponent($1b3cf201cdd38687$var$ExtraInfoContext.Provider, {
806
- get value() {
807
- return props.getContext_;
808
- },
809
- get children() {
810
- return props.children;
811
- }
812
- });
813
- }
814
- function $1b3cf201cdd38687$export$b69d0d92862de18b(props) {
815
- const getContextFunction = $52FdA$solidjs.useContext($1b3cf201cdd38687$var$ExtraInfoContext);
816
- return $52FdA$solidjs.ErrorBoundary({
817
- fallback(err, retry) {
818
- const {
819
- message_: message_,
820
- severity_: severity_
821
- } = props;
822
- let message = message_;
823
- if (err instanceof (0, $95e4006e1dcb5b72$export$aa14a9f43128f61f)) {
824
- console.error(err.cause);
825
- message = "".concat(message, ": ").concat(err.message);
826
- } else $52FdA$depictaiutilishared.report([err, message_], severity_, getContextFunction === null || getContextFunction === void 0 ? void 0 : getContextFunction());
827
- return (() => {
828
- var _el$ = $52FdA$solidjsweb.getNextElement($1b3cf201cdd38687$var$_tmpl$),
829
- _el$2 = _el$.firstChild,
830
- [_el$3, _co$] = $52FdA$solidjsweb.getNextMarker(_el$2.nextSibling),
831
- _el$4 = _el$3.nextSibling,
832
- [_el$5, _co$2] = $52FdA$solidjsweb.getNextMarker(_el$4.nextSibling);
833
- $52FdA$solidjsweb.insert(_el$, message, _el$3, _co$);
834
- $52FdA$solidjsweb.insert(_el$, () => {
835
- var _props$on_error_;
836
- return (_props$on_error_ = props.on_error_) === null || _props$on_error_ === void 0 ? void 0 : _props$on_error_.call(props, retry);
837
- }, _el$5, _co$2);
838
- $52FdA$solidjsweb.effect(_$p => {
839
- var _props$class_list_;
840
- return $52FdA$solidjsweb.classList(_el$, Object.fromEntries(((_props$class_list_ = props.class_list_) === null || _props$class_list_ === void 0 ? void 0 : _props$class_list_.map(c => [c, true])) || []), _$p);
841
- });
842
- return _el$;
843
- })();
844
- },
845
- get children() {
846
- return props.children;
847
- }
848
- });
849
- }
850
1219
  var $6c2c739b113a8ddf$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div>`),
851
1220
  $6c2c739b113a8ddf$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<style type=text/css>`);
852
1221
  function $6c2c739b113a8ddf$export$d21e32dfedac04be(props) {
@@ -1122,65 +1491,6 @@ function $d067f3a30f047b41$export$e68cff63f76bd15b(props) {
1122
1491
  function $d067f3a30f047b41$export$8d0c4fdbb05a2f2e() {
1123
1492
  return $52FdA$solidjs.useContext($d067f3a30f047b41$var$ListingContext);
1124
1493
  }
1125
- var $e3d733f899558f40$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<span>`);
1126
- function $e3d733f899558f40$export$acb3eaade4b23afd(props) {
1127
- // Work around https://github.com/solidjs/solid/issues/1980
1128
- return (() => {
1129
- var _el$ = $52FdA$solidjsweb.getNextElement($e3d733f899558f40$var$_tmpl$);
1130
- $52FdA$solidjsweb.effect(_p$ => {
1131
- var _v$ = "".concat(props.class || "", " depict-placeholder"),
1132
- _v$2 = props.style;
1133
- _v$ !== _p$.e && $52FdA$solidjsweb.className(_el$, _p$.e = _v$);
1134
- _p$.t = $52FdA$solidjsweb.style(_el$, _v$2, _p$.t);
1135
- return _p$;
1136
- }, {
1137
- e: undefined,
1138
- t: undefined
1139
- });
1140
- return _el$;
1141
- })();
1142
- }
1143
- function $b8a8d61b3ec5f5ac$export$3f37af283f8fb843(props) {
1144
- const style = $52FdA$solidjs.createMemo(() => {
1145
- const {
1146
- style: style,
1147
- height: height,
1148
- width: width,
1149
- aspectRatio: aspectRatio
1150
- } = props;
1151
- const is_image = aspectRatio != undefined;
1152
- const size_data = is_image ? {
1153
- width: "100%",
1154
- "padding-bottom": "calc(calc(1 / ".concat(aspectRatio, ") * 100%)")
1155
- } : {
1156
- width: width,
1157
- height: height
1158
- };
1159
- return {
1160
- display: "block",
1161
- ...(style || {}),
1162
- ...size_data
1163
- };
1164
- });
1165
- return $52FdA$solidjsweb.createComponent((0, $e3d733f899558f40$export$acb3eaade4b23afd), {
1166
- get style() {
1167
- return style();
1168
- },
1169
- get ["class"]() {
1170
- return props.class;
1171
- }
1172
- });
1173
- }
1174
- function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
1175
- const signal = $52FdA$solidjs.createSignal(false);
1176
- $52FdA$solidjs.onCleanup($52FdA$depictaiutilishared.javascript_media_query(media_query, _ref => {
1177
- let {
1178
- matches: matches
1179
- } = _ref;
1180
- return signal[1](matches);
1181
- }).remove);
1182
- return signal[0];
1183
- }
1184
1494
  function $a7f7d416e6f61504$export$89c6019e4baa40b1(props) {
1185
1495
  const style = $52FdA$solidjs.createMemo(() => {
1186
1496
  const {
@@ -1885,7 +2195,10 @@ function $1709366c442d8933$export$ebf0b1d4f90c09ae(_ref) {
1885
2195
  var _el$ = $52FdA$solidjsweb.getNextElement($1709366c442d8933$var$_tmpl$),
1886
2196
  _el$2 = _el$.firstChild;
1887
2197
  $52FdA$solidjsweb.addEventListener(_el$2, "mouseleave", $52FdA$depictaiutilishared.catchify(() => supportsHover_() && setUserWantsExpanded(false)));
1888
- $52FdA$solidjsweb.addEventListener(_el$2, "mouseenter", $52FdA$depictaiutilishared.catchify(() => supportsHover_() && setUserWantsExpanded(true)));
2198
+ $52FdA$solidjsweb.addEventListener(_el$2, "mouseenter", $52FdA$depictaiutilishared.catchify(() => {
2199
+ var _displays_;
2200
+ return ((_displays_ = displays_()) === null || _displays_ === void 0 ? void 0 : _displays_.length) && supportsHover_() && setUserWantsExpanded(true);
2201
+ }));
1889
2202
  $52FdA$solidjsweb.use(el => {
1890
2203
  $52FdA$solidjs.createEffect(() => {
1891
2204
  if (userWantsExpanded()) return;
@@ -1938,7 +2251,7 @@ function $1709366c442d8933$export$ebf0b1d4f90c09ae(_ref) {
1938
2251
  }
1939
2252
  }));
1940
2253
  $52FdA$solidjsweb.effect(_p$ => {
1941
- var _v$ = !!(userWantsExpanded() && !!displays_()),
2254
+ var _v$ = !!userWantsExpanded(),
1942
2255
  _v$2 = !!(!getSecondPartAnimationRunning() && userWantsExpanded()),
1943
2256
  _v$3 = displays_() &&
1944
2257
  // The styling is written like this to eke out animation smoothness on low CPU devices, git blame for previous, more readable versions.
@@ -2017,6 +2330,7 @@ function $ae325261371de459$export$44809a8a3e867e30(_ref) {
2017
2330
  } else prev.delete(us);
2018
2331
  return prev;
2019
2332
  }));
2333
+ $52FdA$solidjs.createEffect(() => !display_() && setUserWantsExpanded(false));
2020
2334
  if (slidableInformation) {
2021
2335
  const ourVisiblityInSlider = $52FdA$solidjs.createMemo(() => {
2022
2336
  var _slidableInformation$, _slidableInformation$2;
@@ -2044,7 +2358,7 @@ function $ae325261371de459$export$44809a8a3e867e30(_ref) {
2044
2358
  [_el$3, _co$] = $52FdA$solidjsweb.getNextMarker(_el$2.nextSibling),
2045
2359
  _el$4 = _el$3.nextSibling,
2046
2360
  [_el$5, _co$2] = $52FdA$solidjsweb.getNextMarker(_el$4.nextSibling);
2047
- $52FdA$solidjsweb.addEventListener(_el$, "click", $52FdA$depictaiutilishared.catchify(() => setUserWantsExpanded(prev => !prev)), true);
2361
+ $52FdA$solidjsweb.addEventListener(_el$, "click", $52FdA$depictaiutilishared.catchify(() => display_() && setUserWantsExpanded(prev => !prev)), true);
2048
2362
  $52FdA$solidjsweb.use(el => {
2049
2363
  container = el;
2050
2364
  const ro = new ResizeObserver($52FdA$depictaiutilishared.catchify(records => {
@@ -11694,102 +12008,6 @@ function $0d3ee7000f047e67$export$a1fd619a4743ca08(_ref) {
11694
12008
  });
11695
12009
  return renderedDisplays_;
11696
12010
  }
11697
- var $830518481649feb1$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div>`),
11698
- $830518481649feb1$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<style type=text/css>`);
11699
- const $830518481649feb1$export$c500183c31c2b22e = "--spans-columns";
11700
- function $830518481649feb1$export$ab6b147eec64fea5(props) {
11701
- const container_class = "x" + $52FdA$solidjs.createUniqueId();
11702
- const container_element_ = (() => {
11703
- var _el$ = $52FdA$solidjsweb.getNextElement($830518481649feb1$var$_tmpl$);
11704
- $52FdA$solidjsweb.spread(_el$, $52FdA$solidjsweb.mergeProps(() => props.element_attributes, {
11705
- "classList": {
11706
- [container_class]: true
11707
- }
11708
- }), false, true);
11709
- $52FdA$solidjsweb.insert(_el$, () => props.children);
11710
- $52FdA$solidjsweb.runHydrationEvents();
11711
- return _el$;
11712
- })(); // Don't want this in the error boundary below, it should only be for the actual layouting
11713
- return $52FdA$solidjsweb.createComponent((0, $1b3cf201cdd38687$export$b69d0d92862de18b), {
11714
- message_: "Failed calculating css grid layout",
11715
- severity_: "error",
11716
- get children() {
11717
- return $830518481649feb1$export$e2f22da34aaf310a(props, container_element_, false, container_class);
11718
- }
11719
- });
11720
- }
11721
- function $830518481649feb1$export$e2f22da34aaf310a(props, container_element) {
11722
- let insert_after_container = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
11723
- let container_class = arguments.length > 3 ? arguments[3] : undefined;
11724
- if (!container_class) {
11725
- // only try to add if it wasn't provided, so that we have a code path without classList when doing SSR
11726
- container_class = $52FdA$depictaiutilishared.make_random_classname();
11727
- container_element.classList.add(container_class);
11728
- }
11729
- const container_selector = ".depict .".concat(container_class); // class so ppl can have id if needed
11730
- const col_styling = $52FdA$solidjs.createMemo(() => $830518481649feb1$var$generate_media_queried_declarations({
11731
- container_selector_: container_selector,
11732
- default_grid_spacing_text: props.grid_spacing,
11733
- cols_at_size_: props.cols_at_size,
11734
- override_vertical_spacing_: props.override_vertical_spacing,
11735
- top_row_shortened_by_: props.top_row_shortened_by_()
11736
- }));
11737
- const base_styling = $52FdA$solidjs.createMemo(() => {
11738
- return "".concat(container_selector, "{display:grid;}");
11739
- });
11740
- const get_styling = $52FdA$solidjs.createMemo(() => base_styling() + col_styling());
11741
- const style_element = (() => {
11742
- var _el$2 = $52FdA$solidjsweb.getNextElement($830518481649feb1$var$_tmpl$2);
11743
- $52FdA$solidjsweb.insert(_el$2, get_styling);
11744
- return _el$2;
11745
- })(); // need to create this after set_styling has been called or else there will be no styling in the SSR'd output
11746
- if (insert_after_container) container_element.after(style_element);
11747
- return [container_element, style_element];
11748
- }
11749
- function $830518481649feb1$var$generate_media_queried_declarations(_ref) {
11750
- let {
11751
- container_selector_: container_selector_,
11752
- default_grid_spacing_text: default_grid_spacing_text,
11753
- cols_at_size_: cols_at_size_,
11754
- override_vertical_spacing_: override_vertical_spacing_,
11755
- top_row_shortened_by_: top_row_shortened_by_
11756
- } = _ref;
11757
- return cols_at_size_.map(options => {
11758
- const [n_cols, min, max, grid_spacing_for_size] = options;
11759
- const main_spacing_to_use = grid_spacing_for_size || default_grid_spacing_text;
11760
- // See comment in else block below
11761
- const can_use_gap = override_vertical_spacing_ ? $830518481649feb1$var$can_use_gap_for_unit(override_vertical_spacing_) : $830518481649feb1$var$can_use_gap_for_unit(main_spacing_to_use);
11762
- let spacing_styling;
11763
- let additional_styling = ""; // outside the media query
11764
- if (can_use_gap) spacing_styling = "gap:".concat(main_spacing_to_use, ";").concat(override_vertical_spacing_ ? "row-gap:".concat(override_vertical_spacing_, ";") : "");else {
11765
- // 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)
11766
- // 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.
11767
- // Logical thought: use margins for the vertical spacing. But margins in grids are apparently relative to the size of the individual items in grids.
11768
- // 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.
11769
- const vertical_spacing_to_use = override_vertical_spacing_ !== null && override_vertical_spacing_ !== void 0 ? override_vertical_spacing_ : main_spacing_to_use;
11770
- const width_multiplier = "var(".concat($830518481649feb1$export$c500183c31c2b22e, ", 1)"); // How many cards wide the current item is (needed because content blocks)
11771
- const one_item_width_exclusing_gaps = "calc(calc(100 / ".concat(n_cols, ") - calc(calc(").concat(n_cols * 2 - 2, " * calc(").concat($830518481649feb1$var$strip_percent_unit(vertical_spacing_to_use), " / 2)) / ").concat(n_cols, "))"); // Width of one item in percent of the whole
11772
- // Equation from layout.tsx, also used in CheckboxGrid. Needs half spacing for some reason
11773
- const this_item_width_meat = "calc(".concat(one_item_width_exclusing_gaps, " * ").concat(width_multiplier, ")"); // Width of just the card
11774
- const this_item_width_gaps = "calc(calc(".concat(width_multiplier, " - 1) * ").concat($830518481649feb1$var$strip_percent_unit(vertical_spacing_to_use), ")"); // Width of the gaps
11775
- const this_item_width = "calc(".concat(this_item_width_meat, " + ").concat(this_item_width_gaps, ")"); // Width of this item including gaps
11776
- // 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
11777
- const convert_top_spacing_to_item_width_percentage = spacing => "calc(calc(100 / ".concat(this_item_width, ") * ").concat(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)
11778
- spacing_styling = "column-gap:".concat(main_spacing_to_use, ";"); // Still use gaps in the horizontal direction because that works flawlessly
11779
- // Re-use old layout code to get the correct :nth-child declarations for the top margins
11780
- additional_styling = $52FdA$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_);
11781
- }
11782
- const media_query_body = "".concat(container_selector_, "{").concat(spacing_styling, "grid-template-columns:repeat(").concat(n_cols, ",minmax(0,1fr));}");
11783
- return "".concat($52FdA$depictaiutilishared.layout_media_query_header(min, max), "{").concat(media_query_body, "}").concat(additional_styling);
11784
- }).join("");
11785
- }
11786
- function $830518481649feb1$var$can_use_gap_for_unit(spacing) {
11787
- const trimmed_spacing = spacing.trim();
11788
- return !trimmed_spacing.includes("%");
11789
- }
11790
- function $830518481649feb1$var$strip_percent_unit(css_value) {
11791
- return css_value.replaceAll("%", "");
11792
- }
11793
12011
  function $c749e60bca5000cb$export$cb5808ba002cdeed(_ref) {
11794
12012
  let {
11795
12013
  layout_options_: layout_options_,
@@ -11816,226 +12034,6 @@ function $c749e60bca5000cb$export$cb5808ba002cdeed(_ref) {
11816
12034
  }) : when_filters_closed_cols;
11817
12035
  });
11818
12036
  }
11819
- function $478e5a09664da64c$export$a79e666719b3647c(cols_at_size_) {
11820
- const size_active = $52FdA$solidjs.createMemo(() => cols_at_size_().map(_ref => {
11821
- let [n_cols, min_width, max_width] = _ref;
11822
- const media_query = $52FdA$depictaiutilishared.layout_media_query_header(min_width, max_width).replaceAll("@media", "");
11823
- const matches = $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query);
11824
- return [matches, n_cols];
11825
- }));
11826
- const n_cols_currently_showing = $52FdA$solidjs.createMemo(() => {
11827
- try {
11828
- const [, n_cols_currently_showing] = size_active().find(_ref2 => {
11829
- let [media_query] = _ref2;
11830
- return media_query();
11831
- });
11832
- return n_cols_currently_showing;
11833
- } catch (e) {
11834
- $52FdA$depictaiutilishared.dwarn("No active size found in columnsAtSize - can't render content blocks or looks");
11835
- return null;
11836
- }
11837
- });
11838
- return n_cols_currently_showing;
11839
- }
11840
- var $f8f375d6245ffff2$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class=content-block-wrapper>`);
11841
- function $f8f375d6245ffff2$export$791ef57e62e21c3f(_ref) {
11842
- let {
11843
- content_blocks_: incoming_content_blocks,
11844
- cols_at_size_: cols_at_size_,
11845
- set_top_row_shortened_by_: set_top_row_shortened_by_
11846
- } = _ref;
11847
- // these are by row
11848
- const [content_blocks, set_content_blocks] = $52FdA$solidjsstore.createStore([]);
11849
- const n_cols_currently_showing_ = $478e5a09664da64c$export$a79e666719b3647c(cols_at_size_);
11850
- $52FdA$solidjs.createEffect(() => {
11851
- const incoming_value = incoming_content_blocks();
11852
- if (!incoming_value) {
11853
- set_content_blocks([]);
11854
- return;
11855
- }
11856
- set_content_blocks($52FdA$solidjsstore.reconcile(incoming_value, {
11857
- key: "content"
11858
- })); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
11859
- });
11860
-
11861
- const get_wrapped_blocks_ = $f8f375d6245ffff2$var$wrap_blocks_in_div(content_blocks, n_cols_currently_showing_);
11862
- $52FdA$solidjs.createComputed(() => {
11863
- // 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
11864
- const top_row_block = get_wrapped_blocks_()[0];
11865
- const blocks_in_top_row_taken = top_row_block === null || top_row_block === void 0 ? void 0 : top_row_block.span_columns;
11866
- if (blocks_in_top_row_taken == undefined) {
11867
- // Fall back to zero if no content block in top row, since then no blocks in top row are taken
11868
- set_top_row_shortened_by_(0);
11869
- return;
11870
- }
11871
- set_top_row_shortened_by_(blocks_in_top_row_taken - 1); // minus one because the content block wrapper also is an element
11872
- });
11873
-
11874
- return $f8f375d6245ffff2$var$remap_blocks_to_index({
11875
- get_wrapped_blocks_: get_wrapped_blocks_,
11876
- n_cols_currently_showing_: n_cols_currently_showing_
11877
- });
11878
- }
11879
- /**
11880
- * Calculate where to put each of the finished wrapped content blocks. Also limit blocks' max width.
11881
- * @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
11882
- */
11883
- function $f8f375d6245ffff2$var$remap_blocks_to_index(_ref2) {
11884
- let {
11885
- get_wrapped_blocks_: get_wrapped_blocks_,
11886
- n_cols_currently_showing_: n_cols_currently_showing_
11887
- } = _ref2;
11888
- return $52FdA$solidjs.createMemo(() => {
11889
- // This computation should be quite cheap since it just moves around things into an array
11890
- const content_blocks_by_index = [];
11891
- const constructed_block_arrays = new WeakSet();
11892
- const wrapped_blocks = get_wrapped_blocks_();
11893
- const cols_showing = n_cols_currently_showing_();
11894
- // Need to keep track of products displaced by blocks above when mapping rows to indexes in the actual grid
11895
- 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
11896
- if (!cols_showing)
11897
- // Nope out of here if we don't know how many columns are showing
11898
- return content_blocks_by_index;
11899
- for (let i = 0; i < wrapped_blocks.length; i++) {
11900
- // i = row to show at
11901
- const block = wrapped_blocks[i];
11902
- if (!block) continue; // Array can have holes/not defined places
11903
- const index_of_first_item_in_row = i * cols_showing;
11904
- const index_of_last_item_in_row = index_of_first_item_in_row + cols_showing;
11905
- const {
11906
- span_rows: span_rows,
11907
- position: position,
11908
- span_columns: span_columns
11909
- } = block; // span columns is already capped in the block wrapping step (wrap_blocks_in_div)
11910
- let target_index;
11911
- 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));
11912
- // Calculate displacement of us by content blocks above us
11913
- let displacement_by_added_blocks = 0;
11914
- for (let j = 0; j < i; j++) {
11915
- const row = displaced_products[j];
11916
- if (row === undefined) continue; // there were no blocks in this row
11917
- let displaced_items_in_row;
11918
- if (typeof row === "number") displaced_items_in_row = row;else {
11919
- displaced_items_in_row = row.filter(item => item).length;
11920
- displaced_products[j] = displaced_items_in_row;
11921
- }
11922
- displacement_by_added_blocks += displaced_items_in_row;
11923
- }
11924
- const index_of_us_in_row = target_index - index_of_first_item_in_row;
11925
- for (let j = 0; j < index_of_us_in_row; j++) {
11926
- var _displaced_products$i;
11927
- if ((_displaced_products$i = displaced_products[i]) !== null && _displaced_products$i !== void 0 && _displaced_products$i[j])
11928
- // Add blocks in our *current* row to the displacement, but only the ones to our left
11929
- displacement_by_added_blocks++;
11930
- }
11931
- // Add block to output array at the correct index
11932
- const final_target_index = target_index - displacement_by_added_blocks;
11933
- const existing_block = content_blocks_by_index[final_target_index];
11934
- const block_content = block.content;
11935
- // 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
11936
- if (existing_block) {
11937
- if (constructed_block_arrays.has(existing_block))
11938
- // Only push to arrays we have created to not create funky bugs when there's an array in JSX.Element
11939
- existing_block.push(block_content);else {
11940
- const array = [existing_block, block_content];
11941
- constructed_block_arrays.add(array);
11942
- content_blocks_by_index[final_target_index] = array;
11943
- }
11944
- } else content_blocks_by_index[final_target_index] = block_content;
11945
- // Update displacement
11946
- for (let j = 0; j < span_rows; j++) {
11947
- var _ref3;
11948
- const row = displaced_products[_ref3 = i + j] || (displaced_products[_ref3] = []);
11949
- for (let k = index_of_us_in_row; k < index_of_us_in_row + span_columns; k++) row[k] = true;
11950
- }
11951
- }
11952
- return content_blocks_by_index;
11953
- });
11954
- }
11955
- /**
11956
- * 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.
11957
- * Then renders the content and wraps it into a div with the correct styling.
11958
- * Also caps span_columns to max available columns
11959
- */
11960
- function $f8f375d6245ffff2$var$wrap_blocks_in_div(rendered_content_blocks, max_span_columns) {
11961
- const get_wrapped_blocks = $52FdA$solidjs.mapArray(() => rendered_content_blocks, block => {
11962
- if (!block) return;
11963
- const final_span_columns = $52FdA$solidjs.createMemo(() => {
11964
- var _max_span_columns;
11965
- return Math.min(block.span_columns, (_max_span_columns = max_span_columns()) !== null && _max_span_columns !== void 0 ? _max_span_columns : Infinity);
11966
- });
11967
- // 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
11968
- const final_span_rows = $52FdA$solidjs.createMemo(() => final_span_columns() === max_span_columns() ? 1 : block.span_rows);
11969
- const [rendering_delayed, set_rendering_delayed_] = $52FdA$solidjs.createSignal(true);
11970
- const content = $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Show), {
11971
- get when() {
11972
- return !rendering_delayed();
11973
- },
11974
- get children() {
11975
- var _el$ = $52FdA$solidjsweb.getNextElement($f8f375d6245ffff2$var$_tmpl$);
11976
- $52FdA$solidjsweb.insert(_el$, $52FdA$solidjsweb.createComponent($f8f375d6245ffff2$var$RenderContent, {
11977
- get content() {
11978
- return block.content;
11979
- }
11980
- }));
11981
- $52FdA$solidjsweb.effect(_p$ => {
11982
- var _v$ = {
11983
- [(0, $830518481649feb1$export$c500183c31c2b22e)]: final_span_columns()
11984
- },
11985
- _v$2 = "span ".concat(final_span_columns()),
11986
- _v$3 = "span ".concat(final_span_rows());
11987
- _p$.e = $52FdA$solidjsweb.style(_el$, _v$, _p$.e);
11988
- _v$2 !== _p$.t && ((_p$.t = _v$2) != null ? _el$.style.setProperty("grid-column", _v$2) : _el$.style.removeProperty("grid-column"));
11989
- _v$3 !== _p$.a && ((_p$.a = _v$3) != null ? _el$.style.setProperty("grid-row", _v$3) : _el$.style.removeProperty("grid-row"));
11990
- return _p$;
11991
- }, {
11992
- e: undefined,
11993
- t: undefined,
11994
- a: undefined
11995
- });
11996
- return _el$;
11997
- }
11998
- });
11999
- return $52FdA$solidjs.mergeProps(block, {
12000
- // Create content divs for the blocks with as much fine-grained diffing as possible?
12001
- content: () => {
12002
- // 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
12003
- // 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
12004
- set_rendering_delayed_(false);
12005
- return content;
12006
- },
12007
- get span_columns() {
12008
- // Cap max width of block to the number of columns available, for everyone downstream
12009
- return final_span_columns();
12010
- },
12011
- get span_rows() {
12012
- return final_span_rows();
12013
- }
12014
- });
12015
- });
12016
- return get_wrapped_blocks;
12017
- }
12018
- /**
12019
- * 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.
12020
- */
12021
- function $f8f375d6245ffff2$var$RenderContent(props) {
12022
- const [resource] = $52FdA$solidjs.createResource(() => props.content,
12023
- // Could be reactive
12024
- fn => fn());
12025
- $52FdA$solidjs.createEffect(() => {
12026
- if (resource.error) console.error("Error in content block rendering", resource.error);
12027
- });
12028
- // 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)
12029
- return $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Suspense), {
12030
- get fallback() {
12031
- return $52FdA$solidjsweb.createComponent((0, $b8a8d61b3ec5f5ac$export$3f37af283f8fb843), {
12032
- width: "100%",
12033
- height: "max(100%, 400px)"
12034
- });
12035
- },
12036
- children: resource
12037
- });
12038
- }
12039
12037
  var $484eec37514a982e$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class=PLP-results><!$><!/><!$><!/>`);
12040
12038
  function $484eec37514a982e$export$3925f87b1545cfc6(_ref) {
12041
12039
  let {