@depict-ai/ui 2.0.8 → 2.0.10

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
@@ -61,7 +61,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
61
61
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
62
62
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
63
63
  /*! Depict.ai search and product listing SDK */
64
- const $b757f75811f3261f$export$83d89fbfd8236492 = "2.0.8";
64
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "2.0.10";
65
65
 
66
66
  /** @jsxImportSource solid-js */
67
67
 
@@ -238,6 +238,7 @@ function $a73063cc642f3e5f$export$7f8bd308237ab5a5(get_displays_) {
238
238
  });
239
239
  return displays_by_key_;
240
240
  }
241
+ const $a73063cc642f3e5f$var$result_ids = ["search_result_id", "product_listing_result_id", "recommendation_id"];
241
242
  function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
242
243
  displays_by_key_: displays_by_key_,
243
244
  merchant_: merchant_,
@@ -251,17 +252,24 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
251
252
  },
252
253
  children: (product_id, index) => {
253
254
  const owner = $gVhhF$solidjs.getOwner();
254
- const display_accessor = $gVhhF$solidjs.createMemo(() => displays_by_key_().get(product_id));
255
- const [product_card_resource] = $gVhhF$solidjs.createResource(display_accessor,
256
- // re-render when the reference to the display object changes
257
- // this should only be the case when the merchant or market changes and the new request has completed
258
- display => {
255
+ const display_accessor = $gVhhF$solidjs.createMemo(prev => {
256
+ const new_display = displays_by_key_().get(product_id);
257
+ if (prev && $a73063cc642f3e5f$var$deep_equal(prev, new_display))
258
+ // If displays are identical, they haven't changed due to merchant/market changing OR we made a new query and the displays are the same. Return the old display (same object reference) to avoid re-rendering.
259
+ // This doesn't work if people mutate the displays from within the template but we hope they don't
260
+ // (We can't know if the display changing is due to merchant/market changing or a new query otherwise and don't want to run into https://gitlab.com/depict-ai/depict.ai/-/merge_requests/6890/diffs)
261
+ return prev;
262
+ return new_display;
263
+ });
264
+ const [product_card_resource] = $gVhhF$solidjs.createResource(() => [merchant_(), market_(), display_accessor()],
265
+ // re-render when the reference to the display object changes or the merchant or market changes
266
+ // (We don't want to re-render if nothing has changed)
267
+ ([merchant, market, display]) => {
259
268
  // get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
260
269
  return product_card_template_(display, {
261
270
  set_on_index_change: fn => $gVhhF$solidjs.runWithOwner(owner, () => $gVhhF$solidjs.createEffect(() => fn(index()))),
262
- merchant: $gVhhF$solidjs.untrack(merchant_),
263
- // this means that the merchant and market provided to the template is wrong while we do another fetch, but I don't see how anyone would need to know the correct market there
264
- market: $gVhhF$solidjs.untrack(market_) // recommendation_grid can provide a sneaky undefined here just FYI
271
+ merchant: merchant,
272
+ market: market // recommendation_grid can provide a sneaky undefined here just FYI
265
273
  });
266
274
  });
267
275
 
@@ -276,15 +284,13 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
276
284
  elements.push(element);
277
285
  // Add tracking ids
278
286
  if (!(element instanceof HTMLElement)) continue; // Apparently only HTMLElements have dataset
279
- const {
280
- dataset: dataset
281
- } = element;
282
- const {
283
- search_result_id: search_result_id,
284
- product_listing_result_id: product_listing_result_id,
285
- recommendation_id: recommendation_id
286
- } = display;
287
- if (search_result_id) dataset.searchResultId = search_result_id;else if (product_listing_result_id) dataset.productListingResultId = product_listing_result_id;else if (recommendation_id) dataset.recommendationId = recommendation_id;
287
+ for (let i = 0; i < $a73063cc642f3e5f$var$result_ids.length; i++) {
288
+ const id = $a73063cc642f3e5f$var$result_ids[i];
289
+ const value = display[id];
290
+ if (value) Object.assign(element.dataset, $gVhhF$depictaiutilishared.camelCasifyObject({
291
+ [id]: value
292
+ }));
293
+ }
288
294
  }
289
295
  do_per_elements_?.(elements, index);
290
296
  });
@@ -292,6 +298,23 @@ function $a73063cc642f3e5f$export$43f0fb951fcb0c54({
292
298
  }
293
299
  });
294
300
  }
