@depict-ai/ui 0.0.80 → 0.0.82
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/dist/index.d.ts +15 -13
- package/dist/main.js +606 -611
- package/dist/module.js +609 -614
- package/package.json +4 -4
package/dist/module.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj,
|
|
2
|
-
import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$effect, setAttribute as $g9l4l$setAttribute, createComponent as $g9l4l$createComponent, use as $g9l4l$use, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, classList as $g9l4l$classList,
|
|
3
|
-
import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createRenderEffect as $g9l4l$createRenderEffect, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show,
|
|
1
|
+
import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, CrossIcon as $g9l4l$CrossIcon, useExpandingContainer as $g9l4l$useExpandingContainer, Amazing_Slider as $g9l4l$Amazing_Slider, slider_snap_css as $g9l4l$slider_snap_css, slider_fading_factory as $g9l4l$slider_fading_factory, MinusIcon as $g9l4l$MinusIcon, FilterIcon as $g9l4l$FilterIcon, SortIconAsc as $g9l4l$SortIconAsc, SortIconDesc as $g9l4l$SortIconDesc, PlusIcon as $g9l4l$PlusIcon, hsl_to_rgb as $g9l4l$hsl_to_rgb, relative_luminance_from_rgb as $g9l4l$relative_luminance_from_rgb, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, queueMacroTask as $g9l4l$queueMacroTask, instant_exec_on_suspect_history_change as $g9l4l$instant_exec_on_suspect_history_change, dwarn as $g9l4l$dwarn, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces} from "@depict-ai/utilishared";
|
|
2
|
+
import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$effect, setAttribute as $g9l4l$setAttribute, createComponent as $g9l4l$createComponent, use as $g9l4l$use, memo as $g9l4l$memo, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, classList as $g9l4l$classList, style as $g9l4l$style, Dynamic as $g9l4l$Dynamic, mergeProps as $g9l4l$mergeProps, className as $g9l4l$className} from "solid-js/web";
|
|
3
|
+
import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createRenderEffect as $g9l4l$createRenderEffect, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createReaction as $g9l4l$createReaction, Suspense as $g9l4l$Suspense, on as $g9l4l$on, createRoot as $g9l4l$createRoot, ErrorBoundary as $g9l4l$ErrorBoundary, For as $g9l4l$For, getOwner as $g9l4l$getOwner, runWithOwner as $g9l4l$runWithOwner, Index as $g9l4l$Index} from "solid-js";
|
|
4
4
|
import {compressToBase64 as $g9l4l$compressToBase64, decompressFromBase64 as $g9l4l$decompressFromBase64} from "lz-string";
|
|
5
5
|
|
|
6
|
-
/*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.
|
|
6
|
+
/*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.82";
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
|
|
@@ -431,134 +431,6 @@ function $51b5c03492337d58$export$83fd5de5504a7a67({ formatted_number_of_results
|
|
|
431
431
|
|
|
432
432
|
|
|
433
433
|
|
|
434
|
-
/** @jsxImportSource solid-js */
|
|
435
|
-
function $948599427c358499$export$daf1a0aef2143a61({ first_result_in_viewport_: [, set_first_result_in_viewport_] , last_result_in_viewport_: [, set_last_result_in_viewport_] }) {
|
|
436
|
-
const intersecting = new Set();
|
|
437
|
-
const counting_is = new IntersectionObserver((records)=>{
|
|
438
|
-
let kids;
|
|
439
|
-
for (const { intersectionRatio: intersectionRatio , target: target } of records){
|
|
440
|
-
const intersects = intersectionRatio > 0;
|
|
441
|
-
const has_target = intersecting.has(target);
|
|
442
|
-
if (intersects && !has_target) intersecting.add(target);
|
|
443
|
-
else if (!intersects && has_target) intersecting.delete(target);
|
|
444
|
-
}
|
|
445
|
-
const numbers = [
|
|
446
|
-
...intersecting
|
|
447
|
-
].map((el)=>{
|
|
448
|
-
const index = (kids ||= [
|
|
449
|
-
...el.parentElement?.children || []
|
|
450
|
-
]).indexOf(el);
|
|
451
|
-
if (index < 0) return undefined;
|
|
452
|
-
return index + 1;
|
|
453
|
-
}).filter((item)=>item != undefined);
|
|
454
|
-
set_first_result_in_viewport_(Math.min(...numbers));
|
|
455
|
-
set_last_result_in_viewport_(Math.max(...numbers));
|
|
456
|
-
});
|
|
457
|
-
(0, $g9l4l$onCleanup)(()=>counting_is.disconnect());
|
|
458
|
-
return (els)=>{
|
|
459
|
-
for(let i = 0; i < els?.length; i++){
|
|
460
|
-
const el = els[i];
|
|
461
|
-
if (el instanceof Element) counting_is.observe(el);
|
|
462
|
-
}
|
|
463
|
-
};
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
/** @jsxImportSource solid-js */
|
|
468
|
-
|
|
469
|
-
function $06e28148a32abb47$export$36aef51ac7a64eae({ depict_api_: depict_api_ , min_products_to_fetch_: min_products_to_fetch_ , all_products_loaded_: all_products_loaded_ , query_base_: query_base_ , observe_for_counting_: observe_for_counting_ , start_cursor_: start_cursor_ }) {
|
|
470
|
-
let last_loaded = +new Date();
|
|
471
|
-
let dead = false;
|
|
472
|
-
let current_cursor = start_cursor_;
|
|
473
|
-
const target_to_info = new Map();
|
|
474
|
-
const tear_down = (0, $g9l4l$catchify)((loaded_all_products)=>{
|
|
475
|
-
intersection_observer.disconnect();
|
|
476
|
-
target_to_info.clear();
|
|
477
|
-
dead = true;
|
|
478
|
-
if (loaded_all_products) all_products_loaded_?.[1]?.(true);
|
|
479
|
-
});
|
|
480
|
-
const deduped_load_more = (0, $g9l4l$deparallelize)(async (...args)=>{
|
|
481
|
-
const now = +new Date();
|
|
482
|
-
// load faster if someone is scrolling aggressively
|
|
483
|
-
const num_to_load = now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
|
|
484
|
-
const new_cursor = await $06e28148a32abb47$var$load_more(...args, num_to_load);
|
|
485
|
-
if (new_cursor) current_cursor = new_cursor;
|
|
486
|
-
last_loaded = now;
|
|
487
|
-
});
|
|
488
|
-
const intersection_observer = new IntersectionObserver((0, $g9l4l$catchify)((records)=>{
|
|
489
|
-
let num_children;
|
|
490
|
-
for(let i = 0; i < records.length; i++){
|
|
491
|
-
// we assume they all have the same parent 👀
|
|
492
|
-
const record = records[i];
|
|
493
|
-
if (record.intersectionRatio <= 0) continue;
|
|
494
|
-
const { target: target } = record;
|
|
495
|
-
const parent = target.parentElement;
|
|
496
|
-
if (!parent) continue; // we're not in DOM or something funky
|
|
497
|
-
if (num_children == undefined) {
|
|
498
|
-
const kids = parent.childElementCount;
|
|
499
|
-
if (isNaN(kids)) continue;
|
|
500
|
-
num_children = kids;
|
|
501
|
-
}
|
|
502
|
-
const info = target_to_info.get(target);
|
|
503
|
-
if (!info) continue; // How did this happen?
|
|
504
|
-
let actual_index_;
|
|
505
|
-
for(let i = 0; i < num_children; i++){
|
|
506
|
-
const child = parent.children[i];
|
|
507
|
-
if (child === target) {
|
|
508
|
-
actual_index_ = i;
|
|
509
|
-
break;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
if (actual_index_ == undefined) continue;
|
|
513
|
-
const in_range = actual_index_ / num_children * 100;
|
|
514
|
-
const range_to_load_at = current_cursor === start_cursor_ ? 50 : 75; // if first load, load earlier
|
|
515
|
-
if (in_range > range_to_load_at) {
|
|
516
|
-
// load if more than 75% of elements are in view, this will make so that we load sooner and sooner which maybe (?) will adjust to people scrolling quickly :)
|
|
517
|
-
intersection_observer.disconnect(); // no need to watch these els anymore
|
|
518
|
-
deduped_load_more({
|
|
519
|
-
depict_api_: depict_api_,
|
|
520
|
-
info_: info,
|
|
521
|
-
container_: parent,
|
|
522
|
-
query_base_: query_base_,
|
|
523
|
-
on_reached_end_: ()=>tear_down(true),
|
|
524
|
-
cursor_: current_cursor
|
|
525
|
-
});
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}));
|
|
529
|
-
(0, $g9l4l$onCleanup)(tear_down);
|
|
530
|
-
return (items, _display, info_)=>{
|
|
531
|
-
observe_for_counting_(items);
|
|
532
|
-
if (dead) return items;
|
|
533
|
-
for(let i = 0; i < items?.length; i++){
|
|
534
|
-
const item = items[i];
|
|
535
|
-
if (item instanceof Element) {
|
|
536
|
-
target_to_info.set(item, info_);
|
|
537
|
-
intersection_observer.observe(item);
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
return items;
|
|
541
|
-
};
|
|
542
|
-
}
|
|
543
|
-
async function $06e28148a32abb47$var$load_more({ depict_api_: depict_api_ , query_base_: query_base_ , container_: container_ , on_reached_end_: on_reached_end_ , info_: { rendering_options: rendering_options , t: t } , cursor_: cursor_ }, num_results_to_load) {
|
|
544
|
-
(0, $g9l4l$dlog)("SearchResults: Loading more");
|
|
545
|
-
const base_part = (0, $g9l4l$untrack)(query_base_);
|
|
546
|
-
const api_response = await depict_api_["query_id" in base_part ? "list" : "query"]({
|
|
547
|
-
cursor: cursor_,
|
|
548
|
-
limit: num_results_to_load,
|
|
549
|
-
...base_part
|
|
550
|
-
});
|
|
551
|
-
const new_displays = api_response?.displays || [];
|
|
552
|
-
const { elements: elements } = await (0, $g9l4l$Rec_Renderer)(t, {
|
|
553
|
-
...rendering_options,
|
|
554
|
-
recs: new_displays || []
|
|
555
|
-
});
|
|
556
|
-
if (elements) container_.append(...elements);
|
|
557
|
-
else (0, $g9l4l$dlog)("SearchResults: Got no elements, that's weird", api_response);
|
|
558
|
-
if ("cursor" in api_response) return api_response.cursor;
|
|
559
|
-
else if (!api_response?.failed) on_reached_end_();
|
|
560
|
-
}
|
|
561
|
-
|
|
562
434
|
|
|
563
435
|
|
|
564
436
|
|
|
@@ -794,13 +666,8 @@ function $a20b0ecfca7ab32d$export$ef6006467f04ee41({ i18n_: i18n_ , expanded_hie
|
|
|
794
666
|
]);
|
|
795
667
|
|
|
796
668
|
|
|
797
|
-
/*
|
|
798
|
-
* Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
|
|
799
|
-
*/ const $9679915780ee67c0$export$6c9030e511152266 = 30;
|
|
800
|
-
|
|
801
|
-
|
|
802
669
|
function $ed06bb0bb83a46b3$export$a2cc176055f8f08() {
|
|
803
|
-
return document.createComment("Please try setting `colsAtSize` on `
|
|
670
|
+
return document.createComment("Please try setting `colsAtSize` on the `SearchPage`/`CategoryPage` components to change the grid before setting it with CSS. If you do with CSS, set `ColsAtSize` to an empty array to ensure no declarations created by the SDK leak through.");
|
|
804
671
|
}
|
|
805
672
|
|
|
806
673
|
|
|
@@ -853,77 +720,347 @@ function $a406ebe9523f192f$export$b69d0d92862de18b(props) {
|
|
|
853
720
|
}
|
|
854
721
|
|
|
855
722
|
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
function $
|
|
859
|
-
//
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
//
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
723
|
+
|
|
724
|
+
|
|
725
|
+
function $ccba3881414a4cec$export$2f0cbfbb4354bb52(elements) {
|
|
726
|
+
// FYI this probably doesn't work on hugely deep nestings or large amount of elements
|
|
727
|
+
return (0, $g9l4l$createMemo)(()=>$ccba3881414a4cec$var$unwrapping_helper(elements));
|
|
728
|
+
}
|
|
729
|
+
function $ccba3881414a4cec$var$unwrapping_helper(elements) {
|
|
730
|
+
const result = [];
|
|
731
|
+
if (Array.isArray(elements)) for(let i = 0; i < elements.length; i++){
|
|
732
|
+
const element = elements[i];
|
|
733
|
+
result.push(...$ccba3881414a4cec$var$unwrapping_helper(element));
|
|
734
|
+
}
|
|
735
|
+
else if (typeof elements == "function") result.push(...$ccba3881414a4cec$var$unwrapping_helper(elements()));
|
|
736
|
+
else if (elements != undefined && typeof elements != "boolean") result.push(elements);
|
|
737
|
+
return result;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
|
|
741
|
+
let $dc5df79ae78a9d00$var$cached_placeholder_element;
|
|
742
|
+
let $dc5df79ae78a9d00$var$rendering_cached_placeholder_element;
|
|
743
|
+
function $dc5df79ae78a9d00$export$f33414a4df0afd3f({ product_card_template_: product_card_template_ , num_placeholders_: num_placeholders_ }) {
|
|
744
|
+
const [get_elements, set_elements] = (0, $g9l4l$createSignal)([]);
|
|
745
|
+
let existing_num = 0;
|
|
746
|
+
(0, $g9l4l$createRenderEffect)(()=>{
|
|
747
|
+
const to_add = num_placeholders_() - existing_num;
|
|
748
|
+
if (to_add <= 0) return;
|
|
749
|
+
// Below comment is from when we used recommendation renderer and manual DOM manipulation for this, but I'm still scared to remove placeholders and mess up scroll restoration, so I'm keeping the way it worked. Otherwise, <Index> could be used which would be far more elegant.
|
|
750
|
+
// We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
|
|
751
|
+
// The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
|
|
752
|
+
set_elements((prev)=>[
|
|
753
|
+
...prev,
|
|
754
|
+
...Array.from({
|
|
755
|
+
length: to_add
|
|
756
|
+
}).map(()=>$dc5df79ae78a9d00$var$Placeholder({
|
|
757
|
+
product_card_template_: product_card_template_
|
|
758
|
+
}))
|
|
886
759
|
]);
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
760
|
+
existing_num += to_add;
|
|
761
|
+
});
|
|
762
|
+
return get_elements; // https://github.com/solidjs/solid/releases/tag/v1.7.0
|
|
763
|
+
}
|
|
764
|
+
/**
|
|
765
|
+
* Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
|
|
766
|
+
*/ function $dc5df79ae78a9d00$var$Placeholder({ product_card_template_: product_card_template_ }) {
|
|
767
|
+
const get_cloned_placeholders = (element_to_clone = $dc5df79ae78a9d00$var$cached_placeholder_element)=>Array.isArray(element_to_clone) ? element_to_clone.map((el)=>el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
|
|
768
|
+
if ($dc5df79ae78a9d00$var$cached_placeholder_element) return get_cloned_placeholders();
|
|
769
|
+
let dispose_original_copy;
|
|
770
|
+
const get_unwrapped_element = (0, $g9l4l$createRoot)((dispose)=>{
|
|
771
|
+
dispose_original_copy = dispose;
|
|
772
|
+
// if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
|
|
773
|
+
const [resource] = (0, $g9l4l$createResource)(()=>{
|
|
774
|
+
if ($dc5df79ae78a9d00$var$rendering_cached_placeholder_element) return $dc5df79ae78a9d00$var$rendering_cached_placeholder_element;
|
|
775
|
+
const return_value = product_card_template_(null, undefined);
|
|
776
|
+
if (typeof return_value === "object" && typeof return_value?.then === "function") // Is Promise or promise-like object
|
|
777
|
+
$dc5df79ae78a9d00$var$rendering_cached_placeholder_element = return_value;
|
|
778
|
+
return return_value;
|
|
898
779
|
});
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
(0, $
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (
|
|
906
|
-
|
|
780
|
+
return (0, $g9l4l$createMemo)(()=>{
|
|
781
|
+
if (resource.loading) return ()=>[];
|
|
782
|
+
return (0, $ccba3881414a4cec$export$2f0cbfbb4354bb52)(resource);
|
|
783
|
+
});
|
|
784
|
+
});
|
|
785
|
+
(0, $g9l4l$onCleanup)(()=>{
|
|
786
|
+
if ($dc5df79ae78a9d00$var$rendering_cached_placeholder_element) {
|
|
787
|
+
// If we're still rendering in our separate root, let the rendering finish or other <Placeholder> components waiting for it might get an incomplete result
|
|
788
|
+
const unset_current_rendering = ()=>{
|
|
789
|
+
dispose_original_copy();
|
|
790
|
+
$dc5df79ae78a9d00$var$rendering_cached_placeholder_element = undefined;
|
|
791
|
+
};
|
|
792
|
+
$dc5df79ae78a9d00$var$rendering_cached_placeholder_element?.then(unset_current_rendering, unset_current_rendering);
|
|
793
|
+
} else // Otherwise, just make sure we've disposed our root
|
|
794
|
+
dispose_original_copy();
|
|
795
|
+
});
|
|
796
|
+
return (0, $g9l4l$createMemo)(()=>{
|
|
797
|
+
const unwrapped_array = get_unwrapped_element()();
|
|
798
|
+
if (!unwrapped_array?.length || !unwrapped_array.every((item)=>item)) // Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
|
|
799
|
+
return;
|
|
800
|
+
// placeholders have finished rendering, freeze the elements
|
|
801
|
+
$dc5df79ae78a9d00$var$cached_placeholder_element = get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
|
|
802
|
+
$dc5df79ae78a9d00$var$rendering_cached_placeholder_element = undefined;
|
|
803
|
+
dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
|
|
804
|
+
return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
|
|
805
|
+
});
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
|
|
809
|
+
/*
|
|
810
|
+
* Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
|
|
811
|
+
*/ const $9679915780ee67c0$export$6c9030e511152266 = 30;
|
|
812
|
+
|
|
813
|
+
|
|
814
|
+
/** @jsxImportSource solid-js */
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
|
|
818
|
+
function $ebad9fcdd4698520$export$5e4aed86c12acdd9({ percentage_in_view_: percentage_in_view_ , set_extra_displays_: set_extra_displays_ , all_products_loaded_: all_products_loaded_ , plp_results_: plp_results_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , depict_api_: depict_api_ }) {
|
|
819
|
+
let last_loaded = +new Date();
|
|
820
|
+
let is_loading_more = false;
|
|
821
|
+
let is_first_load = true;
|
|
822
|
+
const [get_last_cursor, set_last_cursor] = (0, $g9l4l$createSignal)();
|
|
823
|
+
(0, $g9l4l$createComputed)((0, $g9l4l$on)(plp_results_, ()=>set_extra_displays_([]), {
|
|
824
|
+
defer: true
|
|
825
|
+
})); // empty array when a new request has completed (don't run this initially since it will already be empty)
|
|
826
|
+
(0, $g9l4l$createComputed)(()=>{
|
|
827
|
+
set_last_cursor(plp_results_()?.cursor);
|
|
828
|
+
last_loaded = +new Date();
|
|
829
|
+
is_first_load = true;
|
|
830
|
+
});
|
|
831
|
+
(0, $g9l4l$createEffect)((0, $g9l4l$catchify)(async ()=>{
|
|
832
|
+
const be_above_percentage = is_first_load ? 50 : 75; // if first load, load earlier
|
|
833
|
+
if (percentage_in_view_() < be_above_percentage || is_loading_more) return;
|
|
834
|
+
if (!get_last_cursor()) {
|
|
835
|
+
// dlog("All results loaded, can't load more");
|
|
836
|
+
all_products_loaded_?.[1](true); // This is unset in SearchPage as we start fetching new results
|
|
907
837
|
return;
|
|
908
838
|
}
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
839
|
+
// dlog("More than ", be_above_percentage, "% in view, ", percentage_in_view_(), "%, loading more");
|
|
840
|
+
is_loading_more = true;
|
|
841
|
+
const base_part = (0, $g9l4l$untrack)(query_base_);
|
|
842
|
+
const now = +new Date();
|
|
843
|
+
// load faster if someone is scrolling aggressively
|
|
844
|
+
const number_of_results_to_load = is_first_load ? // After first load, always just load 20 since people might just be browsing the top ones still
|
|
845
|
+
min_products_to_fetch_ : now - last_loaded < 10000 ? min_products_to_fetch_ * 5 : min_products_to_fetch_;
|
|
846
|
+
// dlog("loading ", number_of_results_to_load, "products, because it was", now - last_loaded, "ms since last load");
|
|
847
|
+
const api_response = await depict_api_["query_id" in base_part ? "list" : "query"]({
|
|
848
|
+
cursor: get_last_cursor(),
|
|
849
|
+
limit: number_of_results_to_load,
|
|
850
|
+
...base_part
|
|
916
851
|
});
|
|
852
|
+
const new_displays = api_response?.displays || [];
|
|
853
|
+
set_extra_displays_((old_value)=>{
|
|
854
|
+
// We want this to go fast. The apply method is the fastest way to add to an array, and AFAIK it's faster to add than to create a new one.
|
|
855
|
+
// eslint-disable-next-line prefer-spread
|
|
856
|
+
old_value.push.apply(old_value, new_displays);
|
|
857
|
+
return old_value;
|
|
858
|
+
});
|
|
859
|
+
set_last_cursor(api_response.cursor);
|
|
860
|
+
is_loading_more = false;
|
|
861
|
+
last_loaded = +new Date();
|
|
862
|
+
is_first_load = false;
|
|
863
|
+
}));
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
function $912322b9ff19fa51$export$63dd0350f8559dda({ displays_by_key_: displays_by_key_ , get_last_result_in_viewport_: get_last_result_in_viewport_ , index_to_target_map_: index_to_target_map_ , is_loading_: is_loading_ , get_extra_displays: get_extra_displays }) {
|
|
869
|
+
const [get_has_rendered_toggle, set_has_rendered_toggle] = (0, $g9l4l$createSignal)(false);
|
|
870
|
+
(0, $g9l4l$createEffect)(()=>{
|
|
871
|
+
// We need this to run after the "render phase"
|
|
872
|
+
get_extra_displays();
|
|
873
|
+
set_has_rendered_toggle((old)=>!old);
|
|
917
874
|
});
|
|
875
|
+
return (0, $g9l4l$createMemo)(()=>{
|
|
876
|
+
const last = get_last_result_in_viewport_();
|
|
877
|
+
// Check if we are past the last result, in that case we want it to count as 100% for a better infinite scroll experience
|
|
878
|
+
past_last_result_check: {
|
|
879
|
+
const elements_of_last_result = index_to_target_map_.get(index_to_target_map_.size - 1);
|
|
880
|
+
if (elements_of_last_result) {
|
|
881
|
+
if ((0, $g9l4l$untrack)(is_loading_)) {
|
|
882
|
+
// We're loading, wait check again after we have inserted our new results
|
|
883
|
+
get_has_rendered_toggle();
|
|
884
|
+
break past_last_result_check;
|
|
885
|
+
}
|
|
886
|
+
for (const element of elements_of_last_result){
|
|
887
|
+
if (document.documentElement.contains(element) && element.getBoundingClientRect().top <= 0) // dlog(element, "which is of last product card is in or above viewport, probably loading more");
|
|
888
|
+
return 100;
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
if (isNaN(last)) return 0;
|
|
893
|
+
if (Math.abs(last) === Infinity) // No product card in view and not after last card, assume first card
|
|
894
|
+
return 0;
|
|
895
|
+
return last / displays_by_key_().size * 100;
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
|
|
900
|
+
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Gets product_id (the thing we key the rendering on) from a display
|
|
904
|
+
*/ function $4dd45ddfca49bd72$export$548d053aba053d79(display) {
|
|
905
|
+
if ("variant_index" in display) {
|
|
906
|
+
const actual_display = display.variant_displays[display.variant_index];
|
|
907
|
+
return actual_display.product_id;
|
|
908
|
+
}
|
|
909
|
+
return display.product_id;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
|
|
913
|
+
|
|
914
|
+
function $7a5055d6c11943a0$export$7f8bd308237ab5a5(get_displays_) {
|
|
915
|
+
const displays_by_key_ = (0, $g9l4l$createMemo)(()=>{
|
|
916
|
+
const displays = get_displays_();
|
|
917
|
+
// We key by product_id because that's what can be used to uniquely identify products
|
|
918
|
+
// This way <For> can optimize the rendering
|
|
919
|
+
const map = new Map();
|
|
920
|
+
for(let i = 0; i < displays.length; i++){
|
|
921
|
+
const display = displays[i];
|
|
922
|
+
const product_id = (0, $4dd45ddfca49bd72$export$548d053aba053d79)(display);
|
|
923
|
+
map.set(product_id, display);
|
|
924
|
+
}
|
|
925
|
+
return map;
|
|
926
|
+
});
|
|
927
|
+
return displays_by_key_;
|
|
928
|
+
}
|
|
929
|
+
function $7a5055d6c11943a0$export$43f0fb951fcb0c54({ displays_by_key_: displays_by_key_ , merchant_: merchant_ , market_: market_ , product_card_template_: product_card_template_ , do_per_elements_: do_per_elements_ }) {
|
|
930
|
+
return (0, $g9l4l$createComponent)((0, $g9l4l$For), {
|
|
931
|
+
get each () {
|
|
932
|
+
return [
|
|
933
|
+
...displays_by_key_().keys()
|
|
934
|
+
];
|
|
935
|
+
},
|
|
936
|
+
children: (product_id, index)=>{
|
|
937
|
+
// We're using `untrack` here since we don't want to react in here to displays_by_key changing
|
|
938
|
+
// As long as our key stays the same we assume that the display hasn't changed, so we don't want to rerender
|
|
939
|
+
// If the key gets removed, <For> will remove us
|
|
940
|
+
const owner = (0, $g9l4l$getOwner)();
|
|
941
|
+
const display_accessor = (0, $g9l4l$createMemo)(()=>displays_by_key_().get(product_id));
|
|
942
|
+
const [product_card_resource] = (0, $g9l4l$createResource)((0, $g9l4l$createMemo)(()=>[
|
|
943
|
+
merchant_(),
|
|
944
|
+
market_()
|
|
945
|
+
]), // re-render when merchant or market changes
|
|
946
|
+
([merchant, market])=>{
|
|
947
|
+
// get display in the function that re-runs when merchant or market have changed, since the display may have changed but product_id not
|
|
948
|
+
const display = (0, $g9l4l$untrack)(display_accessor);
|
|
949
|
+
return product_card_template_(display, {
|
|
950
|
+
set_on_index_change: (fn)=>(0, $g9l4l$runWithOwner)(owner, ()=>(0, $g9l4l$createEffect)(()=>fn(index()))),
|
|
951
|
+
merchant: merchant,
|
|
952
|
+
market: market
|
|
953
|
+
});
|
|
954
|
+
});
|
|
955
|
+
const node_accessor = (0, $ccba3881414a4cec$export$2f0cbfbb4354bb52)(product_card_resource);
|
|
956
|
+
(0, $g9l4l$createEffect)(()=>{
|
|
957
|
+
const product_card_nodes = node_accessor();
|
|
958
|
+
const display = display_accessor();
|
|
959
|
+
const elements = [];
|
|
960
|
+
for(let i = 0; i < product_card_nodes.length; i++){
|
|
961
|
+
const element = product_card_nodes[i];
|
|
962
|
+
if (!(element instanceof Element)) continue;
|
|
963
|
+
elements.push(element);
|
|
964
|
+
// Add tracking ids
|
|
965
|
+
if (!(element instanceof HTMLElement)) continue; // Apparently only HTMLElements have dataset
|
|
966
|
+
const { dataset: dataset } = element;
|
|
967
|
+
const { search_result_id: search_result_id , product_listing_result_id: product_listing_result_id , recommendation_id: recommendation_id } = display;
|
|
968
|
+
if (search_result_id) dataset.searchResultId = search_result_id;
|
|
969
|
+
else if (product_listing_result_id) dataset.productListingResultId = product_listing_result_id;
|
|
970
|
+
else if (recommendation_id) dataset.recommendationId = recommendation_id;
|
|
971
|
+
}
|
|
972
|
+
do_per_elements_?.(elements, index);
|
|
973
|
+
});
|
|
974
|
+
return product_card_resource; // https://github.com/solidjs/solid/releases/tag/v1.7.0
|
|
975
|
+
}
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
|
|
980
|
+
function $9653d6d247b0b1cc$export$a1fd619a4743ca08({ plp_results_: plp_results_ , product_card_template_: product_card_template_ , first_result_in_viewport_: [, set_first_result_in_viewport] , last_result_in_viewport_: [get_last_result_in_viewport_, set_last_result_in_viewport] , merchant_: merchant_ , market_: market_ , all_products_loaded_: all_products_loaded_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , depict_api_: depict_api_ , is_loading_: is_loading_ }) {
|
|
981
|
+
// The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator and knowing when to load more
|
|
982
|
+
const target_to_index_map = new Map();
|
|
983
|
+
const index_to_target_map_ = new Map();
|
|
984
|
+
const currently_intersecting = new Set();
|
|
985
|
+
const intersection_observer = new IntersectionObserver((0, $g9l4l$catchify)((records)=>{
|
|
986
|
+
for(let i = 0; i < records.length; i++){
|
|
987
|
+
const record = records[i];
|
|
988
|
+
const { target: target , intersectionRatio: intersectionRatio } = record;
|
|
989
|
+
const index_of_target = target_to_index_map.get(target);
|
|
990
|
+
const is_in_set = currently_intersecting.has(index_of_target);
|
|
991
|
+
if (intersectionRatio > 0) {
|
|
992
|
+
if (!is_in_set) currently_intersecting.add(index_of_target);
|
|
993
|
+
} else if (is_in_set) currently_intersecting.delete(index_of_target);
|
|
994
|
+
}
|
|
995
|
+
set_first_result_in_viewport(Math.min(...currently_intersecting) + 1); // +1 because we want to start counting at 1
|
|
996
|
+
set_last_result_in_viewport(Math.max(...currently_intersecting) + 1);
|
|
997
|
+
}, "PLPResults IO failed"));
|
|
998
|
+
// Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
|
|
999
|
+
const [get_extra_displays, set_extra_displays_] = (0, $g9l4l$createSignal)([], {
|
|
1000
|
+
equals: false
|
|
1001
|
+
});
|
|
1002
|
+
const displays_by_key_ = (0, $7a5055d6c11943a0$export$7f8bd308237ab5a5)((0, $g9l4l$createMemo)(()=>[
|
|
1003
|
+
...plp_results_().displays,
|
|
1004
|
+
...get_extra_displays()
|
|
1005
|
+
]));
|
|
1006
|
+
const percentage_in_view_ = (0, $912322b9ff19fa51$export$63dd0350f8559dda)({
|
|
1007
|
+
get_last_result_in_viewport_: get_last_result_in_viewport_,
|
|
1008
|
+
displays_by_key_: displays_by_key_,
|
|
1009
|
+
index_to_target_map_: index_to_target_map_,
|
|
1010
|
+
is_loading_: is_loading_,
|
|
1011
|
+
get_extra_displays: get_extra_displays
|
|
1012
|
+
});
|
|
1013
|
+
(0, $ebad9fcdd4698520$export$5e4aed86c12acdd9)({
|
|
1014
|
+
percentage_in_view_: percentage_in_view_,
|
|
1015
|
+
set_extra_displays_: set_extra_displays_,
|
|
1016
|
+
all_products_loaded_: all_products_loaded_,
|
|
1017
|
+
plp_results_: plp_results_,
|
|
1018
|
+
min_products_to_fetch_: min_products_to_fetch_,
|
|
1019
|
+
query_base_: query_base_,
|
|
1020
|
+
depict_api_: depict_api_
|
|
1021
|
+
});
|
|
1022
|
+
return (0, $7a5055d6c11943a0$export$43f0fb951fcb0c54)({
|
|
1023
|
+
displays_by_key_: displays_by_key_,
|
|
1024
|
+
merchant_: merchant_,
|
|
1025
|
+
market_: market_,
|
|
1026
|
+
product_card_template_: product_card_template_,
|
|
1027
|
+
do_per_elements_: (elements, index_accessor)=>// Adds/removes elements from the "results in viewport" intersection observer above
|
|
1028
|
+
(0, $g9l4l$createEffect)(()=>{
|
|
1029
|
+
const display_index = index_accessor();
|
|
1030
|
+
// Nested createEffect because we only want to re-run this when the index changes
|
|
1031
|
+
// We need to save in a map which index the elements of this template are so that we can know that in the IntersectionObserver callback
|
|
1032
|
+
for(let i = 0; i < elements.length; i++){
|
|
1033
|
+
const element = elements[i];
|
|
1034
|
+
target_to_index_map.set(element, display_index);
|
|
1035
|
+
intersection_observer.observe(element);
|
|
1036
|
+
(0, $g9l4l$onCleanup)(()=>{
|
|
1037
|
+
intersection_observer.unobserve(element);
|
|
1038
|
+
target_to_index_map.delete(element);
|
|
1039
|
+
currently_intersecting.delete(display_index);
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
index_to_target_map_.set(display_index, elements);
|
|
1043
|
+
(0, $g9l4l$onCleanup)(()=>index_to_target_map_.delete(display_index));
|
|
1044
|
+
})
|
|
1045
|
+
});
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
const $57363319986950eb$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="PLP-results"></div>`, 2), $57363319986950eb$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="cards"></div>`, 2), $57363319986950eb$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<style></style>`, 2);
|
|
1050
|
+
function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_ , depict_api_: depict_api_ , all_products_loaded_: all_products_loaded_ , min_products_to_fetch_: min_products_to_fetch_ , query_base_: query_base_ , first_result_in_viewport_: first_result_in_viewport_ , last_result_in_viewport_: last_result_in_viewport_ , scroll_restoration_data_: [get_scroll_restoration_data] , no_results_options_: no_results_options_ , desktop_filter_elements_: desktop_filter_elements_ , sort_or_filter_open_: sort_or_filter_open_ , product_card_template_: product_card_template_ , layout_options_: layout_options_ , id_currently_querying_for_: id_currently_querying_for_ }) {
|
|
1051
|
+
// The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
|
|
1052
|
+
const is_loading_ = (0, $g9l4l$createMemo)(()=>plp_results_.loading || query_base_.loading);
|
|
1053
|
+
const merchant_ = (0, $g9l4l$createMemo)(()=>query_base_().tenant);
|
|
1054
|
+
const market_ = (0, $g9l4l$createMemo)(()=>query_base_().market);
|
|
918
1055
|
const has_no_results_or_failed = (0, $g9l4l$createMemo)(()=>{
|
|
919
1056
|
const displays = plp_results_()?.displays;
|
|
920
|
-
return !
|
|
1057
|
+
return !is_loading_() && (!Array.isArray(displays) || !displays.length);
|
|
921
1058
|
});
|
|
922
|
-
if (all_products_loaded_)
|
|
1059
|
+
if (all_products_loaded_) // This is for the case that all products were loaded in the first result I think?
|
|
1060
|
+
(0, $g9l4l$createComputed)(()=>{
|
|
923
1061
|
const is_at_end = !plp_results_()?.cursor; // or failed, but we don't wanna / it's not easy to retry
|
|
924
|
-
if (!
|
|
1062
|
+
if (!is_loading_() && is_at_end) all_products_loaded_[1](true);
|
|
925
1063
|
});
|
|
926
|
-
(0, $g9l4l$onCleanup)(()=>cleanup_old_cards.forEach((fn)=>fn())); // if everything gets cleaned up without new cards replacing the old ones, clean up the last cards
|
|
927
1064
|
return (()=>{
|
|
928
1065
|
const _el$ = $57363319986950eb$var$_tmpl$.cloneNode(true);
|
|
929
1066
|
(0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
@@ -937,7 +1074,7 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
937
1074
|
return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
|
|
938
1075
|
severity_: "error",
|
|
939
1076
|
// More granular error handling
|
|
940
|
-
// This _also_ fails when a product card rendering fails
|
|
1077
|
+
// This _also_ fails when a product card rendering fails
|
|
941
1078
|
on_error_: (retry)=>{
|
|
942
1079
|
// re-try / reset ErrorBoundary next time we're getting product cards
|
|
943
1080
|
const track = (0, $g9l4l$createReaction)(retry);
|
|
@@ -949,83 +1086,108 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
949
1086
|
// So that the styling looks pretty when we've failed
|
|
950
1087
|
message_: "Result rendering failed",
|
|
951
1088
|
get children () {
|
|
1089
|
+
let suspense_contents;
|
|
1090
|
+
let is_just_after_plp_results_update = false;
|
|
1091
|
+
let fallback_is_alive = false;
|
|
952
1092
|
const random_id = (0, $g9l4l$make_random_classname)();
|
|
953
|
-
const
|
|
954
|
-
const
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
cloned_row[0] = num_cols_default - 1;
|
|
970
|
-
if (override_cols) // @ts-ignore
|
|
971
|
-
cloned_row[4] = {
|
|
972
|
-
overrides: Object.fromEntries(Object.entries(override_cols.overrides).map(([row, column])=>[
|
|
973
|
-
row,
|
|
974
|
-
column - 1
|
|
975
|
-
]))
|
|
976
|
-
};
|
|
977
|
-
return cloned_row;
|
|
978
|
-
}) : when_filters_closed_cols;
|
|
979
|
-
const css = (0, $g9l4l$n_col_styling_with_dist)(selector_beginning, layout_options_.grid_spacing, cols_at_size, "grid", layout_options_.override_vertical_spacing);
|
|
980
|
-
style.replaceChildren(css);
|
|
1093
|
+
const selector_beginning_ = `.depict.plp #${random_id}>`;
|
|
1094
|
+
const [get_styling, set_styling_] = (0, $g9l4l$createSignal)("");
|
|
1095
|
+
const [get_should_have_placeholders_rendered, set_should_have_placeholders_rendered] = (0, $g9l4l$createSignal)(false);
|
|
1096
|
+
const rendered_placeholders = (0, $g9l4l$createMemo)(()=>get_should_have_placeholders_rendered() ? (0, $dc5df79ae78a9d00$export$f33414a4df0afd3f)({
|
|
1097
|
+
product_card_template_: product_card_template_,
|
|
1098
|
+
num_placeholders_: (0, $g9l4l$createMemo)(()=>{
|
|
1099
|
+
// Can't use the data out of request_base for the id because request_base is too late, we need the correct amount of placeholders before the browser has restored the scroll state after processing all popstate events
|
|
1100
|
+
return (0, $9679915780ee67c0$export$6c9030e511152266) + (get_scroll_restoration_data().find(({ for_id: for_id })=>for_id === id_currently_querying_for_())?.min_results_loaded ?? min_products_to_fetch_);
|
|
1101
|
+
})
|
|
1102
|
+
}) : undefined);
|
|
1103
|
+
const [get_suspense_is_blocked, set_suspense_is_blocked] = (0, $g9l4l$createSignal)(false);
|
|
1104
|
+
(0, $g9l4l$createComputed)(()=>{
|
|
1105
|
+
if (!is_loading_()) return;
|
|
1106
|
+
set_should_have_placeholders_rendered(true);
|
|
1107
|
+
set_suspense_is_blocked(false);
|
|
1108
|
+
is_just_after_plp_results_update = true;
|
|
981
1109
|
});
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1110
|
+
$57363319986950eb$var$results_grid_styling_generator({
|
|
1111
|
+
layout_options_: layout_options_,
|
|
1112
|
+
set_styling_: set_styling_,
|
|
1113
|
+
sort_or_filter_open_: sort_or_filter_open_,
|
|
1114
|
+
selector_beginning_: selector_beginning_
|
|
1115
|
+
});
|
|
1116
|
+
const has_at_least_one_display = (0, $g9l4l$createMemo)(()=>!!plp_results_()?.displays?.length); // Only de-construct below stuff if we get 0 displays. Important that this returns boolean so that below Suspense only gets re-created if it actually changes
|
|
1117
|
+
const block_suspense_if_needed = ()=>{
|
|
1118
|
+
if (!is_just_after_plp_results_update) return;
|
|
1119
|
+
is_just_after_plp_results_update = false;
|
|
1120
|
+
fallback_is_alive = false;
|
|
1121
|
+
set_suspense_is_blocked(true);
|
|
1122
|
+
};
|
|
1123
|
+
const non_placeholder_product_cards = (0, $g9l4l$createMemo)(()=>has_at_least_one_display() && // 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)
|
|
1124
|
+
// We're creating it outside the <Show> so that we can benefit from <For>'s optimisation between changing results
|
|
1125
|
+
// (For the whole idea of the displays being cached to work we can't tear down and re-run ProductCards for every new result.
|
|
1126
|
+
// We have to keep ProductCards alive, but hidden, and feed them new data as soon as we had it)
|
|
1127
|
+
(0, $g9l4l$createComponent)((0, $g9l4l$Suspense), {
|
|
1128
|
+
get fallback () {
|
|
1129
|
+
return (()=>{
|
|
1130
|
+
fallback_is_alive = true;
|
|
1131
|
+
(0, $g9l4l$onCleanup)(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
|
|
1132
|
+
return (0, $g9l4l$createMemo)(()=>{
|
|
1133
|
+
// 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
|
|
1134
|
+
// In future we could have individual suspense's for each product card, but that's too much for now
|
|
1135
|
+
if (get_suspense_is_blocked()) return suspense_contents;
|
|
1136
|
+
set_should_have_placeholders_rendered(true); // just in case
|
|
1137
|
+
(0, $g9l4l$onCleanup)(()=>set_should_have_placeholders_rendered(false));
|
|
1138
|
+
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>
|
|
1139
|
+
});
|
|
1140
|
+
})();
|
|
1141
|
+
},
|
|
1142
|
+
get children () {
|
|
1143
|
+
return (()=>{
|
|
1144
|
+
suspense_contents = (0, $9653d6d247b0b1cc$export$a1fd619a4743ca08)({
|
|
1145
|
+
product_card_template_: product_card_template_,
|
|
1146
|
+
plp_results_: plp_results_,
|
|
1147
|
+
last_result_in_viewport_: last_result_in_viewport_,
|
|
1148
|
+
first_result_in_viewport_: first_result_in_viewport_,
|
|
1149
|
+
market_: market_,
|
|
1150
|
+
merchant_: merchant_,
|
|
1151
|
+
all_products_loaded_: all_products_loaded_,
|
|
1152
|
+
min_products_to_fetch_: min_products_to_fetch_,
|
|
1153
|
+
query_base_: query_base_,
|
|
1154
|
+
depict_api_: depict_api_,
|
|
1155
|
+
is_loading_: is_loading_
|
|
1156
|
+
});
|
|
1157
|
+
(0, $g9l4l$onCleanup)(()=>suspense_contents = undefined);
|
|
1158
|
+
return suspense_contents;
|
|
1159
|
+
})();
|
|
1021
1160
|
}
|
|
1022
1161
|
}));
|
|
1023
|
-
|
|
1162
|
+
(0, $g9l4l$createEffect)((0, $g9l4l$on)(plp_results_, ()=>{
|
|
1163
|
+
if (!fallback_is_alive) // 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 block the suspense. Therefore, we're just doing it with this effect
|
|
1164
|
+
block_suspense_if_needed();
|
|
1165
|
+
}, {
|
|
1166
|
+
defer: true
|
|
1024
1167
|
}));
|
|
1025
1168
|
return [
|
|
1026
|
-
(0, $ed06bb0bb83a46b3$export$a2cc176055f8f08)
|
|
1027
|
-
|
|
1028
|
-
|
|
1169
|
+
(0, $g9l4l$memo)((0, $ed06bb0bb83a46b3$export$a2cc176055f8f08)),
|
|
1170
|
+
(()=>{
|
|
1171
|
+
const _el$2 = $57363319986950eb$var$_tmpl$2.cloneNode(true);
|
|
1172
|
+
(0, $g9l4l$setAttribute)(_el$2, "id", random_id);
|
|
1173
|
+
(0, $g9l4l$insert)(_el$2, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
1174
|
+
get when () {
|
|
1175
|
+
return !is_loading_();
|
|
1176
|
+
},
|
|
1177
|
+
get fallback () {
|
|
1178
|
+
return rendered_placeholders();
|
|
1179
|
+
},
|
|
1180
|
+
get children () {
|
|
1181
|
+
return non_placeholder_product_cards();
|
|
1182
|
+
}
|
|
1183
|
+
}));
|
|
1184
|
+
return _el$2;
|
|
1185
|
+
})(),
|
|
1186
|
+
(()=>{
|
|
1187
|
+
const _el$3 = $57363319986950eb$var$_tmpl$3.cloneNode(true);
|
|
1188
|
+
(0, $g9l4l$insert)(_el$3, get_styling);
|
|
1189
|
+
return _el$3;
|
|
1190
|
+
})()
|
|
1029
1191
|
];
|
|
1030
1192
|
}
|
|
1031
1193
|
});
|
|
@@ -1036,63 +1198,32 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
1036
1198
|
return _el$;
|
|
1037
1199
|
})();
|
|
1038
1200
|
}
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1201
|
+
/**
|
|
1202
|
+
* Sets styling to styling generated by "Layout" (n_col_styling_with_dist) depending on if filters are open or not
|
|
1203
|
+
* This function is special to the actual PLPResults.
|
|
1204
|
+
*/ function $57363319986950eb$var$results_grid_styling_generator({ layout_options_: layout_options_ , sort_or_filter_open_: sort_or_filter_open_ , set_styling_: set_styling_ , selector_beginning_: selector_beginning_ }) {
|
|
1205
|
+
(0, $g9l4l$createRenderEffect)(()=>{
|
|
1206
|
+
// Add grid styling that changes when filters get opened/closed
|
|
1207
|
+
const when_filters_closed_cols = layout_options_.cols_at_size;
|
|
1208
|
+
const cols_at_size = sort_or_filter_open_() ? when_filters_closed_cols.map((row)=>{
|
|
1209
|
+
const [num_cols_default, , , , override_cols] = row;
|
|
1210
|
+
const cloned_row = [
|
|
1211
|
+
...row
|
|
1212
|
+
];
|
|
1213
|
+
// @ts-ignore
|
|
1214
|
+
cloned_row[0] = num_cols_default - 1;
|
|
1215
|
+
if (override_cols) // @ts-ignore
|
|
1216
|
+
cloned_row[4] = {
|
|
1217
|
+
overrides: Object.fromEntries(Object.entries(override_cols.overrides).map(([row, column])=>[
|
|
1218
|
+
row,
|
|
1219
|
+
column - 1
|
|
1220
|
+
]))
|
|
1221
|
+
};
|
|
1222
|
+
return cloned_row;
|
|
1223
|
+
}) : when_filters_closed_cols;
|
|
1224
|
+
const css = (0, $g9l4l$n_col_styling_with_dist)(selector_beginning_, layout_options_.grid_spacing, cols_at_size, "grid", layout_options_.override_vertical_spacing);
|
|
1225
|
+
set_styling_(css);
|
|
1044
1226
|
});
|
|
1045
|
-
let existing_num = 0;
|
|
1046
|
-
let removed_old_children = false;
|
|
1047
|
-
if (!$57363319986950eb$var$cached_placeholder_element) {
|
|
1048
|
-
const [dispose_card, root_in_root] = (0, $g9l4l$createRoot)((dispose)=>[
|
|
1049
|
-
dispose,
|
|
1050
|
-
(0, $g9l4l$getOwner)()
|
|
1051
|
-
]);
|
|
1052
|
-
const { elements: elements } = await (0, $g9l4l$default_rr)(tenant_object_, {
|
|
1053
|
-
...rr_options_,
|
|
1054
|
-
type: "placeholder",
|
|
1055
|
-
pre_processors: [],
|
|
1056
|
-
post_processors: [],
|
|
1057
|
-
...typeof rr_options_.template === "function" ? {
|
|
1058
|
-
template: $57363319986950eb$var$wrap_template_to_throw_into_error_boundary(rr_options_.template, root_in_root, ()=>(0, $g9l4l$queueMacroTask)((0, $g9l4l$catchify)(dispose_card)) // we just want it cloned and dead
|
|
1059
|
-
)
|
|
1060
|
-
} : {},
|
|
1061
|
-
recs: [
|
|
1062
|
-
{
|
|
1063
|
-
page_url: "javascript:void(0)"
|
|
1064
|
-
}
|
|
1065
|
-
] // This later gets ignored and turned into `null` by the SDK functions in the @depict-ai/ui package
|
|
1066
|
-
});
|
|
1067
|
-
const element = elements?.find((e)=>e instanceof HTMLElement || e instanceof SVGElement);
|
|
1068
|
-
if (!element) return [];
|
|
1069
|
-
$57363319986950eb$var$cached_placeholder_element = element.cloneNode(true); // don't save the actual element, clone it directly so that the who provided it can't modify it later (this has caused a bug before with react)
|
|
1070
|
-
}
|
|
1071
|
-
(0, $g9l4l$runWithOwner)(owner_, ()=>(0, $g9l4l$createRenderEffect)(()=>{
|
|
1072
|
-
const to_add = num_placeholders() - existing_num;
|
|
1073
|
-
if (to_add <= 0) return;
|
|
1074
|
-
// We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
|
|
1075
|
-
// The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
|
|
1076
|
-
cards_element_[removed_old_children ? "append" : (removed_old_children = true, "replaceChildren")](...Array.from({
|
|
1077
|
-
length: to_add
|
|
1078
|
-
}).map(()=>$57363319986950eb$var$cached_placeholder_element.cloneNode(true)));
|
|
1079
|
-
existing_num += to_add;
|
|
1080
|
-
}));
|
|
1081
|
-
}
|
|
1082
|
-
function $57363319986950eb$var$wrap_template_to_throw_into_error_boundary(template, root_in_root, on_finally) {
|
|
1083
|
-
return async (...args)=>{
|
|
1084
|
-
try {
|
|
1085
|
-
return await (0, $g9l4l$runWithOwner)(root_in_root, ()=>template(...args)) || [];
|
|
1086
|
-
} catch (e) {
|
|
1087
|
-
(0, $g9l4l$runWithOwner)(root_in_root, ()=>{
|
|
1088
|
-
// Throw in case of promise rejection, ultimately into ErrorBoundary
|
|
1089
|
-
throw e;
|
|
1090
|
-
});
|
|
1091
|
-
return [];
|
|
1092
|
-
} finally{
|
|
1093
|
-
on_finally?.();
|
|
1094
|
-
}
|
|
1095
|
-
};
|
|
1096
1227
|
}
|
|
1097
1228
|
|
|
1098
1229
|
|
|
@@ -1681,7 +1812,7 @@ function $9e6544e509214c47$export$ca21a16d65b3dd8({ show_extras_: [get_show_extr
|
|
|
1681
1812
|
const $5be19bd31e1c92fe$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<form class="checkboxes"></form>`, 2);
|
|
1682
1813
|
const $5be19bd31e1c92fe$var$max_visible_without_collapsing = 7;
|
|
1683
1814
|
const $5be19bd31e1c92fe$var$show_non_collapsible_when_collapsed = 4;
|
|
1684
|
-
function $5be19bd31e1c92fe$export$dd948f91abc3a1c4({ filter_: filter_ , selected_filters_: [get_selected_filters, set_selected_filters] , i18n_: i18n_ , view_more_button_below_group_: [
|
|
1815
|
+
function $5be19bd31e1c92fe$export$dd948f91abc3a1c4({ filter_: filter_ , selected_filters_: [get_selected_filters, set_selected_filters] , i18n_: i18n_ , view_more_button_below_group_: [, set_view_more_button_below_group_] }) {
|
|
1685
1816
|
const existing_filter = (0, $g9l4l$createMemo)(()=>{
|
|
1686
1817
|
const { field: field , op: op } = filter_();
|
|
1687
1818
|
return get_selected_filters().find(({ field: checking_field , op: checking_op })=>checking_field === field && checking_op === op);
|
|
@@ -1762,7 +1893,7 @@ function $5be19bd31e1c92fe$export$dd948f91abc3a1c4({ filter_: filter_ , selected
|
|
|
1762
1893
|
...base_object,
|
|
1763
1894
|
data: [
|
|
1764
1895
|
...new FormData(form)
|
|
1765
|
-
].filter(([
|
|
1896
|
+
].filter(([, value])=>value === "on").map(([key])=>key)
|
|
1766
1897
|
};
|
|
1767
1898
|
const selected_filters = [
|
|
1768
1899
|
...get_selected_filters()
|
|
@@ -3996,7 +4127,10 @@ function $bf7fe049e78f975a$var$OpenSortingButton({ i18n_: i18n_ , get_current_so
|
|
|
3996
4127
|
(0, $g9l4l$setAttribute)(_el$12, "tabindex", tabindex_);
|
|
3997
4128
|
(0, $g9l4l$insert)(_el$13, (()=>{
|
|
3998
4129
|
const _c$ = (0, $g9l4l$memo)(()=>!!sorting_closed());
|
|
3999
|
-
return ()
|
|
4130
|
+
return ()=>// Show the title of the currently selected sorting when the sorting is closed, if there's currently a sorting selected
|
|
4131
|
+
// This is to balance that both it should be easy to find the sorting and to see what sorting currently is set
|
|
4132
|
+
// See issue description of https://gitlab.com/depict-ai/depict.ai/-/merge_requests/6537
|
|
4133
|
+
_c$() && meta_of_currently_selected_sorting_()?.title || i18n_.sorting_text_();
|
|
4000
4134
|
})());
|
|
4001
4135
|
(0, $g9l4l$insert)(_el$12, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
4002
4136
|
get when () {
|
|
@@ -4596,90 +4730,6 @@ function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklink
|
|
|
4596
4730
|
|
|
4597
4731
|
|
|
4598
4732
|
|
|
4599
|
-
|
|
4600
|
-
|
|
4601
|
-
function $cb20e79516018342$export$3945d6db2dfd3d12({ crumb_data_: crumb_data_ , query_id_: query_id_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , plp_results_: plp_results_ , router_: router_ }) {
|
|
4602
|
-
// If we just got opened in a new tab, clear filters instantly and remove the flag
|
|
4603
|
-
$cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
|
|
4604
|
-
plp_results_: plp_results_,
|
|
4605
|
-
local_filter_cache_: local_filter_cache_,
|
|
4606
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4607
|
-
selected_filters_: selected_filters_,
|
|
4608
|
-
i18n_: i18n_,
|
|
4609
|
-
router_: router_
|
|
4610
|
-
});
|
|
4611
|
-
// Code below is for when we're already open and the user navigates to a new category
|
|
4612
|
-
let previous_crumb_data = (0, $g9l4l$untrack)(crumb_data_);
|
|
4613
|
-
let query_id_when_we_got_previous_data = (0, $g9l4l$untrack)(query_id_);
|
|
4614
|
-
let allow_filter_clearing = true; // set to false when going backwards/forwards
|
|
4615
|
-
// temporarily disable filter clearing when going backwards/forwards
|
|
4616
|
-
const handler = ()=>allow_filter_clearing = false;
|
|
4617
|
-
window.addEventListener("popstate", handler); // popstate only gets called when using back/forwards button of browser or the history navigate to achieve the same, but not on pushState or replaceState
|
|
4618
|
-
(0, $g9l4l$onCleanup)(()=>window.removeEventListener("popstate", handler));
|
|
4619
|
-
(0, $g9l4l$createEffect)((0, $g9l4l$on)(crumb_data_, (0, $g9l4l$catchify)((new_crumb_data)=>{
|
|
4620
|
-
const query_id_of_new_data = query_id_();
|
|
4621
|
-
if (allow_filter_clearing && previous_crumb_data && new_crumb_data && query_id_of_new_data !== query_id_when_we_got_previous_data) {
|
|
4622
|
-
const previous_length = previous_crumb_data.length;
|
|
4623
|
-
const new_length = new_crumb_data.length;
|
|
4624
|
-
const went_upwards = new_length < previous_length;
|
|
4625
|
-
const went_downwards = previous_length < new_length;
|
|
4626
|
-
const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
|
|
4627
|
-
const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
|
|
4628
|
-
if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) {
|
|
4629
|
-
// We went sideways, not up or down. Clear filters.
|
|
4630
|
-
(0, $af89070cc0052779$export$8895d39404bd2bb1)({
|
|
4631
|
-
user_triggered_: false,
|
|
4632
|
-
i18n_: i18n_,
|
|
4633
|
-
also_clear_sorting_: false,
|
|
4634
|
-
selected_filters_: selected_filters_,
|
|
4635
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4636
|
-
local_filter_cache_: local_filter_cache_
|
|
4637
|
-
});
|
|
4638
|
-
// Also ensure we don't have `sideways_url_params_flag` set anymore
|
|
4639
|
-
$cb20e79516018342$var$delete_sideways_param_flag(router_);
|
|
4640
|
-
}
|
|
4641
|
-
}
|
|
4642
|
-
query_id_when_we_got_previous_data = query_id_of_new_data;
|
|
4643
|
-
previous_crumb_data = new_crumb_data;
|
|
4644
|
-
if (!allow_filter_clearing) allow_filter_clearing = true;
|
|
4645
|
-
})));
|
|
4646
|
-
}
|
|
4647
|
-
function $cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({ plp_results_: plp_results_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , router_: router_ }) {
|
|
4648
|
-
const tracking_function_for_plp_results = (0, $g9l4l$createReaction)(()=>{
|
|
4649
|
-
// On first rendering of the CategoryPage (after we have results), check if we got to this URL by going sideways in QuickLinks and clear filters with toast if so
|
|
4650
|
-
const had_flag = $cb20e79516018342$var$delete_sideways_param_flag(router_);
|
|
4651
|
-
if (!had_flag) return;
|
|
4652
|
-
(0, $g9l4l$dlog)("Flag to clear filters was set, clearing filters");
|
|
4653
|
-
(0, $g9l4l$queueMacroTask)(()=>{
|
|
4654
|
-
// Do it next task so that all the filters have time to populate
|
|
4655
|
-
(0, $af89070cc0052779$export$8895d39404bd2bb1)({
|
|
4656
|
-
user_triggered_: false,
|
|
4657
|
-
i18n_: i18n_,
|
|
4658
|
-
also_clear_sorting_: false,
|
|
4659
|
-
selected_filters_: selected_filters_,
|
|
4660
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4661
|
-
local_filter_cache_: local_filter_cache_
|
|
4662
|
-
});
|
|
4663
|
-
});
|
|
4664
|
-
});
|
|
4665
|
-
tracking_function_for_plp_results(plp_results_);
|
|
4666
|
-
}
|
|
4667
|
-
function $cb20e79516018342$var$delete_sideways_param_flag(router) {
|
|
4668
|
-
const url_object = new URL(location.href);
|
|
4669
|
-
const { searchParams: searchParams } = url_object;
|
|
4670
|
-
if (searchParams.get((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac)) !== "true") return false;
|
|
4671
|
-
searchParams.delete((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac));
|
|
4672
|
-
router.navigate_.go_to_({
|
|
4673
|
-
new_url_: url_object,
|
|
4674
|
-
is_replace_: true,
|
|
4675
|
-
force_spa_navigation_: true
|
|
4676
|
-
});
|
|
4677
|
-
return true;
|
|
4678
|
-
}
|
|
4679
|
-
|
|
4680
|
-
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
4733
|
const $f4d7f67154f032af$var$max_history_change_frequency = 300;
|
|
4684
4734
|
const $f4d7f67154f032af$var$api_max_products_per_request = 100;
|
|
4685
4735
|
function $f4d7f67154f032af$export$6e49da55e449af7c({ scroll_restoration_data_: [, set_scroll_restoration_data] , last_result_in_viewport_: [get_last_result_in_viewport_] , id_: id_ , can_write_scroll_restoration_: can_write_scroll_restoration_ }) {
|
|
@@ -4792,8 +4842,92 @@ let $01115659405f3c64$export$44dad306455dddf;
|
|
|
4792
4842
|
})($01115659405f3c64$export$44dad306455dddf || ($01115659405f3c64$export$44dad306455dddf = {}));
|
|
4793
4843
|
|
|
4794
4844
|
|
|
4845
|
+
|
|
4846
|
+
|
|
4847
|
+
|
|
4848
|
+
|
|
4849
|
+
function $cb20e79516018342$export$3945d6db2dfd3d12({ crumb_data_: crumb_data_ , query_id_: query_id_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , plp_results_: plp_results_ , router_: router_ }) {
|
|
4850
|
+
// If we just got opened in a new tab, clear filters instantly and remove the flag
|
|
4851
|
+
$cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
|
|
4852
|
+
plp_results_: plp_results_,
|
|
4853
|
+
local_filter_cache_: local_filter_cache_,
|
|
4854
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4855
|
+
selected_filters_: selected_filters_,
|
|
4856
|
+
i18n_: i18n_,
|
|
4857
|
+
router_: router_
|
|
4858
|
+
});
|
|
4859
|
+
// Code below is for when we're already open and the user navigates to a new category
|
|
4860
|
+
let previous_crumb_data = (0, $g9l4l$untrack)(crumb_data_);
|
|
4861
|
+
let query_id_when_we_got_previous_data = (0, $g9l4l$untrack)(query_id_);
|
|
4862
|
+
let allow_filter_clearing = true; // set to false when going backwards/forwards
|
|
4863
|
+
// temporarily disable filter clearing when going backwards/forwards
|
|
4864
|
+
const handler = ()=>allow_filter_clearing = false;
|
|
4865
|
+
window.addEventListener("popstate", handler); // popstate only gets called when using back/forwards button of browser or the history navigate to achieve the same, but not on pushState or replaceState
|
|
4866
|
+
(0, $g9l4l$onCleanup)(()=>window.removeEventListener("popstate", handler));
|
|
4867
|
+
(0, $g9l4l$createEffect)((0, $g9l4l$on)(crumb_data_, (0, $g9l4l$catchify)((new_crumb_data)=>{
|
|
4868
|
+
const query_id_of_new_data = query_id_();
|
|
4869
|
+
if (allow_filter_clearing && previous_crumb_data && new_crumb_data && query_id_of_new_data !== query_id_when_we_got_previous_data) {
|
|
4870
|
+
const previous_length = previous_crumb_data.length;
|
|
4871
|
+
const new_length = new_crumb_data.length;
|
|
4872
|
+
const went_upwards = new_length < previous_length;
|
|
4873
|
+
const went_downwards = previous_length < new_length;
|
|
4874
|
+
const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
|
|
4875
|
+
const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
|
|
4876
|
+
if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) {
|
|
4877
|
+
// We went sideways, not up or down. Clear filters.
|
|
4878
|
+
(0, $af89070cc0052779$export$8895d39404bd2bb1)({
|
|
4879
|
+
user_triggered_: false,
|
|
4880
|
+
i18n_: i18n_,
|
|
4881
|
+
also_clear_sorting_: false,
|
|
4882
|
+
selected_filters_: selected_filters_,
|
|
4883
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4884
|
+
local_filter_cache_: local_filter_cache_
|
|
4885
|
+
});
|
|
4886
|
+
// Also ensure we don't have `sideways_url_params_flag` set anymore
|
|
4887
|
+
$cb20e79516018342$var$delete_sideways_param_flag(router_);
|
|
4888
|
+
}
|
|
4889
|
+
}
|
|
4890
|
+
query_id_when_we_got_previous_data = query_id_of_new_data;
|
|
4891
|
+
previous_crumb_data = new_crumb_data;
|
|
4892
|
+
if (!allow_filter_clearing) allow_filter_clearing = true;
|
|
4893
|
+
})));
|
|
4894
|
+
}
|
|
4895
|
+
function $cb20e79516018342$var$clear_if_opened_new_tab_with_sideways_url_params_flag({ plp_results_: plp_results_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , router_: router_ }) {
|
|
4896
|
+
const tracking_function_for_plp_results = (0, $g9l4l$createReaction)(()=>{
|
|
4897
|
+
// On first rendering of the CategoryPage (after we have results), check if we got to this URL by going sideways in QuickLinks and clear filters with toast if so
|
|
4898
|
+
const had_flag = $cb20e79516018342$var$delete_sideways_param_flag(router_);
|
|
4899
|
+
if (!had_flag) return;
|
|
4900
|
+
(0, $g9l4l$dlog)("Flag to clear filters was set, clearing filters");
|
|
4901
|
+
(0, $g9l4l$queueMacroTask)(()=>{
|
|
4902
|
+
// Do it next task so that all the filters have time to populate
|
|
4903
|
+
(0, $af89070cc0052779$export$8895d39404bd2bb1)({
|
|
4904
|
+
user_triggered_: false,
|
|
4905
|
+
i18n_: i18n_,
|
|
4906
|
+
also_clear_sorting_: false,
|
|
4907
|
+
selected_filters_: selected_filters_,
|
|
4908
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4909
|
+
local_filter_cache_: local_filter_cache_
|
|
4910
|
+
});
|
|
4911
|
+
});
|
|
4912
|
+
});
|
|
4913
|
+
tracking_function_for_plp_results(plp_results_);
|
|
4914
|
+
}
|
|
4915
|
+
function $cb20e79516018342$var$delete_sideways_param_flag(router) {
|
|
4916
|
+
const url_object = new URL(location.href);
|
|
4917
|
+
const { searchParams: searchParams } = url_object;
|
|
4918
|
+
if (searchParams.get((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac)) !== "true") return false;
|
|
4919
|
+
searchParams.delete((0, $73294c7089bfc7c9$export$e2cf3f19dd3f8aac));
|
|
4920
|
+
router.navigate_.go_to_({
|
|
4921
|
+
new_url_: url_object,
|
|
4922
|
+
is_replace_: true,
|
|
4923
|
+
force_spa_navigation_: true
|
|
4924
|
+
});
|
|
4925
|
+
return true;
|
|
4926
|
+
}
|
|
4927
|
+
|
|
4928
|
+
|
|
4795
4929
|
const $1ae892b13d7746ab$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="product-count"> </div>`, 2), $1ae892b13d7746ab$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div></div>`, 2), $1ae892b13d7746ab$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-results-for-one-row"></div>`, 2), $1ae892b13d7746ab$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp category"><div class="listing-page"></div></div>`, 4);
|
|
4796
|
-
function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ ,
|
|
4930
|
+
function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ }) {
|
|
4797
4931
|
let results_for;
|
|
4798
4932
|
let only_show_filters_opener_;
|
|
4799
4933
|
let middle_elements_;
|
|
@@ -4803,12 +4937,6 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4803
4937
|
show_n_results_: incoming_i18n.show_n_products_,
|
|
4804
4938
|
no_results_text_: incoming_i18n.no_products_text_
|
|
4805
4939
|
};
|
|
4806
|
-
const tenant_object_ = new (0, $g9l4l$Tenant)({
|
|
4807
|
-
TENANT: (0, $g9l4l$untrack)(tenant_),
|
|
4808
|
-
MARKET: (0, $g9l4l$untrack)(market_),
|
|
4809
|
-
GA_ID: "",
|
|
4810
|
-
get_product_id: get_product_id_
|
|
4811
|
-
});
|
|
4812
4940
|
const [get_sorting] = current_sorting_;
|
|
4813
4941
|
const number_of_rendered_selected_filters_items_ = (0, $g9l4l$createSignal)(0);
|
|
4814
4942
|
const first_result_in_viewport_ = (0, $g9l4l$createSignal)();
|
|
@@ -5045,11 +5173,9 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
5045
5173
|
last_result_in_viewport_: last_result_in_viewport_,
|
|
5046
5174
|
scroll_restoration_data_: scroll_restoration_data_,
|
|
5047
5175
|
layout_options_: layout_options_,
|
|
5048
|
-
|
|
5176
|
+
product_card_template_: product_card_template_,
|
|
5049
5177
|
sort_or_filter_open_: sort_or_filter_open_,
|
|
5050
5178
|
desktop_filter_elements_: desktop_filter_elements_,
|
|
5051
|
-
tenant_object_: tenant_object_,
|
|
5052
|
-
type_for_tracking_: "category",
|
|
5053
5179
|
id_currently_querying_for_: query_id_,
|
|
5054
5180
|
no_results_options_: {
|
|
5055
5181
|
selected_filters_: selected_filters_,
|
|
@@ -5488,7 +5614,7 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
|
|
|
5488
5614
|
});
|
|
5489
5615
|
}
|
|
5490
5616
|
}
|
|
5491
|
-
function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_category , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template ,
|
|
5617
|
+
function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_category , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , show_breadcrumbs: show_breadcrumbs = true , show_quicklinks: show_quicklinks = true , category_title: category_title }) {
|
|
5492
5618
|
const shared_properties = $ec52ef1e6c117813$var$get_shared_properties(depict_category);
|
|
5493
5619
|
const grid_spacing_override = typeof grid_spacing === "string" ? {
|
|
5494
5620
|
grid_spacing: grid_spacing
|
|
@@ -5521,17 +5647,11 @@ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
5521
5647
|
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
5522
5648
|
selected_filters_: selected_filters_,
|
|
5523
5649
|
scroll_restoration_data_: scroll_restoration_data_,
|
|
5524
|
-
get_product_id_: get_product_id,
|
|
5525
5650
|
layout_options_: {
|
|
5526
5651
|
cols_at_size: (0, $b4e6a093ae83373b$export$6daf8749b65a1b77)(cols_at_size),
|
|
5527
5652
|
...grid_spacing_override
|
|
5528
5653
|
},
|
|
5529
|
-
|
|
5530
|
-
template: (display, info)=>{
|
|
5531
|
-
const is_placeholder = info.rendering_options.type === "placeholder";
|
|
5532
|
-
return product_card_template(is_placeholder ? null : display, info);
|
|
5533
|
-
}
|
|
5534
|
-
}
|
|
5654
|
+
product_card_template_: product_card_template
|
|
5535
5655
|
});
|
|
5536
5656
|
}, "Entire CategoryPage failed");
|
|
5537
5657
|
}
|
|
@@ -5937,22 +6057,48 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5937
6057
|
|
|
5938
6058
|
|
|
5939
6059
|
|
|
6060
|
+
|
|
6061
|
+
|
|
5940
6062
|
const $aee0c68312d971f4$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="cards"></div>`, 2), $aee0c68312d971f4$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="search-recs"><h3 class="search-recs-title"></h3></div>`, 4), $aee0c68312d971f4$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="show-more major" type="button"></button>`, 2);
|
|
5941
6063
|
const $aee0c68312d971f4$export$1c8c715550dc689d = 2;
|
|
5942
|
-
function $aee0c68312d971f4$export$7de92c4c2205ebf3({ depict_api_: depict_api_ , i18n_: i18n_ ,
|
|
5943
|
-
const [
|
|
5944
|
-
const
|
|
5945
|
-
const
|
|
5946
|
-
const
|
|
6064
|
+
function $aee0c68312d971f4$export$7de92c4c2205ebf3({ depict_api_: depict_api_ , i18n_: i18n_ , search_query_base_: search_query_base_ , product_card_template_: product_card_template_ , showing_recommendation_rows_: showing_recommendation_rows_ , view_more_button_: view_more_button_ = true , layout_options_: layout_options_ }) {
|
|
6065
|
+
const [get_showing_recommendation_rows] = showing_recommendation_rows_; // We reset this in after_submit in search.tsx FYI
|
|
6066
|
+
const rows_object = view_more_button_ ? $aee0c68312d971f4$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
|
|
6067
|
+
const [recommendations_resource] = (0, $g9l4l$createResource)(search_query_base_, (query)=>depict_api_.get_recommended(query).then((r)=>r.displays));
|
|
6068
|
+
const is_showing_something = (0, $g9l4l$createMemo)(()=>recommendations_resource.loading || recommendations_resource()?.length);
|
|
6069
|
+
const num_placeholders_ = (0, $g9l4l$createMemo)(()=>(0, $9679915780ee67c0$export$6c9030e511152266) + get_showing_recommendation_rows() * Math.max(...layout_options_.cols_at_size.map(([per_column])=>per_column)));
|
|
6070
|
+
const cards = (()=>{
|
|
6071
|
+
const _el$ = $aee0c68312d971f4$var$_tmpl$.cloneNode(true);
|
|
6072
|
+
(0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Suspense), {
|
|
6073
|
+
get fallback () {
|
|
6074
|
+
return (0, $dc5df79ae78a9d00$export$f33414a4df0afd3f)({
|
|
6075
|
+
num_placeholders_: num_placeholders_,
|
|
6076
|
+
product_card_template_: product_card_template_
|
|
6077
|
+
});
|
|
6078
|
+
},
|
|
6079
|
+
get children () {
|
|
6080
|
+
return (()=>{
|
|
6081
|
+
// IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
|
|
6082
|
+
const displays_by_key_ = (0, $7a5055d6c11943a0$export$7f8bd308237ab5a5)((0, $g9l4l$createMemo)(()=>recommendations_resource() || []));
|
|
6083
|
+
return (0, $7a5055d6c11943a0$export$43f0fb951fcb0c54)({
|
|
6084
|
+
displays_by_key_: displays_by_key_,
|
|
6085
|
+
merchant_: (0, $g9l4l$createMemo)(()=>search_query_base_().tenant),
|
|
6086
|
+
market_: (0, $g9l4l$createMemo)(()=>search_query_base_().market),
|
|
6087
|
+
product_card_template_: product_card_template_
|
|
6088
|
+
});
|
|
6089
|
+
})();
|
|
6090
|
+
}
|
|
6091
|
+
}));
|
|
6092
|
+
return _el$;
|
|
6093
|
+
})();
|
|
6094
|
+
const search_recs_elements = (()=>{
|
|
5947
6095
|
const _el$2 = $aee0c68312d971f4$var$_tmpl$2.cloneNode(true), _el$3 = _el$2.firstChild;
|
|
5948
6096
|
(0, $g9l4l$insert)(_el$3, ()=>i18n_.search_recs_title_());
|
|
5949
6097
|
(0, $g9l4l$insert)(_el$2, (0, $ed06bb0bb83a46b3$export$a2cc176055f8f08), null);
|
|
5950
6098
|
(0, $g9l4l$insert)(_el$2, cards, null);
|
|
5951
6099
|
return _el$2;
|
|
5952
6100
|
})();
|
|
5953
|
-
|
|
5954
|
-
const rows_object = view_more_button_ ? $aee0c68312d971f4$var$make_state_saved_rows(showing_recommendation_rows_, i18n_) : "all";
|
|
5955
|
-
const cleanup_old_cards = [];
|
|
6101
|
+
// the cards element must have a parent for Layout to work, therefore we're inserting it into a div above
|
|
5956
6102
|
(0, $g9l4l$Layout)({
|
|
5957
6103
|
container_element: cards,
|
|
5958
6104
|
layout: "grid",
|
|
@@ -5962,77 +6108,11 @@ function $aee0c68312d971f4$export$7de92c4c2205ebf3({ depict_api_: depict_api_ ,
|
|
|
5962
6108
|
e,
|
|
5963
6109
|
"Layout failed"
|
|
5964
6110
|
], "error"));
|
|
5965
|
-
// copied from RecommendationGrid
|
|
5966
|
-
// convoluted lazy loading that
|
|
5967
|
-
// when the elements are in the DOM starts IntersectionObserver on whole grid
|
|
5968
|
-
// when grid intersects starts Lazyfier
|
|
5969
|
-
// this is because Lazyfier is fucking stupid
|
|
5970
|
-
(0, $g9l4l$observer).wait_for_element(cards).then((0, $g9l4l$catchify)((element)=>{
|
|
5971
|
-
let start_lazy_loading;
|
|
5972
|
-
const lazy_loading_promise = new Promise((r)=>start_lazy_loading = r);
|
|
5973
|
-
const lf = new (0, $g9l4l$Lazyfier)({
|
|
5974
|
-
only_load_intersecting: true,
|
|
5975
|
-
wait_for_dominsertion: lazy_loading_promise,
|
|
5976
|
-
ignore_data_urls: true,
|
|
5977
|
-
lazyfinder: {
|
|
5978
|
-
unload () {}
|
|
5979
|
-
}
|
|
5980
|
-
});
|
|
5981
|
-
lf.start_observing_for_new_children_(element);
|
|
5982
|
-
const i_o = new IntersectionObserver((0, $g9l4l$catchify)((records)=>{
|
|
5983
|
-
for (const record of records)if (record.intersectionRatio > 0) {
|
|
5984
|
-
start_lazy_loading();
|
|
5985
|
-
i_o.disconnect();
|
|
5986
|
-
return;
|
|
5987
|
-
}
|
|
5988
|
-
}));
|
|
5989
|
-
i_o.observe(cards);
|
|
5990
|
-
}));
|
|
5991
|
-
const deparallelized_recs_fetcher = (0, $g9l4l$deparallelize_no_drop)((0, $g9l4l$catchify)(async (base_query)=>{
|
|
5992
|
-
const recs_promise = depict_api_.get_recommended(base_query).then((r)=>r.displays);
|
|
5993
|
-
// create owner to run product cards with an Owner, so they know when they've gotten removed
|
|
5994
|
-
const [owner_for_cards, dispose_our_cards] = (0, $g9l4l$createRoot)((dispose)=>[
|
|
5995
|
-
(0, $g9l4l$getOwner)(),
|
|
5996
|
-
dispose
|
|
5997
|
-
]);
|
|
5998
|
-
const rendering_result = await (await (0, $g9l4l$make_placeholder_rr)({
|
|
5999
|
-
// render the max amount of elements that there could be, to make sure scroll restoration works (placeholders can't be shorter than actual content)
|
|
6000
|
-
num_items: (0, $9679915780ee67c0$export$6c9030e511152266) + (0, $g9l4l$untrack)(get_showing_recommendation_rows) * Math.max(...layout_options_.cols_at_size.map(([per_column])=>per_column))
|
|
6001
|
-
}))(tenant_object_, // @ts-ignore - make_placeholder_rr types is a touchy subject
|
|
6002
|
-
{
|
|
6003
|
-
type: "search_recs",
|
|
6004
|
-
recs: recs_promise,
|
|
6005
|
-
...rr_options_,
|
|
6006
|
-
...typeof rr_options_.template === "function" ? {
|
|
6007
|
-
template: (...args)=>(0, $g9l4l$runWithOwner)(owner_for_cards, ()=>// give template the possibility to know when it gets removed from the DOM by using solid-js onCleanup
|
|
6008
|
-
// @ts-ignore
|
|
6009
|
-
rr_options_.template(...args))
|
|
6010
|
-
} : {}
|
|
6011
|
-
});
|
|
6012
|
-
const { elements: elements , should_stay_inserted: should_stay_inserted } = rendering_result;
|
|
6013
|
-
let dead = false;
|
|
6014
|
-
while(on_next_render.length)on_next_render.pop()();
|
|
6015
|
-
on_next_render.push(()=>dead = true);
|
|
6016
|
-
if (!elements) {
|
|
6017
|
-
set_is_showing_something(false);
|
|
6018
|
-
return;
|
|
6019
|
-
}
|
|
6020
|
-
cards.replaceChildren(...elements);
|
|
6021
|
-
// Dispose the old cards just after the cards have been removed from the DOM
|
|
6022
|
-
cleanup_old_cards.forEach((cleanup_function)=>cleanup_function());
|
|
6023
|
-
cleanup_old_cards.push(dispose_our_cards); // push after calling, so that we don't instantly demolish ourselves lol
|
|
6024
|
-
set_is_showing_something(true);
|
|
6025
|
-
should_stay_inserted?.then((should)=>{
|
|
6026
|
-
if (!should && !dead /* just in case */ ) set_is_showing_something(false);
|
|
6027
|
-
});
|
|
6028
|
-
}));
|
|
6029
|
-
(0, $g9l4l$createRenderEffect)(()=>deparallelized_recs_fetcher(search_query_base_()));
|
|
6030
|
-
(0, $g9l4l$onCleanup)(()=>cleanup_old_cards.forEach((fn)=>fn())); // if everything gets cleaned up without new cards replacing the old ones, clean up the last cards
|
|
6031
6111
|
return (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
6032
6112
|
get when () {
|
|
6033
6113
|
return is_showing_something();
|
|
6034
6114
|
},
|
|
6035
|
-
children:
|
|
6115
|
+
children: search_recs_elements
|
|
6036
6116
|
});
|
|
6037
6117
|
}
|
|
6038
6118
|
function $aee0c68312d971f4$var$make_state_saved_rows([get_showing_recommendation_rows, set_showing_recommendation_rows], i18n_) {
|
|
@@ -6244,7 +6324,8 @@ async function $7f6ddd9a7e868c4d$export$e16630ecb9644a1c({ on_submit_with_unchan
|
|
|
6244
6324
|
|
|
6245
6325
|
|
|
6246
6326
|
const $d3c0043bb23a833f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="orig price"></span>`, 2), $d3c0043bb23a833f$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span></div><div class="price-container"><span class="price"></span></div></div></a>`, 16), $d3c0043bb23a833f$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="tagline"></div>`, 2);
|
|
6247
|
-
const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n
|
|
6327
|
+
const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n }, router_)=>{
|
|
6328
|
+
const search_result_id = (0, $g9l4l$createMemo)(()=>display_or_variant_container().search_result_id);
|
|
6248
6329
|
const display = (0, $g9l4l$createMemo)(()=>{
|
|
6249
6330
|
const display = display_or_variant_container();
|
|
6250
6331
|
// Support for backend's new display format
|
|
@@ -6262,19 +6343,19 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
|
|
|
6262
6343
|
});
|
|
6263
6344
|
const image_url = (0, $g9l4l$createMemo)(()=>display().image_url);
|
|
6264
6345
|
const contained_image = (0, $g9l4l$createMemo)(()=>(0, $g9l4l$ContainedImage)({
|
|
6346
|
+
loading: "lazy",
|
|
6265
6347
|
aspect_ratio: 1,
|
|
6266
6348
|
alt: "",
|
|
6267
6349
|
rendering_options: {},
|
|
6268
|
-
|
|
6269
|
-
"data-src": image_url(),
|
|
6350
|
+
"src": image_url(),
|
|
6270
6351
|
srcset_opts: {
|
|
6271
|
-
set_dataset:
|
|
6352
|
+
set_dataset: false
|
|
6272
6353
|
},
|
|
6273
|
-
|
|
6354
|
+
sizes: "0px"
|
|
6274
6355
|
}));
|
|
6275
6356
|
const is_sale = (0, $g9l4l$createMemo)(()=>display().sale_price !== display().original_price);
|
|
6276
6357
|
const href = (0, $g9l4l$createMemo)(()=>display().page_url);
|
|
6277
|
-
|
|
6358
|
+
return (()=>{
|
|
6278
6359
|
const _el$ = $d3c0043bb23a833f$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$4.nextSibling, _el$9 = _el$7.firstChild;
|
|
6279
6360
|
(0, $g9l4l$addEventListener)(_el$, "click", (0, $g9l4l$catchify)((event_)=>router_.navigate_.go_to_({
|
|
6280
6361
|
new_url_: href(),
|
|
@@ -6325,18 +6406,18 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
|
|
|
6325
6406
|
}), null);
|
|
6326
6407
|
(0, $g9l4l$insert)(_el$9, ()=>i18n.price_formatting_().post_, null);
|
|
6327
6408
|
(0, $g9l4l$effect)((_p$)=>{
|
|
6328
|
-
const _v$ = href(), _v$2 = !!is_sale();
|
|
6409
|
+
const _v$ = href(), _v$2 = search_result_id(), _v$3 = !!is_sale();
|
|
6329
6410
|
_v$ !== _p$._v$ && (0, $g9l4l$setAttribute)(_el$, "href", _p$._v$ = _v$);
|
|
6330
|
-
_v$2 !== _p$._v$2 &&
|
|
6411
|
+
_v$2 !== _p$._v$2 && (0, $g9l4l$setAttribute)(_el$, "data-search-result-id", _p$._v$2 = _v$2);
|
|
6412
|
+
_v$3 !== _p$._v$3 && _el$9.classList.toggle("sales-price", _p$._v$3 = _v$3);
|
|
6331
6413
|
return _p$;
|
|
6332
6414
|
}, {
|
|
6333
6415
|
_v$: undefined,
|
|
6334
|
-
_v$2: undefined
|
|
6416
|
+
_v$2: undefined,
|
|
6417
|
+
_v$3: undefined
|
|
6335
6418
|
});
|
|
6336
6419
|
return _el$;
|
|
6337
6420
|
})();
|
|
6338
|
-
// This solves a JSX type issue where the return value does not match with the explicit JSX.Element type for some reason
|
|
6339
|
-
return returnVal;
|
|
6340
6421
|
};
|
|
6341
6422
|
(0, $g9l4l$delegateEvents)([
|
|
6342
6423
|
"click"
|
|
@@ -6373,7 +6454,7 @@ function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
|
|
|
6373
6454
|
}));
|
|
6374
6455
|
const sliced_displays = (0, $g9l4l$createMemo)(()=>search_results()?.displays?.slice(0, max_cards));
|
|
6375
6456
|
let placeholder;
|
|
6376
|
-
|
|
6457
|
+
return (()=>{
|
|
6377
6458
|
const _el$ = $d811ce622b5b7626$var$_tmpl$.cloneNode(true);
|
|
6378
6459
|
(0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
6379
6460
|
get when () {
|
|
@@ -6391,8 +6472,8 @@ function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
|
|
|
6391
6472
|
get each () {
|
|
6392
6473
|
return sliced_displays();
|
|
6393
6474
|
},
|
|
6394
|
-
children: (d, i)
|
|
6395
|
-
render_instant_card_ ? (0, $g9l4l$createMemo)(()=>render_instant_card_(d(), {
|
|
6475
|
+
children: (d, i)=>{
|
|
6476
|
+
const card = render_instant_card_ ? (0, $g9l4l$createMemo)(()=>render_instant_card_(d(), {
|
|
6396
6477
|
index: i,
|
|
6397
6478
|
i18n: (0, $589fd8dc82a78e48$export$27b710c08412a7ad)(i18n_),
|
|
6398
6479
|
merchant: tenant_(),
|
|
@@ -6402,79 +6483,14 @@ function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
|
|
|
6402
6483
|
i18n: i18n_,
|
|
6403
6484
|
merchant: tenant_(),
|
|
6404
6485
|
market: market_()
|
|
6405
|
-
}, router_)
|
|
6486
|
+
}, router_);
|
|
6487
|
+
return card;
|
|
6488
|
+
}
|
|
6406
6489
|
});
|
|
6407
6490
|
}
|
|
6408
6491
|
}));
|
|
6409
6492
|
return _el$;
|
|
6410
6493
|
})();
|
|
6411
|
-
new (0, $g9l4l$Lazyfier)({
|
|
6412
|
-
container: container,
|
|
6413
|
-
lazyfinder: {
|
|
6414
|
-
unload () {}
|
|
6415
|
-
},
|
|
6416
|
-
ignore_data_urls: true
|
|
6417
|
-
});
|
|
6418
|
-
return container;
|
|
6419
|
-
}
|
|
6420
|
-
function $d811ce622b5b7626$var$track_elements(display, index, elements, tenant, market) {
|
|
6421
|
-
const type = "instant_result";
|
|
6422
|
-
const unwrapped_elements = $d811ce622b5b7626$var$unwrap_solid_jsx_element(elements);
|
|
6423
|
-
const disconnectors = [];
|
|
6424
|
-
(0, $g9l4l$createComputed)(()=>{
|
|
6425
|
-
let stop = false;
|
|
6426
|
-
const modern_or_legacy_d = display(); // For every display
|
|
6427
|
-
const d = "variant_index" in modern_or_legacy_d ? modern_or_legacy_d.variant_displays[modern_or_legacy_d.variant_index] : modern_or_legacy_d;
|
|
6428
|
-
const t = tenant(); // and tenant
|
|
6429
|
-
const m = market(); // / market combination
|
|
6430
|
-
const click_handler = ()=>{
|
|
6431
|
-
(0, $g9l4l$depict_click)({
|
|
6432
|
-
tenant: (0, $g9l4l$untrack)(tenant),
|
|
6433
|
-
market: (0, $g9l4l$untrack)(market),
|
|
6434
|
-
...d,
|
|
6435
|
-
click_location: type + "_" + (index + 1),
|
|
6436
|
-
recommendation_type: type
|
|
6437
|
-
});
|
|
6438
|
-
localStorage.setItem(`depict_attribution_${d.product_id}`, d.search_result_id);
|
|
6439
|
-
};
|
|
6440
|
-
while(disconnectors.length)// disconnect stuff from old display
|
|
6441
|
-
disconnectors.pop()();
|
|
6442
|
-
disconnectors.push(()=>stop = true);
|
|
6443
|
-
(0, $g9l4l$createComputed)(()=>{
|
|
6444
|
-
if (stop) return;
|
|
6445
|
-
const filtered_els = unwrapped_elements().filter((el)=>el instanceof Element);
|
|
6446
|
-
for (const element of filtered_els){
|
|
6447
|
-
element.addEventListener("click", click_handler);
|
|
6448
|
-
disconnectors.push((0, $g9l4l$impression_track_element)({
|
|
6449
|
-
element: element,
|
|
6450
|
-
data: {
|
|
6451
|
-
tenant: t,
|
|
6452
|
-
market: m,
|
|
6453
|
-
recommendation_type: type,
|
|
6454
|
-
recommendation_id: d.recommendation_id,
|
|
6455
|
-
product_id: d.product_id,
|
|
6456
|
-
entity_price: d.entity_price
|
|
6457
|
-
}
|
|
6458
|
-
}), ()=>element.removeEventListener("click", click_handler));
|
|
6459
|
-
}
|
|
6460
|
-
(0, $g9l4l$add_new_tab_listener)(filtered_els, d, 1, (disconnector)=>disconnectors.push(disconnector));
|
|
6461
|
-
});
|
|
6462
|
-
});
|
|
6463
|
-
return elements;
|
|
6464
|
-
}
|
|
6465
|
-
function $d811ce622b5b7626$var$unwrap_solid_jsx_element(elements) {
|
|
6466
|
-
// FYI this probably doesn't work on hugely deep nestings or large amount of elements
|
|
6467
|
-
return (0, $g9l4l$createMemo)(()=>$d811ce622b5b7626$var$unwrapping_helper(elements));
|
|
6468
|
-
}
|
|
6469
|
-
function $d811ce622b5b7626$var$unwrapping_helper(elements) {
|
|
6470
|
-
const result = [];
|
|
6471
|
-
if (Array.isArray(elements)) for(let i = 0; i < elements.length; i++){
|
|
6472
|
-
const element = elements[i];
|
|
6473
|
-
result.push(...$d811ce622b5b7626$var$unwrapping_helper(element));
|
|
6474
|
-
}
|
|
6475
|
-
else if (typeof elements == "function") result.push(...$d811ce622b5b7626$var$unwrapping_helper(elements()));
|
|
6476
|
-
else if (elements != undefined && typeof elements != "boolean") result.push(elements);
|
|
6477
|
-
return result;
|
|
6478
6494
|
}
|
|
6479
6495
|
|
|
6480
6496
|
|
|
@@ -7515,13 +7531,7 @@ function $57ec75eac12fe1fc$export$9dd50d35b9d94fdf({ get_search_query_: get_sear
|
|
|
7515
7531
|
|
|
7516
7532
|
const $b76e8f62b1f313ef$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-results-for-one-row"></div>`, 2), $b76e8f62b1f313ef$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"><div class="listing-page"></div></div>`, 4);
|
|
7517
7533
|
function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
|
|
7518
|
-
const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , get_search_query_: get_search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ ,
|
|
7519
|
-
const tenant_object_ = new (0, $g9l4l$Tenant)({
|
|
7520
|
-
TENANT: (0, $g9l4l$untrack)(tenant_),
|
|
7521
|
-
MARKET: (0, $g9l4l$untrack)(market_),
|
|
7522
|
-
GA_ID: "",
|
|
7523
|
-
get_product_id: get_product_id_
|
|
7524
|
-
});
|
|
7534
|
+
const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , get_search_query_: get_search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , search_recs_view_more_: search_recs_view_more_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , product_card_template_: product_card_template_ } = opts;
|
|
7525
7535
|
const [get_sorting] = current_sorting_;
|
|
7526
7536
|
const all_products_loaded_ = (0, $g9l4l$createSignal)(false);
|
|
7527
7537
|
const [get_all_products_loaded, set_all_products_loaded] = all_products_loaded_;
|
|
@@ -7672,10 +7682,6 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
|
|
|
7672
7682
|
get_search_query_();
|
|
7673
7683
|
(0, $b760a1a8108897d0$export$c7e181728ad525f)(location);
|
|
7674
7684
|
});
|
|
7675
|
-
(0, $g9l4l$createComputed)(()=>{
|
|
7676
|
-
tenant_object_.tenant = tenant_object_.TENANT = tenant_();
|
|
7677
|
-
tenant_object_.market = tenant_object_.MARKET = market_();
|
|
7678
|
-
});
|
|
7679
7685
|
return [
|
|
7680
7686
|
document.createComment("Search page based on Depict SDK"),
|
|
7681
7687
|
(()=>{
|
|
@@ -7731,11 +7737,9 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
|
|
|
7731
7737
|
last_result_in_viewport_: last_result_in_viewport_,
|
|
7732
7738
|
scroll_restoration_data_: scroll_restoration_data_,
|
|
7733
7739
|
desktop_filter_elements_: desktop_filter_elements_,
|
|
7734
|
-
|
|
7740
|
+
product_card_template_: product_card_template_,
|
|
7735
7741
|
layout_options_: layout_options_,
|
|
7736
7742
|
sort_or_filter_open_: sort_or_filter_open_,
|
|
7737
|
-
tenant_object_: tenant_object_,
|
|
7738
|
-
type_for_tracking_: "search",
|
|
7739
7743
|
id_currently_querying_for_: get_search_query_,
|
|
7740
7744
|
no_results_options_: {
|
|
7741
7745
|
selected_filters_: selected_filters_,
|
|
@@ -7762,9 +7766,8 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
|
|
|
7762
7766
|
search_query_base_: search_query_base_,
|
|
7763
7767
|
layout_options_: recommendations_layout_options_,
|
|
7764
7768
|
showing_recommendation_rows_: showing_recommendation_rows_,
|
|
7765
|
-
rr_options_: recommendations_rr_options_,
|
|
7766
7769
|
view_more_button_: search_recs_view_more_,
|
|
7767
|
-
|
|
7770
|
+
product_card_template_: product_card_template_
|
|
7768
7771
|
});
|
|
7769
7772
|
}
|
|
7770
7773
|
});
|
|
@@ -8054,7 +8057,7 @@ function $540e930c58500cbe$var$get_shared_properties(depict_search) {
|
|
|
8054
8057
|
if (!shared_properties) throw new Error("Can't connect to provided DepictSearch instance");
|
|
8055
8058
|
return shared_properties;
|
|
8056
8059
|
}
|
|
8057
|
-
function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template ,
|
|
8060
|
+
function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , extra_depict_options: extra_depict_options }) {
|
|
8058
8061
|
const shared_properties = $540e930c58500cbe$var$get_shared_properties(depict_search);
|
|
8059
8062
|
const grid_spacing_override = typeof grid_spacing === "string" ? {
|
|
8060
8063
|
grid_spacing: grid_spacing
|
|
@@ -8121,15 +8124,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
8121
8124
|
height_: 12,
|
|
8122
8125
|
width_: 6.46
|
|
8123
8126
|
}),
|
|
8124
|
-
|
|
8125
|
-
template: (display, info)=>{
|
|
8126
|
-
const is_placeholder = info.rendering_options.type === "placeholder";
|
|
8127
|
-
return product_card_template(is_placeholder ? null : display, info);
|
|
8128
|
-
},
|
|
8129
|
-
pre_processors: extra_depict_options?.pre_processors,
|
|
8130
|
-
post_processors: extra_depict_options?.post_processors
|
|
8131
|
-
},
|
|
8132
|
-
get_product_id_: get_product_id
|
|
8127
|
+
product_card_template_: product_card_template
|
|
8133
8128
|
});
|
|
8134
8129
|
}, "Entire SearchPage failed");
|
|
8135
8130
|
}
|