301
+ // Source: https://dmitripavlutin.com/how-to-compare-objects-in-javascript/
302
+ function $a73063cc642f3e5f$var$deep_equal(object1, object2) {
303
+ const keys1 = Object.keys(object1);
304
+ const keys2 = Object.keys(object2);
305
+ if (keys1.length !== keys2.length) return false;
306
+ for (const key of keys1) {
307
+ if ($a73063cc642f3e5f$var$result_ids.includes(key)) continue; // ignore result ids that change per response
308
+ const val1 = object1[key];
309
+ const val2 = object2[key];
310
+ const areObjects = $a73063cc642f3e5f$var$is_object(val1) && $a73063cc642f3e5f$var$is_object(val2);
311
+ if (areObjects && !$a73063cc642f3e5f$var$deep_equal(val1, val2) || !areObjects && val1 !== val2) return false;
312
+ }
313
+ return true;
314
+ }
315
+ function $a73063cc642f3e5f$var$is_object(object) {
316
+ return object != null && typeof object === "object";
317
+ }
295
318
 
296
319
  // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
297
320
  class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
@@ -654,51 +677,52 @@ function $b8e79813f4f7ebe4$export$7da560f849543dff({
654
677
  }) {
655
678
  const is_showing_something = $gVhhF$solidjs.createMemo(() => recommendations_resource_.loading || recommendations_resource_()?.length);
656
679
  const num_placeholders_ = () => 20;
680
+ const elements = (() => {
681
+ const _el$ = $gVhhF$solidjsweb.getNextElement($b8e79813f4f7ebe4$var$_tmpl$),
682
+ _el$2 = _el$.firstChild,
683
+ [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
684
+ _el$4 = _el$3.nextSibling,
685
+ [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
686
+ $gVhhF$solidjsweb.insert(_el$, (0, $fc23d7668ae0011d$export$a2cc176055f8f08), _el$3, _co$);
687
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), $gVhhF$solidjsweb.mergeProps({
688
+ get rows() {
689
+ return rows_object_();
690
+ },
691
+ layout: "grid",
692
+ element_attributes: {
693
+ class: "cards"
694
+ }
695
+ }, layout_options_, {
696
+ get children() {
697
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
698
+ get fallback() {
699
+ return $0caf87eaa19079da$export$f33414a4df0afd3f({
700
+ num_placeholders_: num_placeholders_,
701
+ product_card_template_: product_card_template_
702
+ });
703
+ },
704
+ get children() {
705
+ return (() => {
706
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
707
+ const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
708
+ return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
709
+ displays_by_key_: displays_by_key_,
710
+ merchant_: merchant_,
711
+ market_: market_,
712
+ product_card_template_: product_card_template_
713
+ });
714
+ })();
715
+ }
716
+ });
717
+ }
718
+ })), _el$5, _co$2);
719
+ return _el$;
720
+ })();
657
721
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
658
722
  get when() {
659
723
  return is_showing_something();
660
724
  },
661
- get children() {
662
- const _el$ = $gVhhF$solidjsweb.getNextElement($b8e79813f4f7ebe4$var$_tmpl$),
663
- _el$2 = _el$.firstChild,
664
- [_el$3, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$2.nextSibling),
665
- _el$4 = _el$3.nextSibling,
666
- [_el$5, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$4.nextSibling);
667
- $gVhhF$solidjsweb.insert(_el$, (0, $fc23d7668ae0011d$export$a2cc176055f8f08), _el$3, _co$);
668
- $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), $gVhhF$solidjsweb.mergeProps({
669
- get rows() {
670
- return rows_object_();
671
- },
672
- layout: "grid",
673
- element_attributes: {
674
- class: "cards"
675
- }
676
- }, layout_options_, {
677
- get children() {
678
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
679
- get fallback() {
680
- return $0caf87eaa19079da$export$f33414a4df0afd3f({
681
- num_placeholders_: num_placeholders_,
682
- product_card_template_: product_card_template_
683
- });
684
- },
685
- get children() {
686
- return (() => {
687
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
688
- const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
689
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
690
- displays_by_key_: displays_by_key_,
691
- merchant_: merchant_,
692
- market_: market_,
693
- product_card_template_: product_card_template_
694
- });
695
- })();
696
- }
697
- });
698
- }
699
- })), _el$5, _co$2);
700
- return _el$;
701
- }
725
+ children: elements
702
726
  });
703
727
  }
704
728
  const $1f8dbf7e28b3eff2$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="show-more major" type="button"></button>`, 2),
@@ -3466,8 +3490,8 @@ function $70482f04605572e2$var$modify_only_local_filter(local_filter_object, sel
3466
3490
  }
3467
3491
  return modified_filter_object;
3468
3492
  }
3469
- async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_opts) {
3470
- const body = await (0, $gVhhF$depictaiutilishared.observer).wait_for_element("body");
3493
+ async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_opts, parent) {
3494
+ const body = parent || (await (0, $gVhhF$depictaiutilishared.observer).wait_for_element("body"));
3471
3495
  let dispose_and_remove;
3472
3496
  const open_modal_ = (extra_options_for_modal = {}, on_dispose) => {
3473
3497
  if (dispose_and_remove)
@@ -4304,7 +4328,7 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
4304
4328
  const [get_extra_displays, set_extra_displays_] = $gVhhF$solidjs.createSignal([], {
4305
4329
  equals: false
4306
4330
  });
4307
- const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => [...plp_results_().displays, ...get_extra_displays()]));
4331
+ const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => [...(plp_results_()?.displays || []), ...get_extra_displays()]));
4308
4332
  const percentage_in_view_ = $4117463e2939f5f4$export$63dd0350f8559dda({
4309
4333
  get_last_result_in_viewport_: get_last_result_in_viewport_,
4310
4334
  displays_by_key_: displays_by_key_,
@@ -4423,18 +4447,18 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
4423
4447
  layout_options_: layout_options_,
4424
4448
  sort_or_filter_open_: sort_or_filter_open_
4425
4449
  });
4426
- $gVhhF$solidjs.createComputed(() => {
4427
- if (!is_loading_()) return;
4428
- set_should_have_placeholders_rendered(true);
4429
- set_suspense_is_blocked(false);
4430
- is_just_after_plp_results_update = true;
4431
- });
4432
4450
  const block_suspense_if_needed = () => {
4433
4451
  if (!is_just_after_plp_results_update) return;
4434
4452
  is_just_after_plp_results_update = false;
4435
4453
  fallback_is_alive = false;
4436
4454
  set_suspense_is_blocked(true);
4437
4455
  };
4456
+ $gVhhF$solidjs.createComputed(() => {
4457
+ if (!is_loading_()) return;
4458
+ set_should_have_placeholders_rendered(true);
4459
+ set_suspense_is_blocked(false);
4460
+ is_just_after_plp_results_update = true;
4461
+ });
4438
4462
  $gVhhF$solidjs.createEffect($gVhhF$solidjs.on(plp_results_, () => {
4439
4463
  if (!fallback_is_alive) {
4440
4464
  // if all product card rendering functions after the initial rendering are synchronous the suspense boundary will never go into the fallback, so we don't know when they have finished rendering, and we can't block the suspense. Therefore, we're just doing it with this effect
@@ -4444,6 +4468,48 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
4444
4468
  }, {
4445
4469
  defer: true
4446
4470
  }));
4471
+ /*
4472
+ This suspense ensures that if someone has async templates, we still show placeholders until the product cards actually have finished rendering (automagically since they're createResource's)
4473
+ We're creating it outside the <Show> so that we can benefit from <For>'s optimisation between changing results
4474
+ (For the whole idea of the displays being cached to work we can't tear down and re-run ProductCards for every new result.
4475
+ We have to keep ProductCards alive, but hidden, and feed them new data as soon as we had it)
4476
+ */
4477
+ const product_cards_when_data = $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
4478
+ get fallback() {
4479
+ return (() => {
4480
+ fallback_is_alive = true;
4481
+ $gVhhF$solidjs.onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
4482
+ return $gVhhF$solidjs.createMemo(() => {
4483
+ // We need to be able to block the suspense since when async product cards are *rendering* we want to show the placeholders on initial load but not when loading more
4484
+ // In future we could have individual suspense's for each product card, but that's too much for now
4485
+ if (get_suspense_is_blocked()) return suspense_contents;
4486
+ set_should_have_placeholders_rendered(true); // just in case
4487
+ $gVhhF$solidjs.onCleanup(() => set_should_have_placeholders_rendered(false));
4488
+ return rendered_placeholders; // I lifted the placeholders into the memo since we don't want to re-render them when switching from <Show> to <Suspense>
4489
+ });
4490
+ })();
4491
+ },
4492
+
4493
+ get children() {
4494
+ return (() => {
4495
+ suspense_contents = $ac167f6af6a48fc3$export$a1fd619a4743ca08({
4496
+ product_card_template_: product_card_template_,
4497
+ plp_results_: plp_results_,
4498
+ last_result_in_viewport_: last_result_in_viewport_,
4499
+ first_result_in_viewport_: first_result_in_viewport_,
4500
+ market_: market_,
4501
+ merchant_: merchant_,
4502
+ all_products_loaded_: all_products_loaded_,
4503
+ min_products_to_fetch_: min_products_to_fetch_,
4504
+ query_base_: query_base_,
4505
+ depict_api_: depict_api_,
4506
+ is_loading_: is_loading_
4507
+ });
4508
+ $gVhhF$solidjs.onCleanup(() => suspense_contents = undefined);
4509
+ return suspense_contents;
4510
+ })();
4511
+ }
4512
+ });
4447
4513
  return [$gVhhF$solidjsweb.memo((0, $fc23d7668ae0011d$export$a2cc176055f8f08)), $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
4448
4514
  get cols_at_size() {
4449
4515
  return modified_cols_at_size();
@@ -4467,44 +4533,7 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
4467
4533
  get fallback() {
4468
4534
  return rendered_placeholders();
4469
4535
  },
4470
- get children() {
4471
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
4472
- get fallback() {
4473
- return (() => {
4474
- fallback_is_alive = true;
4475
- $gVhhF$solidjs.onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
4476
- return $gVhhF$solidjs.createMemo(() => {
4477
- // We need to be able to block the suspense since when async product cards are *rendering* we want to show the placeholders on initial load but not when loading more
4478
- // In future we could have individual suspense's for each product card, but that's too much for now
4479
- if (get_suspense_is_blocked()) return suspense_contents;
4480
- set_should_have_placeholders_rendered(true); // just in case
4481
- $gVhhF$solidjs.onCleanup(() => set_should_have_placeholders_rendered(false));
4482
- return rendered_placeholders; // I lifted the placeholders into the memo since we don't want to re-render them when switching from <Show> to <Suspense>
4483
- });
4484
- })();
4485
- },
4486
-
4487
- get children() {
4488
- return (() => {
4489
- suspense_contents = $ac167f6af6a48fc3$export$a1fd619a4743ca08({
4490
- product_card_template_: product_card_template_,
4491
- plp_results_: plp_results_,
4492
- last_result_in_viewport_: last_result_in_viewport_,
4493
- first_result_in_viewport_: first_result_in_viewport_,
4494
- market_: market_,
4495
- merchant_: merchant_,
4496
- all_products_loaded_: all_products_loaded_,
4497
- min_products_to_fetch_: min_products_to_fetch_,
4498
- query_base_: query_base_,
4499
- depict_api_: depict_api_,
4500
- is_loading_: is_loading_
4501
- });
4502
- $gVhhF$solidjs.onCleanup(() => suspense_contents = undefined);
4503
- return suspense_contents;
4504
- })();
4505
- }
4506
- });
4507
- }
4536
+ children: product_cards_when_data
4508
4537
  });
4509
4538
  }
4510
4539
  })];
@@ -7513,58 +7542,61 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({
7513
7542
  product_card_template_: product_card_template_,
7514
7543
  showing_recommendation_rows_: showing_recommendation_rows_,
7515
7544
  view_more_button_ = true,
7516
- layout_options_: layout_options_
7545
+ layout_options_: layout_options_,
7546
+ all_products_loaded_: all_products_loaded_
7517
7547
  }) {
7518
7548
  const [get_showing_recommendation_rows] = showing_recommendation_rows_; // We reset this in after_submit in search.tsx FYI
7519
7549
  const rows_object = view_more_button_ ? $fb29c6201c369e39$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
7520
7550
  const [recommendations_resource] = $gVhhF$solidjs.createResource(search_query_base_, query => depict_api_.get_recommended(query).then(r => r.displays));
7521
7551
  const is_showing_something = $gVhhF$solidjs.createMemo(() => recommendations_resource.loading || recommendations_resource()?.length);
7522
7552
  const num_placeholders_ = $gVhhF$solidjs.createMemo(() => (0, $aec24316ed262dc0$export$6c9030e511152266) + get_showing_recommendation_rows() * Math.max(...layout_options_().cols_at_size.map(([per_column]) => per_column)));
7553
+ // Don't tear down elements every time one updates the page - don't put them within <Show>
7554
+ const elements = (() => {
7555
+ const _el$ = $gVhhF$solidjsweb.getNextElement($fb29c6201c369e39$var$_tmpl$),
7556
+ _el$2 = _el$.firstChild,
7557
+ _el$3 = _el$2.nextSibling,
7558
+ [_el$4, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$3.nextSibling),
7559
+ _el$5 = _el$4.nextSibling,
7560
+ [_el$6, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
7561
+ $gVhhF$solidjsweb.insert(_el$2, () => i18n_.search_recs_title_());
7562
+ $gVhhF$solidjsweb.insert(_el$, (0, $fc23d7668ae0011d$export$a2cc176055f8f08), _el$4, _co$);
7563
+ $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), $gVhhF$solidjsweb.mergeProps({
7564
+ rows: rows_object,
7565
+ layout: "grid",
7566
+ element_attributes: {
7567
+ class: "cards"
7568
+ }
7569
+ }, layout_options_, {
7570
+ get children() {
7571
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
7572
+ get fallback() {
7573
+ return $0caf87eaa19079da$export$f33414a4df0afd3f({
7574
+ num_placeholders_: num_placeholders_,
7575
+ product_card_template_: product_card_template_
7576
+ });
7577
+ },
7578
+ get children() {
7579
+ return (() => {
7580
+ // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
7581
+ const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource() || []));
7582
+ return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
7583
+ displays_by_key_: displays_by_key_,
7584
+ merchant_: $gVhhF$solidjs.createMemo(() => search_query_base_().tenant),
7585
+ market_: $gVhhF$solidjs.createMemo(() => search_query_base_().market),
7586
+ product_card_template_: product_card_template_
7587
+ });
7588
+ })();
7589
+ }
7590
+ });
7591
+ }
7592
+ })), _el$6, _co$2);
7593
+ return _el$;
7594
+ })();
7523
7595
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7524
7596
  get when() {
7525
- return is_showing_something();
7597
+ return $gVhhF$solidjsweb.memo(() => !!is_showing_something())() && all_products_loaded_();
7526
7598
  },
7527
- get children() {
7528
- const _el$ = $gVhhF$solidjsweb.getNextElement($fb29c6201c369e39$var$_tmpl$),
7529
- _el$2 = _el$.firstChild,
7530
- _el$3 = _el$2.nextSibling,
7531
- [_el$4, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$3.nextSibling),
7532
- _el$5 = _el$4.nextSibling,
7533
- [_el$6, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
7534
- $gVhhF$solidjsweb.insert(_el$2, () => i18n_.search_recs_title_());
7535
- $gVhhF$solidjsweb.insert(_el$, (0, $fc23d7668ae0011d$export$a2cc176055f8f08), _el$4, _co$);
7536
- $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), $gVhhF$solidjsweb.mergeProps({
7537
- rows: rows_object,
7538
- layout: "grid",
7539
- element_attributes: {
7540
- class: "cards"
7541
- }
7542
- }, layout_options_, {
7543
- get children() {
7544
- return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Suspense), {
7545
- get fallback() {
7546
- return $0caf87eaa19079da$export$f33414a4df0afd3f({
7547
- num_placeholders_: num_placeholders_,
7548
- product_card_template_: product_card_template_
7549
- });
7550
- },
7551
- get children() {
7552
- return (() => {
7553
- // IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
7554
- const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource() || []));
7555
- return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
7556
- displays_by_key_: displays_by_key_,
7557
- merchant_: $gVhhF$solidjs.createMemo(() => search_query_base_().tenant),
7558
- market_: $gVhhF$solidjs.createMemo(() => search_query_base_().market),
7559
- product_card_template_: product_card_template_
7560
- });
7561
- })();
7562
- }
7563
- });
7564
- }
7565
- })), _el$6, _co$2);
7566
- return _el$;
7567
- }
7599
+ children: elements
7568
7600
  });
7569
7601
  }
7570
7602
  function $fb29c6201c369e39$var$make_state_saved_rows([get_showing_recommendation_rows, set_showing_recommendation_rows], i18n_) {
@@ -9999,9 +10031,7 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
9999
10031
  }
10000
10032
  }), _el$19, _co$8);
10001
10033
  $gVhhF$solidjsweb.insert(_el$7, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
10002
- get when() {
10003
- return get_all_products_loaded() && !disable_search_recommendations_;
10004
- },
10034
+ when: !disable_search_recommendations_,
10005
10035
  keyed: false,
10006
10036
  get children() {
10007
10037
  return $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
@@ -10017,7 +10047,8 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
10017
10047
  },
10018
10048
  showing_recommendation_rows_: showing_recommendation_rows_,
10019
10049
  view_more_button_: search_recs_view_more_,
10020
- product_card_template_: product_card_template_
10050
+ product_card_template_: product_card_template_,
10051
+ all_products_loaded_: get_all_products_loaded
10021
10052
  });
10022
10053
  }
10023
10054
  });
@@ -10127,6 +10158,7 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
10127
10158
  disable_scrolling_during_modal = true,
10128
10159
  bottom_distance_under_modal: bottom_distance_under_modal,
10129
10160
  render_instant_card: render_instant_card,
10161
+ override_modal_element: override_modal_element,
10130
10162
  ...props_on_class
10131
10163
  }) {
10132
10164
  const owner = $gVhhF$solidjs.getOwner() || $gVhhF$solidjs.createRoot(() => $gVhhF$solidjs.getOwner()); // we might have an owner, if so, pass it on. Otherwise, create one so solid doesn't print warnings to the console
@@ -10249,7 +10281,7 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
10249
10281
  enable_category_suggestions_: enable_category_suggestions,
10250
10282
  disable_scrolling_: disable_scrolling_during_modal,
10251
10283
  bottom_distance_under_modal_: bottom_distance_under_modal
10252
- });
10284
+ }, override_modal_element);
10253
10285
  // This will add some default behaviour to open_modal_ if no style_props_ are supplied
10254
10286
  // The default behaviour is to align the modal with the input field if possible
10255
10287
  const modal_opening_effect = () => {
package/latest/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/
7
7
  import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
8
8
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
9
9
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
10
- export const version = "2.0.8";
10
+ export const version = "2.0.10";
11
11
  /**
12
12
  * Returns accessor with the size of the provided element, including padding and border (I think)
13
13
  */
@@ -435,6 +435,7 @@ export type PageURLCreator<InputDisplay extends ModernDisplay, OutputDisplay ext
435
435
  * So the idea is to have a modal. It should either be rendered and exist, in which case it is in the foreground and open, or it's completely gone. This makes things easier.
436
436
  * @param search_modal a function which returns an array of nodes that get appended into <body>. This function will run in its own solid-js root which will call onCleanup and cleanup all reactive things inside it when the modal is closed. This function will get the arguments passed to open_modal_ and the modal_fn_opts merged together, along with register_closing_animation_ where an async function that resolves once the animation is finished can be provided to animate the closing of the modal
437
437
  * @param modal_fn_opts static options for the modal that won't change on a per-opening basis
438
+ * @param parent override the parent element to append the modal to. Defaults to <body>
438
439
  @returns a function to open and close the modal. When calling the open_modal_ function additional parameters can be passed to the modal
439
440
  */
440
441
  export function general_modal_abstraction<StaticOptions extends {
@@ -445,7 +446,7 @@ export function general_modal_abstraction<StaticOptions extends {
445
446
  close_modal_: VoidFunction;
446
447
  open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
447
448
  register_closing_animation_: (animation: () => Promise<any>) => void;
448
- }) => Node_Array, modal_fn_opts: StaticOptions): Promise<{
449
+ }) => Node_Array, modal_fn_opts: StaticOptions, parent?: HTMLElement | ShadowRoot): Promise<{
449
450
  open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
450
451
  close_modal_: () => void;
451
452
  }>;
@@ -753,6 +754,7 @@ type GeneralConstructorOptions<InputDisplay extends Display, OutputDisplay exten
753
754
  disable_scrolling_during_modal?: boolean;
754
755
  bottom_distance_under_modal?: Accessor<number | undefined>;
755
756
  render_instant_card?: InstantCard<OutputDisplay extends ModernDisplay ? OutputDisplay : InputDisplay>;
757
+ override_modal_element?: HTMLElement | ShadowRoot;
756
758
  };
757
759
  type ConstructorOptionsWithApi<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never> = GeneralConstructorOptions<InputDisplay, OutputDisplay> & {
758
760
  api: DepictAPI<InputDisplay, OutputDisplay>;
@@ -786,6 +788,7 @@ export class DepictSearch<InputDisplay extends Display, OutputDisplay extends Mo
786
788
  disable_scrolling_during_modal,
787
789
  bottom_distance_under_modal,
788
790
  render_instant_card,
791
+ override_modal_element,
789
792
  ...props_on_class
790
793
  }: ConstructorOptions<InputDisplay, OutputDisplay>);
791
794
  get enable_content_search(): boolean | undefined;