@depict-ai/ui 0.0.64 → 0.0.66
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 +13 -7
- package/dist/main.js +487 -614
- package/dist/module.js +490 -618
- package/dist/typescript_schema/BaseSearchRequest.d.ts +197 -0
- package/dist/typescript_schema/ProductListingQueriesRequest.d.ts +14 -0
- package/dist/typescript_schema/ProductListingQueriesResponse.d.ts +10 -0
- package/dist/typescript_schema/ProductListingRequest.d.ts +221 -0
- package/dist/typescript_schema/ProductListingResponse.d.ts +232 -0
- package/dist/typescript_schema/RecommendResponse.d.ts +15 -0
- package/dist/typescript_schema/SearchRequest.d.ts +213 -0
- package/dist/typescript_schema/SearchResponse.d.ts +192 -0
- package/dist/typescript_schema/SearchSuggestionsRequest.d.ts +18 -0
- package/dist/typescript_schema/SearchSuggestionsResponse.d.ts +182 -0
- package/dist/typescript_schema/TrackV2Request.d.ts +115 -0
- package/package.json +5 -5
- package/dist/moduule.js +0 -7872
package/dist/module.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
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, Tenant as $g9l4l$Tenant,
|
|
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,
|
|
3
|
-
import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch,
|
|
4
|
-
import {decompressFromBase64 as $g9l4l$decompressFromBase64, compressToBase64 as $g9l4l$compressToBase64} from "lz-string";
|
|
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, Tenant as $g9l4l$Tenant, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, default_rr as $g9l4l$default_rr, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, Lazyfier as $g9l4l$Lazyfier, queueMacroTask as $g9l4l$queueMacroTask, deparallelize as $g9l4l$deparallelize, Rec_Renderer as $g9l4l$Rec_Renderer, 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, normal_get_product_id as $g9l4l$normal_get_product_id, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, make_placeholder_rr as $g9l4l$make_placeholder_rr, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, depict_click as $g9l4l$depict_click, impression_track_element as $g9l4l$impression_track_element, add_new_tab_listener as $g9l4l$add_new_tab_listener, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces, instant_exec_on_popstate_before_ipns_update as $g9l4l$instant_exec_on_popstate_before_ipns_update} 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, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, classList as $g9l4l$classList, memo as $g9l4l$memo, style as $g9l4l$style, 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, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createRenderEffect as $g9l4l$createRenderEffect, runWithOwner as $g9l4l$runWithOwner, createRoot as $g9l4l$createRoot, getOwner as $g9l4l$getOwner, createReaction as $g9l4l$createReaction, on as $g9l4l$on, ErrorBoundary as $g9l4l$ErrorBoundary, Index as $g9l4l$Index, For as $g9l4l$For} from "solid-js";
|
|
5
4
|
|
|
6
|
-
/*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.
|
|
5
|
+
/*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.66";
|
|
7
6
|
|
|
8
7
|
|
|
9
8
|
|
|
@@ -57,16 +56,14 @@ function $014a147d094b0d08$var$history_state_change(signals, entries, state) {
|
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
|
|
60
|
-
function $
|
|
61
|
-
const state = (0, $014a147d094b0d08$export$e183a13865960371)(
|
|
59
|
+
function $3075a4497054bec6$export$9862539c89138352(get_default_values) {
|
|
60
|
+
const state = (0, $014a147d094b0d08$export$e183a13865960371)(get_default_values());
|
|
62
61
|
const reset_state = ()=>{
|
|
63
|
-
const new_defaults =
|
|
62
|
+
const new_defaults = get_default_values();
|
|
64
63
|
for(const key in state){
|
|
65
64
|
const new_value = new_defaults[key];
|
|
66
65
|
state[key][1](new_value);
|
|
67
66
|
}
|
|
68
|
-
set_current_sorting();
|
|
69
|
-
if (get_selected_filters().length > 0) set_selected_filters([]);
|
|
70
67
|
};
|
|
71
68
|
return [
|
|
72
69
|
reset_state,
|
|
@@ -124,8 +121,9 @@ class $3846bb34098c738f$export$e015ed2f2950f2e3 {
|
|
|
124
121
|
async #cached_post_request(endpoint1, input_req, fallback_response) {
|
|
125
122
|
const cache_obj = this.#get_cache_obj_for_endpoint(endpoint1);
|
|
126
123
|
const with_ids = $3846bb34098c738f$var$add_ids_to_request(input_req);
|
|
127
|
-
const
|
|
128
|
-
|
|
124
|
+
const metaData = await this.#get_metadata?.();
|
|
125
|
+
const request = metaData ? Object.assign(with_ids, {
|
|
126
|
+
metadata: metaData
|
|
129
127
|
}) : with_ids;
|
|
130
128
|
const body = JSON.stringify((0, $g9l4l$sort_obj)(request));
|
|
131
129
|
const response_from_cache = cache_obj.cache_[body]?.deref?.();
|
|
@@ -789,6 +787,55 @@ function $ed06bb0bb83a46b3$export$a2cc176055f8f08() {
|
|
|
789
787
|
}
|
|
790
788
|
|
|
791
789
|
|
|
790
|
+
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
// Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
|
|
797
|
+
class $22d7fd594100c3d0$export$e1d52e4f0c7557a1 extends Error {
|
|
798
|
+
}
|
|
799
|
+
class $22d7fd594100c3d0$export$aa14a9f43128f61f extends $22d7fd594100c3d0$export$e1d52e4f0c7557a1 {
|
|
800
|
+
constructor(templateError){
|
|
801
|
+
super("Uncaught error in product card template", {
|
|
802
|
+
cause: templateError
|
|
803
|
+
});
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
const $a406ebe9523f192f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div></div>`, 2);
|
|
809
|
+
function $a406ebe9523f192f$export$b69d0d92862de18b(props) {
|
|
810
|
+
return (0, $g9l4l$ErrorBoundary)({
|
|
811
|
+
fallback (err, retry) {
|
|
812
|
+
const { message_: message_ , severity_: severity_ } = props;
|
|
813
|
+
let message = message_;
|
|
814
|
+
if (err instanceof (0, $22d7fd594100c3d0$export$aa14a9f43128f61f)) {
|
|
815
|
+
console.error(err.cause);
|
|
816
|
+
message = `${message}: ${err.message}`;
|
|
817
|
+
} else (0, $g9l4l$report)([
|
|
818
|
+
err,
|
|
819
|
+
message_
|
|
820
|
+
], severity_);
|
|
821
|
+
props.on_error_?.(retry);
|
|
822
|
+
return (()=>{
|
|
823
|
+
const _el$ = $a406ebe9523f192f$var$_tmpl$.cloneNode(true);
|
|
824
|
+
(0, $g9l4l$insert)(_el$, message);
|
|
825
|
+
(0, $g9l4l$effect)((_$p)=>(0, $g9l4l$classList)(_el$, Object.fromEntries(props.class_list_?.map((c)=>[
|
|
826
|
+
c,
|
|
827
|
+
true
|
|
828
|
+
]) || []), _$p));
|
|
829
|
+
return _el$;
|
|
830
|
+
})();
|
|
831
|
+
},
|
|
832
|
+
get children () {
|
|
833
|
+
return props.children;
|
|
834
|
+
}
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
|
|
838
|
+
|
|
792
839
|
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);
|
|
793
840
|
let $57363319986950eb$var$cached_placeholder_element;
|
|
794
841
|
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_: scroll_restoration_data_ , no_results_options_: no_results_options_ , desktop_filter_elements_: desktop_filter_elements_ , sort_or_filter_open_: sort_or_filter_open_ , rr_options_: rr_options_ , layout_options_: layout_options_ , tenant_object_: tenant_object_ , type_for_tracking_: type_for_tracking_ , id_currently_querying_for_: id_currently_querying_for_ }) {
|
|
@@ -825,8 +872,7 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
825
872
|
recs: current_results.displays,
|
|
826
873
|
...rr_options_,
|
|
827
874
|
...typeof rr_options_.template === "function" ? {
|
|
828
|
-
template:
|
|
829
|
-
rr_options_.template(...args))
|
|
875
|
+
template: $57363319986950eb$var$wrap_template_to_throw_into_error_boundary(rr_options_.template, owner_for_cards)
|
|
830
876
|
} : {},
|
|
831
877
|
post_processors: [
|
|
832
878
|
...rr_options_.post_processors || [],
|
|
@@ -871,86 +917,101 @@ function $57363319986950eb$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
871
917
|
return (0, $g9l4l$createComponent)((0, $a20b0ecfca7ab32d$export$ef6006467f04ee41), no_results_options_);
|
|
872
918
|
},
|
|
873
919
|
get children () {
|
|
874
|
-
return ((
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
plp_results_(); // re-run render_and_insert_results when results change
|
|
919
|
-
render_and_insert_results(cards, owner_);
|
|
920
|
-
}
|
|
921
|
-
}));
|
|
922
|
-
// copied from RecommendationGrid
|
|
923
|
-
// convoluted lazy loading that
|
|
924
|
-
// when the elements are in the DOM starts IntersectionObserver on whole grid
|
|
925
|
-
// when grid intersects starts Lazyfier
|
|
926
|
-
// this is because Lazyfier is fucking stupid
|
|
927
|
-
(0, $g9l4l$observer).wait_for_element(cards).then((0, $g9l4l$catchify)((element)=>{
|
|
928
|
-
let start_lazy_loading;
|
|
929
|
-
const lazy_loading_promise = new Promise((r)=>start_lazy_loading = r);
|
|
930
|
-
const lf = new (0, $g9l4l$Lazyfier)({
|
|
931
|
-
only_load_intersecting: true,
|
|
932
|
-
wait_for_dominsertion: lazy_loading_promise,
|
|
933
|
-
ignore_data_urls: true,
|
|
934
|
-
lazyfinder: {
|
|
935
|
-
unload () {}
|
|
936
|
-
}
|
|
920
|
+
return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
|
|
921
|
+
severity_: "error",
|
|
922
|
+
// More granular error handling
|
|
923
|
+
// This _also_ fails when a product card rendering fails due to the runWithOwner with a root that was created inside the "root"/"context" of this ErrorBoundary
|
|
924
|
+
on_error_: (retry)=>{
|
|
925
|
+
// re-try / reset ErrorBoundary next time we're getting product cards
|
|
926
|
+
const track = (0, $g9l4l$createReaction)(retry);
|
|
927
|
+
track(plp_results_);
|
|
928
|
+
},
|
|
929
|
+
class_list_: [
|
|
930
|
+
"cards"
|
|
931
|
+
],
|
|
932
|
+
// So that the styling looks pretty when we've failed
|
|
933
|
+
message_: "Result rendering failed",
|
|
934
|
+
get children () {
|
|
935
|
+
const random_id = (0, $g9l4l$make_random_classname)();
|
|
936
|
+
const selector_beginning = `.depict.plp #${random_id}>`;
|
|
937
|
+
const cards = (()=>{
|
|
938
|
+
const _el$2 = $57363319986950eb$var$_tmpl$2.cloneNode(true);
|
|
939
|
+
(0, $g9l4l$setAttribute)(_el$2, "id", random_id);
|
|
940
|
+
return _el$2;
|
|
941
|
+
})();
|
|
942
|
+
const style = document.createElement("style");
|
|
943
|
+
(0, $g9l4l$createRenderEffect)(()=>{
|
|
944
|
+
// Add grid styling that changes when filters get opened/closed
|
|
945
|
+
const when_filters_closed_cols = layout_options_.cols_at_size;
|
|
946
|
+
const cols_at_size = sort_or_filter_open_() ? when_filters_closed_cols.map((row)=>{
|
|
947
|
+
const [num_cols_default, , , , override_cols] = row;
|
|
948
|
+
const cloned_row = [
|
|
949
|
+
...row
|
|
950
|
+
];
|
|
951
|
+
// @ts-ignore
|
|
952
|
+
cloned_row[0] = num_cols_default - 1;
|
|
953
|
+
if (override_cols) // @ts-ignore
|
|
954
|
+
cloned_row[4] = {
|
|
955
|
+
overrides: Object.fromEntries(Object.entries(override_cols.overrides).map(([row, column])=>[
|
|
956
|
+
row,
|
|
957
|
+
column - 1
|
|
958
|
+
]))
|
|
959
|
+
};
|
|
960
|
+
return cloned_row;
|
|
961
|
+
}) : when_filters_closed_cols;
|
|
962
|
+
const css = (0, $g9l4l$n_col_styling_with_dist)(selector_beginning, layout_options_.grid_spacing, cols_at_size, "grid", layout_options_.override_vertical_spacing);
|
|
963
|
+
style.replaceChildren(css);
|
|
937
964
|
});
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
965
|
+
(0, $g9l4l$createRenderEffect)(// render placeholders / product cards
|
|
966
|
+
(0, $g9l4l$catchify)(async ()=>{
|
|
967
|
+
const owner_ = (0, $g9l4l$getOwner)();
|
|
968
|
+
if (is_loading()) await $57363319986950eb$var$insert_placeholders({
|
|
969
|
+
scroll_restoration_data_: scroll_restoration_data_,
|
|
970
|
+
id_currently_querying_for_: id_currently_querying_for_,
|
|
971
|
+
rr_options_: rr_options_,
|
|
972
|
+
tenant_object_: tenant_object_,
|
|
973
|
+
min_products_to_fetch_: min_products_to_fetch_,
|
|
974
|
+
owner_: owner_,
|
|
975
|
+
cards_element_: cards
|
|
976
|
+
});
|
|
977
|
+
else if (!has_no_results_or_failed()) {
|
|
978
|
+
plp_results_(); // re-run render_and_insert_results when results change
|
|
979
|
+
render_and_insert_results(cards, owner_);
|
|
944
980
|
}
|
|
945
981
|
}));
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
982
|
+
// copied from RecommendationGrid
|
|
983
|
+
// convoluted lazy loading that
|
|
984
|
+
// when the elements are in the DOM starts IntersectionObserver on whole grid
|
|
985
|
+
// when grid intersects starts Lazyfier
|
|
986
|
+
// this is because Lazyfier is fucking stupid
|
|
987
|
+
(0, $g9l4l$observer).wait_for_element(cards).then((0, $g9l4l$catchify)((element)=>{
|
|
988
|
+
let start_lazy_loading;
|
|
989
|
+
const lazy_loading_promise = new Promise((r)=>start_lazy_loading = r);
|
|
990
|
+
const lf = new (0, $g9l4l$Lazyfier)({
|
|
991
|
+
only_load_intersecting: true,
|
|
992
|
+
wait_for_dominsertion: lazy_loading_promise,
|
|
993
|
+
ignore_data_urls: true,
|
|
994
|
+
lazyfinder: {
|
|
995
|
+
unload () {}
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
lf.start_observing_for_new_children_(element);
|
|
999
|
+
const i_o = new IntersectionObserver((0, $g9l4l$catchify)((records)=>{
|
|
1000
|
+
for (const record of records)if (record.intersectionRatio > 0) {
|
|
1001
|
+
start_lazy_loading();
|
|
1002
|
+
i_o.disconnect();
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
}));
|
|
1006
|
+
i_o.observe(cards);
|
|
1007
|
+
}));
|
|
1008
|
+
return [
|
|
1009
|
+
(0, $ed06bb0bb83a46b3$export$a2cc176055f8f08)(),
|
|
1010
|
+
cards,
|
|
1011
|
+
style
|
|
1012
|
+
];
|
|
1013
|
+
}
|
|
1014
|
+
});
|
|
954
1015
|
}
|
|
955
1016
|
}), null);
|
|
956
1017
|
(0, $g9l4l$insert)(_el$, desktop_filter_elements_, null);
|
|
@@ -967,19 +1028,18 @@ async function $57363319986950eb$var$insert_placeholders({ scroll_restoration_da
|
|
|
967
1028
|
let existing_num = 0;
|
|
968
1029
|
let removed_old_children = false;
|
|
969
1030
|
if (!$57363319986950eb$var$cached_placeholder_element) {
|
|
1031
|
+
const [dispose_card, root_in_root] = (0, $g9l4l$createRoot)((dispose)=>[
|
|
1032
|
+
dispose,
|
|
1033
|
+
(0, $g9l4l$getOwner)()
|
|
1034
|
+
]);
|
|
970
1035
|
const { elements: elements } = await (0, $g9l4l$default_rr)(tenant_object_, {
|
|
971
1036
|
...rr_options_,
|
|
972
1037
|
type: "placeholder",
|
|
973
1038
|
pre_processors: [],
|
|
974
1039
|
post_processors: [],
|
|
975
1040
|
...typeof rr_options_.template === "function" ? {
|
|
976
|
-
template: (
|
|
977
|
-
|
|
978
|
-
return await rr_options_.template(...args);
|
|
979
|
-
} finally{
|
|
980
|
-
(0, $g9l4l$queueMacroTask)((0, $g9l4l$catchify)(dispose)); // we just want it cloned and dead
|
|
981
|
-
}
|
|
982
|
-
})
|
|
1041
|
+
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
|
|
1042
|
+
)
|
|
983
1043
|
} : {},
|
|
984
1044
|
recs: [
|
|
985
1045
|
{
|
|
@@ -995,13 +1055,28 @@ async function $57363319986950eb$var$insert_placeholders({ scroll_restoration_da
|
|
|
995
1055
|
const to_add = num_placeholders() - existing_num;
|
|
996
1056
|
if (to_add <= 0) return;
|
|
997
1057
|
// 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.
|
|
998
|
-
// 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
|
|
1058
|
+
// 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.
|
|
999
1059
|
cards_element_[removed_old_children ? "append" : (removed_old_children = true, "replaceChildren")](...Array.from({
|
|
1000
1060
|
length: to_add
|
|
1001
1061
|
}).map(()=>$57363319986950eb$var$cached_placeholder_element.cloneNode(true)));
|
|
1002
1062
|
existing_num += to_add;
|
|
1003
1063
|
}));
|
|
1004
1064
|
}
|
|
1065
|
+
function $57363319986950eb$var$wrap_template_to_throw_into_error_boundary(template, root_in_root, on_finally) {
|
|
1066
|
+
return async (...args)=>{
|
|
1067
|
+
try {
|
|
1068
|
+
return await (0, $g9l4l$runWithOwner)(root_in_root, ()=>template(...args)) || [];
|
|
1069
|
+
} catch (e) {
|
|
1070
|
+
(0, $g9l4l$runWithOwner)(root_in_root, ()=>{
|
|
1071
|
+
// Throw in case of promise rejection, ultimately into ErrorBoundary
|
|
1072
|
+
throw e;
|
|
1073
|
+
});
|
|
1074
|
+
return [];
|
|
1075
|
+
} finally{
|
|
1076
|
+
on_finally?.();
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
}
|
|
1005
1080
|
|
|
1006
1081
|
|
|
1007
1082
|
|
|
@@ -2637,7 +2712,7 @@ function $b114513503b25433$export$82ed4b28ecb67608({ filter_: filter_ , selected
|
|
|
2637
2712
|
// lighten or darken (+/- 10) depending on it's over or under 50 lightness
|
|
2638
2713
|
// lighten under 25 lightness by 20
|
|
2639
2714
|
const target_lightness = is_hovered ? is_light ? lightness() - 10 : lightness() < 25 ? lightness() + 20 : lightness() + 10 : lightness();
|
|
2640
|
-
classList.toggle("check-dark",
|
|
2715
|
+
classList.toggle("check-dark", $b114513503b25433$var$black_contrast_better(hue(), saturation(), lightness())); // Decide between black/white checkmark based on which one has better contrast according to WCAG contrast guidelines
|
|
2641
2716
|
style.backgroundColor = `hsl(${hue()}, ${saturation()}%, ${target_lightness}%)`;
|
|
2642
2717
|
}
|
|
2643
2718
|
});
|
|
@@ -2734,6 +2809,15 @@ function $b114513503b25433$export$82ed4b28ecb67608({ filter_: filter_ , selected
|
|
|
2734
2809
|
return _el$;
|
|
2735
2810
|
})();
|
|
2736
2811
|
}
|
|
2812
|
+
function $b114513503b25433$var$black_contrast_better(hue, saturation, lightness) {
|
|
2813
|
+
const as_rgb = (0, $g9l4l$hsl_to_rgb)(hue, saturation, lightness);
|
|
2814
|
+
const luminance_color = (0, $g9l4l$relative_luminance_from_rgb)(...as_rgb);
|
|
2815
|
+
const luminance_white = 1;
|
|
2816
|
+
const luminance_black = 0;
|
|
2817
|
+
const contrast_ratio_if_white = (luminance_white + 0.05) / (luminance_color + 0.05);
|
|
2818
|
+
const contrast_ratio_if_black = (luminance_color + 0.05) / (luminance_black + 0.05);
|
|
2819
|
+
return contrast_ratio_if_black > contrast_ratio_if_white;
|
|
2820
|
+
}
|
|
2737
2821
|
|
|
2738
2822
|
|
|
2739
2823
|
var $7b224b353182ce9a$export$2e2bcd8739ae039 = {
|
|
@@ -2749,6 +2833,156 @@ var $7b224b353182ce9a$export$2e2bcd8739ae039 = {
|
|
|
2749
2833
|
|
|
2750
2834
|
|
|
2751
2835
|
|
|
2836
|
+
function $dd3727f29e682893$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
|
|
2837
|
+
let last_remote_state;
|
|
2838
|
+
(0, $g9l4l$createComputed)(()=>{
|
|
2839
|
+
const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
|
|
2840
|
+
JSON.stringify([
|
|
2841
|
+
filter.field,
|
|
2842
|
+
filter.op,
|
|
2843
|
+
filter?.meta?.type
|
|
2844
|
+
]),
|
|
2845
|
+
filter
|
|
2846
|
+
]) || []);
|
|
2847
|
+
const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
|
|
2848
|
+
JSON.stringify([
|
|
2849
|
+
filter.field,
|
|
2850
|
+
filter.op,
|
|
2851
|
+
filter?.meta?.type
|
|
2852
|
+
]),
|
|
2853
|
+
filter
|
|
2854
|
+
]));
|
|
2855
|
+
const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
|
|
2856
|
+
JSON.stringify([
|
|
2857
|
+
filter_obj.field,
|
|
2858
|
+
filter_obj.op
|
|
2859
|
+
]),
|
|
2860
|
+
filter_obj
|
|
2861
|
+
]));
|
|
2862
|
+
const new_local_filter_state = [];
|
|
2863
|
+
// we want to be as close as possible to available_filters_ in local_filters except that we want to keep values from previous available_filters_ as long as they're selected
|
|
2864
|
+
for (const filter_id of [
|
|
2865
|
+
...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
|
|
2866
|
+
...Object.keys(remote_filters)
|
|
2867
|
+
]){
|
|
2868
|
+
const local_filter = local_filters[filter_id];
|
|
2869
|
+
const remote_filter = remote_filters[filter_id];
|
|
2870
|
+
const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
|
|
2871
|
+
if (!remote_filter) // check if this filter is selected, if it is just take the local one but set counts to 0 and remove non-selected options
|
|
2872
|
+
{
|
|
2873
|
+
if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($dd3727f29e682893$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
|
|
2874
|
+
} else if (!local_filter) // just take the remote one
|
|
2875
|
+
new_local_filter_state.push(remote_filter);
|
|
2876
|
+
else {
|
|
2877
|
+
// both exist, merge them if needed
|
|
2878
|
+
const remote_meta = remote_filter.meta;
|
|
2879
|
+
const local_meta = local_filter.meta;
|
|
2880
|
+
const this_applied_filter = selected_filters[filter_id_without_meta_type];
|
|
2881
|
+
if (!remote_meta || !local_meta || !("values" in remote_meta) || !("values" in local_meta) || !Array.isArray(this_applied_filter?.data)) // can't or shouldn't be merged due to not being selected, just take remote one
|
|
2882
|
+
new_local_filter_state.push(remote_filter);
|
|
2883
|
+
else {
|
|
2884
|
+
const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
|
|
2885
|
+
JSON.stringify(value),
|
|
2886
|
+
{
|
|
2887
|
+
value_: value,
|
|
2888
|
+
count_: remote_meta.counts?.[index],
|
|
2889
|
+
name_: remote_meta.names?.[index]
|
|
2890
|
+
}
|
|
2891
|
+
]));
|
|
2892
|
+
const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
|
|
2893
|
+
JSON.stringify(value),
|
|
2894
|
+
{
|
|
2895
|
+
value_: value,
|
|
2896
|
+
count_: 0,
|
|
2897
|
+
name_: local_meta.names?.[index]
|
|
2898
|
+
}
|
|
2899
|
+
]));
|
|
2900
|
+
const new_data = [
|
|
2901
|
+
...Object.keys(data_objs_in_local).filter((key)=>{
|
|
2902
|
+
// put data entries that are selected and don't exist in new remote state first
|
|
2903
|
+
if (key in data_objs_in_remote) return false;
|
|
2904
|
+
const selected_values = this_applied_filter.data;
|
|
2905
|
+
return selected_values.some((value)=>{
|
|
2906
|
+
const is_equal = JSON.stringify(value) === key;
|
|
2907
|
+
if (is_equal) return true;
|
|
2908
|
+
if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
|
|
2909
|
+
// Very special case for hierarchical checkboxes - when a parent has all kids checked and a kid is deselected, the parent gets deselected. But since if it still has selected children we don't want to remove it from the filter state, even though it isn't selected, as the UI won't know the correct title of the parent category otherwise. This keeps it in that case.
|
|
2910
|
+
const selected_values = data_objs_in_local[key].value_;
|
|
2911
|
+
const values_length = value?.length;
|
|
2912
|
+
if (values_length > 1 && values_length - 1 === selected_values.length) {
|
|
2913
|
+
let is_parent = true;
|
|
2914
|
+
for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
|
|
2915
|
+
return is_parent;
|
|
2916
|
+
}
|
|
2917
|
+
}
|
|
2918
|
+
return false;
|
|
2919
|
+
});
|
|
2920
|
+
}).map((key)=>data_objs_in_local[key]),
|
|
2921
|
+
...Object.values(data_objs_in_remote)
|
|
2922
|
+
];
|
|
2923
|
+
const new_values = new_data.map(({ value_: value_ })=>value_);
|
|
2924
|
+
const result = {
|
|
2925
|
+
...remote_filter,
|
|
2926
|
+
meta: {
|
|
2927
|
+
...remote_filter.meta,
|
|
2928
|
+
values: new_values,
|
|
2929
|
+
names: new_data.map(({ name_: name_ })=>name_),
|
|
2930
|
+
counts: new_data.map(({ count_: count_ })=>count_)
|
|
2931
|
+
}
|
|
2932
|
+
};
|
|
2933
|
+
new_local_filter_state.push(result);
|
|
2934
|
+
}
|
|
2935
|
+
}
|
|
2936
|
+
}
|
|
2937
|
+
if (last_remote_state !== available_filters_() || // we HAVE to update the local filter state (it can contain same info but needs to be different object reference) every time the API state changes, otherwise the CheckboxHierarchicalFilter component doesn't update
|
|
2938
|
+
JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
|
|
2939
|
+
write_local_cache(new_local_filter_state);
|
|
2940
|
+
last_remote_state = available_filters_();
|
|
2941
|
+
});
|
|
2942
|
+
return read_local_cache;
|
|
2943
|
+
}
|
|
2944
|
+
/**
|
|
2945
|
+
* When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
|
|
2946
|
+
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
2947
|
+
*/ function $dd3727f29e682893$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
2948
|
+
const old_meta = local_filter_object.meta;
|
|
2949
|
+
const selected_filter_data = selected_filter.data;
|
|
2950
|
+
const modified_filter_object = {
|
|
2951
|
+
...local_filter_object
|
|
2952
|
+
};
|
|
2953
|
+
if (old_meta) {
|
|
2954
|
+
const new_meta = {
|
|
2955
|
+
...old_meta
|
|
2956
|
+
};
|
|
2957
|
+
modified_filter_object.meta = new_meta;
|
|
2958
|
+
// set counts to 0
|
|
2959
|
+
if ("counts" in new_meta) {
|
|
2960
|
+
const counts = new_meta.counts;
|
|
2961
|
+
if (counts) new_meta.counts = counts.map(()=>0);
|
|
2962
|
+
}
|
|
2963
|
+
if (Array.isArray(selected_filter_data) && "values" in new_meta) {
|
|
2964
|
+
// we have an array of values and want to strip the ones from the available ones that aren't selected
|
|
2965
|
+
const values = new_meta.values;
|
|
2966
|
+
if (Array.isArray(values)) {
|
|
2967
|
+
const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
|
|
2968
|
+
const indexes_to_remove = new Set();
|
|
2969
|
+
for(let i = 0; i < values.length; i++){
|
|
2970
|
+
const value = values[i];
|
|
2971
|
+
if (!jsond_set_values.includes(JSON.stringify(value))) // We want to remove the entry with this value from the filter object because it's not selected
|
|
2972
|
+
indexes_to_remove.add(i);
|
|
2973
|
+
}
|
|
2974
|
+
new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
|
|
2975
|
+
if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
|
|
2976
|
+
if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
|
|
2977
|
+
new_meta.counts.length -= indexes_to_remove.size;
|
|
2978
|
+
}
|
|
2979
|
+
}
|
|
2980
|
+
}
|
|
2981
|
+
return modified_filter_object;
|
|
2982
|
+
}
|
|
2983
|
+
|
|
2984
|
+
|
|
2985
|
+
|
|
2752
2986
|
|
|
2753
2987
|
|
|
2754
2988
|
|
|
@@ -2865,31 +3099,6 @@ function $a2432c33d88ec427$export$ab34afce88557c0e(props) {
|
|
|
2865
3099
|
|
|
2866
3100
|
|
|
2867
3101
|
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
const $a406ebe9523f192f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div></div>`, 2);
|
|
2871
|
-
function $a406ebe9523f192f$export$b69d0d92862de18b(props) {
|
|
2872
|
-
return (0, $g9l4l$ErrorBoundary)({
|
|
2873
|
-
fallback (err) {
|
|
2874
|
-
const { message_: message_ , severity_: severity_ } = props;
|
|
2875
|
-
(0, $g9l4l$report)([
|
|
2876
|
-
err,
|
|
2877
|
-
message_
|
|
2878
|
-
], severity_);
|
|
2879
|
-
return (()=>{
|
|
2880
|
-
const _el$ = $a406ebe9523f192f$var$_tmpl$.cloneNode(true);
|
|
2881
|
-
(0, $g9l4l$insert)(_el$, message_);
|
|
2882
|
-
return _el$;
|
|
2883
|
-
})();
|
|
2884
|
-
},
|
|
2885
|
-
get children () {
|
|
2886
|
-
return props.children;
|
|
2887
|
-
}
|
|
2888
|
-
});
|
|
2889
|
-
}
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
3102
|
const $8aff437d739a524d$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-collapsible"></div>`, 2), $8aff437d739a524d$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="clear-group"><span></span></button>`, 4), $8aff437d739a524d$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="view-more-clear"></div>`, 2), $8aff437d739a524d$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filter-collapsible-body"><div class="filter-part"></div></div>`, 4), $8aff437d739a524d$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<details class="filter-collapsible"></details>`, 2), $8aff437d739a524d$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<summary class="filter-group-summary"><div class="summary"><span></span><div class="selected-w-sign"></div></div></summary>`, 8), $8aff437d739a524d$var$_tmpl$7 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="ungrouped"></div>`, 2), $8aff437d739a524d$var$_tmpl$8 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="clear-all-filters major"></button>`, 2);
|
|
2894
3103
|
function $8aff437d739a524d$export$3f1a388cc0d8fed7(props) {
|
|
2895
3104
|
// Split like this to make placeholder wrapping more visible & this component is exported and used in MobileModal
|
|
@@ -2915,7 +3124,11 @@ function $8aff437d739a524d$export$3f1a388cc0d8fed7(props) {
|
|
|
2915
3124
|
});
|
|
2916
3125
|
}
|
|
2917
3126
|
function $8aff437d739a524d$var$ActualFilterBody(props) {
|
|
2918
|
-
const
|
|
3127
|
+
const modified_available_filters_with_selected_unexisting_ones_injected_from_local_state = (0, $dd3727f29e682893$export$b288c38ae3fddb56)({
|
|
3128
|
+
available_filters_: props.available_filters_,
|
|
3129
|
+
selected_filters_: props.selected_filters_,
|
|
3130
|
+
local_filter_cache_: props.local_filter_cache_
|
|
3131
|
+
});
|
|
2919
3132
|
const togglable_filters = (0, $g9l4l$createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>item?.meta?.group_title));
|
|
2920
3133
|
const untogglable_filters = (0, $g9l4l$createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>!item?.meta?.group_title));
|
|
2921
3134
|
const togglable_filters_grouped_by_collapsible = (0, $g9l4l$createMemo)(()=>{
|
|
@@ -3116,10 +3329,9 @@ function $8aff437d739a524d$var$ActualFilterBody(props) {
|
|
|
3116
3329
|
|
|
3117
3330
|
|
|
3118
3331
|
const $c23bd3d951eee1f2$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting-attributes"></div>`, 2), $c23bd3d951eee1f2$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting-direction"></div>`, 2), $c23bd3d951eee1f2$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div><div class="input-row"><input type="radio"><span class="custom-indicator"></span></div></div>`, 7), $c23bd3d951eee1f2$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div><label class="input-row"><input type="radio"><span class="custom-indicator"></span></label></div>`, 7);
|
|
3119
|
-
function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_:
|
|
3332
|
+
function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: current_sorting_ }) {
|
|
3120
3333
|
const title_radio_name = (0, $g9l4l$make_random_classname)();
|
|
3121
3334
|
const order_radio_name = (0, $g9l4l$make_random_classname)();
|
|
3122
|
-
const meta_of_currently_selected_sorting = (0, $g9l4l$createMemo)(()=>available_sortings_()?.find?.((sorting)=>sorting.field === get_current_sorting()?.field)?.meta);
|
|
3123
3335
|
return (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
3124
3336
|
get when () {
|
|
3125
3337
|
return available_sortings_()?.length;
|
|
@@ -3151,14 +3363,14 @@ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: availa
|
|
|
3151
3363
|
},
|
|
3152
3364
|
children: (item, index)=>{
|
|
3153
3365
|
const is_checked = (0, $g9l4l$createMemo)(()=>{
|
|
3154
|
-
const sort =
|
|
3366
|
+
const sort = current_sorting_[0]();
|
|
3155
3367
|
if (!sort) // if no sortings are selected, "select" first sort
|
|
3156
3368
|
return index === 0;
|
|
3157
3369
|
return sort.field === item().field && (sort.order === item().order || item().meta.values?.length > 1);
|
|
3158
3370
|
});
|
|
3159
3371
|
return /* wrapping div for flex gap polyfill scss mixin */ (()=>{
|
|
3160
3372
|
const _el$8 = $c23bd3d951eee1f2$var$_tmpl$4.cloneNode(true), _el$9 = _el$8.firstChild, _el$10 = _el$9.firstChild, _el$11 = _el$10.nextSibling;
|
|
3161
|
-
(0, $g9l4l$addEventListener)(_el$10, "change", (0, $g9l4l$catchify)(()=>
|
|
3373
|
+
(0, $g9l4l$addEventListener)(_el$10, "change", (0, $g9l4l$catchify)(()=>current_sorting_[1](item())));
|
|
3162
3374
|
(0, $g9l4l$setAttribute)(_el$10, "name", title_radio_name);
|
|
3163
3375
|
(0, $g9l4l$insert)(_el$9, ()=>item().meta.title, null);
|
|
3164
3376
|
(0, $g9l4l$effect)(()=>_el$10.checked = is_checked());
|
|
@@ -3170,25 +3382,27 @@ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: availa
|
|
|
3170
3382
|
})(),
|
|
3171
3383
|
(0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
3172
3384
|
get when () {
|
|
3173
|
-
return
|
|
3385
|
+
return current_sorting_[0]()?.meta?.values?.length > 1;
|
|
3174
3386
|
},
|
|
3175
3387
|
get children () {
|
|
3176
3388
|
const _el$2 = $c23bd3d951eee1f2$var$_tmpl$2.cloneNode(true);
|
|
3177
3389
|
(0, $g9l4l$insert)(_el$2, (0, $g9l4l$createComponent)((0, $g9l4l$Index), {
|
|
3178
3390
|
get each () {
|
|
3179
|
-
return
|
|
3391
|
+
return current_sorting_[0]().meta.values;
|
|
3180
3392
|
},
|
|
3181
3393
|
children: (order_value, index)=>{
|
|
3182
|
-
const is_checked = (0, $g9l4l$createMemo)(()=>get_current_sorting()?.order === order_value());
|
|
3183
3394
|
return (()=>{
|
|
3184
3395
|
const _el$12 = $c23bd3d951eee1f2$var$_tmpl$4.cloneNode(true), _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling;
|
|
3185
|
-
(0, $g9l4l$addEventListener)(_el$14, "change", (0, $g9l4l$catchify)(()=>
|
|
3396
|
+
(0, $g9l4l$addEventListener)(_el$14, "change", (0, $g9l4l$catchify)(()=>current_sorting_[1]((c)=>c && {
|
|
3186
3397
|
...c,
|
|
3187
3398
|
order: order_value()
|
|
3188
3399
|
})));
|
|
3189
3400
|
(0, $g9l4l$setAttribute)(_el$14, "name", order_radio_name);
|
|
3190
|
-
(0, $g9l4l$insert)(_el$13, ()=>
|
|
3191
|
-
(0, $g9l4l$effect)(()=>_el$14.checked =
|
|
3401
|
+
(0, $g9l4l$insert)(_el$13, ()=>current_sorting_[0]()?.meta?.names?.[index], null);
|
|
3402
|
+
(0, $g9l4l$effect)(()=>_el$14.checked = (0, $g9l4l$createMemo)(()=>{
|
|
3403
|
+
const sort = current_sorting_[0]();
|
|
3404
|
+
return sort?.order === order_value();
|
|
3405
|
+
})());
|
|
3192
3406
|
return _el$12;
|
|
3193
3407
|
})();
|
|
3194
3408
|
}
|
|
@@ -3533,167 +3747,12 @@ function $fd7da6fb3e08aa40$export$9bf11afa910f536e({ args_for_sorting_: args_for
|
|
|
3533
3747
|
|
|
3534
3748
|
|
|
3535
3749
|
|
|
3536
|
-
|
|
3537
|
-
function $dd3727f29e682893$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
|
|
3538
|
-
let last_remote_state;
|
|
3539
|
-
(0, $g9l4l$createComputed)(()=>{
|
|
3540
|
-
const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
|
|
3541
|
-
JSON.stringify([
|
|
3542
|
-
filter.field,
|
|
3543
|
-
filter.op,
|
|
3544
|
-
filter?.meta?.type
|
|
3545
|
-
]),
|
|
3546
|
-
filter
|
|
3547
|
-
]) || []);
|
|
3548
|
-
const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
|
|
3549
|
-
JSON.stringify([
|
|
3550
|
-
filter.field,
|
|
3551
|
-
filter.op,
|
|
3552
|
-
filter?.meta?.type
|
|
3553
|
-
]),
|
|
3554
|
-
filter
|
|
3555
|
-
]));
|
|
3556
|
-
const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
|
|
3557
|
-
JSON.stringify([
|
|
3558
|
-
filter_obj.field,
|
|
3559
|
-
filter_obj.op
|
|
3560
|
-
]),
|
|
3561
|
-
filter_obj
|
|
3562
|
-
]));
|
|
3563
|
-
const new_local_filter_state = [];
|
|
3564
|
-
// we want to be as close as possible to available_filters_ in local_filters except that we want to keep values from previous available_filters_ as long as they're selected
|
|
3565
|
-
for (const filter_id of [
|
|
3566
|
-
...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
|
|
3567
|
-
...Object.keys(remote_filters)
|
|
3568
|
-
]){
|
|
3569
|
-
const local_filter = local_filters[filter_id];
|
|
3570
|
-
const remote_filter = remote_filters[filter_id];
|
|
3571
|
-
const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
|
|
3572
|
-
if (!remote_filter) // check if this filter is selected, if it is just take the local one but set counts to 0 and remove non-selected options
|
|
3573
|
-
{
|
|
3574
|
-
if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($dd3727f29e682893$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
|
|
3575
|
-
} else if (!local_filter) // just take the remote one
|
|
3576
|
-
new_local_filter_state.push(remote_filter);
|
|
3577
|
-
else {
|
|
3578
|
-
// both exist, merge them if needed
|
|
3579
|
-
const remote_meta = remote_filter.meta;
|
|
3580
|
-
const local_meta = local_filter.meta;
|
|
3581
|
-
const this_applied_filter = selected_filters[filter_id_without_meta_type];
|
|
3582
|
-
if (!remote_meta || !local_meta || !("values" in remote_meta) || !("values" in local_meta) || !Array.isArray(this_applied_filter?.data)) // can't or shouldn't be merged due to not being selected, just take remote one
|
|
3583
|
-
new_local_filter_state.push(remote_filter);
|
|
3584
|
-
else {
|
|
3585
|
-
const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
|
|
3586
|
-
JSON.stringify(value),
|
|
3587
|
-
{
|
|
3588
|
-
value_: value,
|
|
3589
|
-
count_: remote_meta.counts?.[index],
|
|
3590
|
-
name_: remote_meta.names?.[index]
|
|
3591
|
-
}
|
|
3592
|
-
]));
|
|
3593
|
-
const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
|
|
3594
|
-
JSON.stringify(value),
|
|
3595
|
-
{
|
|
3596
|
-
value_: value,
|
|
3597
|
-
count_: 0,
|
|
3598
|
-
name_: local_meta.names?.[index]
|
|
3599
|
-
}
|
|
3600
|
-
]));
|
|
3601
|
-
const new_data = [
|
|
3602
|
-
...Object.keys(data_objs_in_local).filter((key)=>{
|
|
3603
|
-
// put data entries that are selected and don't exist in new remote state first
|
|
3604
|
-
if (key in data_objs_in_remote) return false;
|
|
3605
|
-
const selected_values = this_applied_filter.data;
|
|
3606
|
-
return selected_values.some((value)=>{
|
|
3607
|
-
const is_equal = JSON.stringify(value) === key;
|
|
3608
|
-
if (is_equal) return true;
|
|
3609
|
-
if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
|
|
3610
|
-
// Very special case for hierarchical checkboxes - when a parent has all kids checked and a kid is deselected, the parent gets deselected. But since if it still has selected children we don't want to remove it from the filter state, even though it isn't selected, as the UI won't know the correct title of the parent category otherwise. This keeps it in that case.
|
|
3611
|
-
const selected_values = data_objs_in_local[key].value_;
|
|
3612
|
-
const values_length = value?.length;
|
|
3613
|
-
if (values_length > 1 && values_length - 1 === selected_values.length) {
|
|
3614
|
-
let is_parent = true;
|
|
3615
|
-
for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
|
|
3616
|
-
return is_parent;
|
|
3617
|
-
}
|
|
3618
|
-
}
|
|
3619
|
-
return false;
|
|
3620
|
-
});
|
|
3621
|
-
}).map((key)=>data_objs_in_local[key]),
|
|
3622
|
-
...Object.values(data_objs_in_remote)
|
|
3623
|
-
];
|
|
3624
|
-
const new_values = new_data.map(({ value_: value_ })=>value_);
|
|
3625
|
-
const result = {
|
|
3626
|
-
...remote_filter,
|
|
3627
|
-
meta: {
|
|
3628
|
-
...remote_filter.meta,
|
|
3629
|
-
values: new_values,
|
|
3630
|
-
names: new_data.map(({ name_: name_ })=>name_),
|
|
3631
|
-
counts: new_data.map(({ count_: count_ })=>count_)
|
|
3632
|
-
}
|
|
3633
|
-
};
|
|
3634
|
-
new_local_filter_state.push(result);
|
|
3635
|
-
}
|
|
3636
|
-
}
|
|
3637
|
-
}
|
|
3638
|
-
if (last_remote_state !== available_filters_() || // we HAVE to update the local filter state (it can contain same info but needs to be different object reference) every time the API state changes, otherwise the CheckboxHierarchicalFilter component doesn't update
|
|
3639
|
-
JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
|
|
3640
|
-
write_local_cache(new_local_filter_state);
|
|
3641
|
-
last_remote_state = available_filters_();
|
|
3642
|
-
});
|
|
3643
|
-
}
|
|
3644
|
-
/**
|
|
3645
|
-
* When a filter is only available locally due to being selected in a previous navigation, we want to make that clear and prevent further "invalid" choices.
|
|
3646
|
-
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
3647
|
-
*/ function $dd3727f29e682893$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
3648
|
-
const old_meta = local_filter_object.meta;
|
|
3649
|
-
const selected_filter_data = selected_filter.data;
|
|
3650
|
-
const modified_filter_object = {
|
|
3651
|
-
...local_filter_object
|
|
3652
|
-
};
|
|
3653
|
-
if (old_meta) {
|
|
3654
|
-
const new_meta = {
|
|
3655
|
-
...old_meta
|
|
3656
|
-
};
|
|
3657
|
-
modified_filter_object.meta = new_meta;
|
|
3658
|
-
// set counts to 0
|
|
3659
|
-
if ("counts" in new_meta) {
|
|
3660
|
-
const counts = new_meta.counts;
|
|
3661
|
-
if (counts) new_meta.counts = counts.map(()=>0);
|
|
3662
|
-
}
|
|
3663
|
-
if (Array.isArray(selected_filter_data) && "values" in new_meta) {
|
|
3664
|
-
// we have an array of values and want to strip the ones from the available ones that aren't selected
|
|
3665
|
-
const values = new_meta.values;
|
|
3666
|
-
if (Array.isArray(values)) {
|
|
3667
|
-
const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
|
|
3668
|
-
const indexes_to_remove = new Set();
|
|
3669
|
-
for(let i = 0; i < values.length; i++){
|
|
3670
|
-
const value = values[i];
|
|
3671
|
-
if (!jsond_set_values.includes(JSON.stringify(value))) // We want to remove the entry with this value from the filter object because it's not selected
|
|
3672
|
-
indexes_to_remove.add(i);
|
|
3673
|
-
}
|
|
3674
|
-
new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
|
|
3675
|
-
if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
|
|
3676
|
-
if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
|
|
3677
|
-
new_meta.counts.length -= indexes_to_remove.size;
|
|
3678
|
-
}
|
|
3679
|
-
}
|
|
3680
|
-
}
|
|
3681
|
-
return modified_filter_object;
|
|
3682
|
-
}
|
|
3683
|
-
|
|
3684
|
-
|
|
3685
3750
|
const $bf7fe049e78f975a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="filters"><div class="body"></div></div>`, 4), $bf7fe049e78f975a$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sorting"><div class="body"></div></div>`, 4), $bf7fe049e78f975a$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="sort-and-filter-buttons"><div class="outer"><div class="inner"></div></div></div>`, 6), $bf7fe049e78f975a$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="num-filters"></span>`, 2), $bf7fe049e78f975a$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="open-filters-button-container"><button class="filter toggle-button major-minor-transition" type="button"><span></span></button></div>`, 6), $bf7fe049e78f975a$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="toggle-button for-sorting major-minor-transition"><span></span></button>`, 4);
|
|
3686
3751
|
function $bf7fe049e78f975a$export$d7841e452f2e59a8({ current_sorting_: current_sorting_ , set_extra_els_in_results_container_: set_extra_els_in_results_container_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , set_sort_or_filter_open_: set_sort_or_filter_open_ , i18n_: i18n_ , available_sortings_: available_sortings_ , available_filters_: available_filters_ , expanded_filters_: expanded_filters_ , middle_elements_: middle_elements_ , input_modal_open_: input_modal_open_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , number_of_rendered_selected_filters_items_: number_of_rendered_selected_filters_items_ , set_sort_and_filter_element_: set_sort_and_filter_element_ , formatted_number_of_results_: formatted_number_of_results_ , filter_button_width_: filter_button_width_ , sort_button_width_: sort_button_width_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , get_extra_filters_button_: get_extra_filters_button_ , get_extra_sorting_button_: get_extra_sorting_button_ }) {
|
|
3687
3752
|
return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
|
|
3688
3753
|
severity_: "error",
|
|
3689
3754
|
message_: "Sorting and filters failed",
|
|
3690
3755
|
get children () {
|
|
3691
|
-
// This could technically be in SearchPage and CategoryPage and would be better suited there since it writes into local_filter_cache_ which i.e. SelectedFilters uses, but it's better suited here IMO due to DRY and being inside the correct error boundary here
|
|
3692
|
-
(0, $dd3727f29e682893$export$b288c38ae3fddb56)({
|
|
3693
|
-
available_filters_: available_filters_,
|
|
3694
|
-
selected_filters_: selected_filters_,
|
|
3695
|
-
local_filter_cache_: local_filter_cache_
|
|
3696
|
-
});
|
|
3697
3756
|
const cleanup_promise = new Promise((r)=>(0, $g9l4l$onCleanup)(r));
|
|
3698
3757
|
const [filters_open, set_filters_open] = search_filters_open_;
|
|
3699
3758
|
const [sorting_open, set_sorting_open] = search_sorting_open_;
|
|
@@ -4064,166 +4123,6 @@ function $4a2667e8d77eb55a$var$ActualFloatingButtons({ search_filters_open_: [ge
|
|
|
4064
4123
|
|
|
4065
4124
|
|
|
4066
4125
|
|
|
4067
|
-
|
|
4068
|
-
|
|
4069
|
-
|
|
4070
|
-
|
|
4071
|
-
const $4ebab5f2b1a65493$var$operator_map = {
|
|
4072
|
-
"eq": "≡",
|
|
4073
|
-
"neq": "≠",
|
|
4074
|
-
"in": "∈",
|
|
4075
|
-
"nin": "∉",
|
|
4076
|
-
"leq": "≤",
|
|
4077
|
-
"geq": "≥",
|
|
4078
|
-
"inrange": "\uD83D\uDD22"
|
|
4079
|
-
};
|
|
4080
|
-
const $4ebab5f2b1a65493$var$ascending_token = "\uD83D\uDCC8";
|
|
4081
|
-
const $4ebab5f2b1a65493$var$descending_token = "\uD83D\uDCC9";
|
|
4082
|
-
const $4ebab5f2b1a65493$export$4f506378e99f23dd = "filter_";
|
|
4083
|
-
const $4ebab5f2b1a65493$export$196aa1ee621a9930 = "sorting";
|
|
4084
|
-
const $4ebab5f2b1a65493$var$range_delimiter = "-";
|
|
4085
|
-
function $4ebab5f2b1a65493$export$7bcff1eb3eca57d7() {
|
|
4086
|
-
const current_sorting_ = (0, $g9l4l$createSignal)();
|
|
4087
|
-
const selected_filters_ = (0, $g9l4l$createSignal)([]);
|
|
4088
|
-
const [get_sorting, set_sorting] = current_sorting_;
|
|
4089
|
-
const [get_selected_filters, set_selected_filters] = selected_filters_;
|
|
4090
|
-
const [get_current_href, set_current_href] = (0, $g9l4l$createSignal)(location.href);
|
|
4091
|
-
const history_change_handler = ()=>set_current_href(location.href);
|
|
4092
|
-
let writer_started = false;
|
|
4093
|
-
(0, $g9l4l$instant_exec_on_suspect_history_change).add(history_change_handler);
|
|
4094
|
-
(0, $g9l4l$onCleanup)(()=>(0, $g9l4l$instant_exec_on_suspect_history_change).delete(history_change_handler));
|
|
4095
|
-
(0, $g9l4l$createComputed)(()=>{
|
|
4096
|
-
const { searchParams: searchParams } = new URL(get_current_href());
|
|
4097
|
-
const sorting = searchParams.get($4ebab5f2b1a65493$export$196aa1ee621a9930);
|
|
4098
|
-
(0, $g9l4l$batch)(()=>{
|
|
4099
|
-
set_sorting: {
|
|
4100
|
-
if (!sorting) {
|
|
4101
|
-
set_sorting();
|
|
4102
|
-
break set_sorting;
|
|
4103
|
-
}
|
|
4104
|
-
let target_field;
|
|
4105
|
-
let target_order;
|
|
4106
|
-
if (sorting.endsWith($4ebab5f2b1a65493$var$ascending_token)) {
|
|
4107
|
-
target_field = sorting.slice(0, -$4ebab5f2b1a65493$var$ascending_token.length);
|
|
4108
|
-
target_order = "asc";
|
|
4109
|
-
} else if (sorting.endsWith($4ebab5f2b1a65493$var$descending_token)) {
|
|
4110
|
-
target_field = sorting.slice(0, -$4ebab5f2b1a65493$var$descending_token.length);
|
|
4111
|
-
target_order = "desc";
|
|
4112
|
-
} else {
|
|
4113
|
-
(0, $g9l4l$dlog)("Invalid sorting query param value", sorting);
|
|
4114
|
-
break set_sorting;
|
|
4115
|
-
}
|
|
4116
|
-
const current_sorting = (0, $g9l4l$untrack)(get_sorting);
|
|
4117
|
-
// Do some diffing since we might assume in certain places of the code that if the signal changes it means the sorting has changed
|
|
4118
|
-
if (current_sorting?.field !== target_field || current_sorting?.order !== target_order) set_sorting({
|
|
4119
|
-
field: target_field,
|
|
4120
|
-
order: target_order
|
|
4121
|
-
});
|
|
4122
|
-
}
|
|
4123
|
-
const found_filters = [];
|
|
4124
|
-
for (const key of searchParams.keys()){
|
|
4125
|
-
if (!key.startsWith($4ebab5f2b1a65493$export$4f506378e99f23dd)) continue;
|
|
4126
|
-
for (const op of Object.keys($4ebab5f2b1a65493$var$operator_map)){
|
|
4127
|
-
const token = $4ebab5f2b1a65493$var$operator_map[op];
|
|
4128
|
-
if (!key.endsWith(token)) continue;
|
|
4129
|
-
const field = key.slice($4ebab5f2b1a65493$export$4f506378e99f23dd.length, -token.length);
|
|
4130
|
-
const data = searchParams.get(key);
|
|
4131
|
-
if (data) {
|
|
4132
|
-
let parsed_data;
|
|
4133
|
-
if (op === "inrange") parsed_data = data.split($4ebab5f2b1a65493$var$range_delimiter).map((x)=>parseFloat(x));
|
|
4134
|
-
else if (data === "1") parsed_data = "true";
|
|
4135
|
-
else if (data === "0") parsed_data = "false";
|
|
4136
|
-
else try {
|
|
4137
|
-
parsed_data = JSON.parse((0, $g9l4l$decompressFromBase64)(data));
|
|
4138
|
-
} catch (e) {
|
|
4139
|
-
(0, $g9l4l$dlog)("Failed to parse filter data", key, data, e);
|
|
4140
|
-
continue;
|
|
4141
|
-
}
|
|
4142
|
-
found_filters.push({
|
|
4143
|
-
field: field,
|
|
4144
|
-
op: op,
|
|
4145
|
-
data: parsed_data
|
|
4146
|
-
});
|
|
4147
|
-
}
|
|
4148
|
-
}
|
|
4149
|
-
}
|
|
4150
|
-
const selected_filters = (0, $g9l4l$untrack)(get_selected_filters);
|
|
4151
|
-
const found_filters_map = new Map(found_filters.map(({ field: field , op: op , data: data })=>[
|
|
4152
|
-
JSON.stringify([
|
|
4153
|
-
field,
|
|
4154
|
-
op
|
|
4155
|
-
]),
|
|
4156
|
-
data
|
|
4157
|
-
]));
|
|
4158
|
-
// Sorry for this diffing algorithm lol. Looking forwards to Records and Tuples.
|
|
4159
|
-
if (selected_filters.length !== found_filters.length || !selected_filters.every(({ field: field , op: op , data: data })=>JSON.stringify(found_filters_map.get(JSON.stringify([
|
|
4160
|
-
field,
|
|
4161
|
-
op
|
|
4162
|
-
]))) === JSON.stringify(data))) set_selected_filters(found_filters);
|
|
4163
|
-
if (!writer_started) {
|
|
4164
|
-
$4ebab5f2b1a65493$var$start_href_writer(get_sorting, get_selected_filters);
|
|
4165
|
-
writer_started = true;
|
|
4166
|
-
}
|
|
4167
|
-
});
|
|
4168
|
-
});
|
|
4169
|
-
return {
|
|
4170
|
-
current_sorting_: current_sorting_,
|
|
4171
|
-
selected_filters_: selected_filters_
|
|
4172
|
-
};
|
|
4173
|
-
}
|
|
4174
|
-
function $4ebab5f2b1a65493$var$start_href_writer(get_sorting, get_selected_filters) {
|
|
4175
|
-
// This has to be a createComputed because there can be some kind of URL query bouncing back and forwards otherwise (observed when clearing filters by making a new search)
|
|
4176
|
-
(0, $g9l4l$createComputed)((0, $g9l4l$on)([
|
|
4177
|
-
get_sorting,
|
|
4178
|
-
get_selected_filters
|
|
4179
|
-
], ([sorting, filters])=>{
|
|
4180
|
-
const current_href = location.href;
|
|
4181
|
-
const url_object = new URL(current_href);
|
|
4182
|
-
const { searchParams: searchParams } = url_object;
|
|
4183
|
-
const keys = [
|
|
4184
|
-
...searchParams.keys()
|
|
4185
|
-
]; // get keys here to be able to iterate over it later while modifying the search params
|
|
4186
|
-
if (sorting) {
|
|
4187
|
-
const { field: field , order: order } = sorting;
|
|
4188
|
-
const ascending = order === "asc";
|
|
4189
|
-
searchParams.set($4ebab5f2b1a65493$export$196aa1ee621a9930, field + (ascending ? $4ebab5f2b1a65493$var$ascending_token : $4ebab5f2b1a65493$var$descending_token));
|
|
4190
|
-
} else searchParams.delete($4ebab5f2b1a65493$export$196aa1ee621a9930);
|
|
4191
|
-
for (const key of keys)if (key.startsWith($4ebab5f2b1a65493$export$4f506378e99f23dd)) searchParams.delete(key);
|
|
4192
|
-
for (const filter of filters){
|
|
4193
|
-
const { field: field , op: op , data: data } = filter;
|
|
4194
|
-
let value;
|
|
4195
|
-
if (op === "inrange" && Array.isArray(data)) value = data.join($4ebab5f2b1a65493$var$range_delimiter);
|
|
4196
|
-
else if (data === "true") value = "1";
|
|
4197
|
-
else if (data === "false") value = "0";
|
|
4198
|
-
else value = (0, $g9l4l$compressToBase64)(JSON.stringify(data));
|
|
4199
|
-
searchParams.set($4ebab5f2b1a65493$export$4f506378e99f23dd + field + $4ebab5f2b1a65493$var$operator_map[op], value);
|
|
4200
|
-
}
|
|
4201
|
-
// We can't just check if the URL is equal since sometimes the order of the parameters in the URL changes (randomly?) so we need to compare them one by one
|
|
4202
|
-
const unmodified_search_params = [
|
|
4203
|
-
...new URL(current_href).searchParams
|
|
4204
|
-
];
|
|
4205
|
-
const new_search_params = new Map(searchParams);
|
|
4206
|
-
if (unmodified_search_params.length !== new_search_params.size || !unmodified_search_params.every(([key, value])=>new_search_params.get(key) === value)) // Only update URL if it actually changed
|
|
4207
|
-
history.replaceState({}, "", url_object.href);
|
|
4208
|
-
}, {
|
|
4209
|
-
defer: true
|
|
4210
|
-
}));
|
|
4211
|
-
}
|
|
4212
|
-
|
|
4213
|
-
|
|
4214
|
-
function $36c8a3d571f01d23$export$bca5a41ac5ef1190(url) {
|
|
4215
|
-
if (!url) return url;
|
|
4216
|
-
const got_u_o = url instanceof URL;
|
|
4217
|
-
const u_o = got_u_o ? url : new URL(url);
|
|
4218
|
-
const { searchParams: searchParams } = u_o;
|
|
4219
|
-
const current_search_params = new URLSearchParams(location.search);
|
|
4220
|
-
if (current_search_params.has((0, $4ebab5f2b1a65493$export$196aa1ee621a9930))) searchParams.set((0, $4ebab5f2b1a65493$export$196aa1ee621a9930), current_search_params.get((0, $4ebab5f2b1a65493$export$196aa1ee621a9930)));
|
|
4221
|
-
for (const key of current_search_params.keys())if (key.startsWith((0, $4ebab5f2b1a65493$export$4f506378e99f23dd))) searchParams.set(key, current_search_params.get(key));
|
|
4222
|
-
if (got_u_o) return u_o;
|
|
4223
|
-
return u_o.href;
|
|
4224
|
-
}
|
|
4225
|
-
|
|
4226
|
-
|
|
4227
4126
|
const $1b5a927e48d892a1$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<nav class="crumbs"></nav>`, 2), $1b5a927e48d892a1$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="crumb"></a>`, 2), $1b5a927e48d892a1$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="separator"></span>`, 2);
|
|
4228
4127
|
function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_data , on_crumb_click_: on_crumb_click_ , i18n_: i18n_ }) {
|
|
4229
4128
|
const placeholder_crumb_data = [
|
|
@@ -4241,20 +4140,11 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4241
4140
|
get each () {
|
|
4242
4141
|
return crumb_data();
|
|
4243
4142
|
},
|
|
4244
|
-
children: (
|
|
4245
|
-
const modified_display_accessor = (0, $g9l4l$createMemo)(()=>{
|
|
4246
|
-
const value = unmodified_display_accessor();
|
|
4247
|
-
if (!value) return value;
|
|
4248
|
-
return {
|
|
4249
|
-
...value,
|
|
4250
|
-
// We don't want these links to delete the sort and filter state by default, only if `clear_filters_when_going_sideways` explicitly clears them
|
|
4251
|
-
page_url: (0, $36c8a3d571f01d23$export$bca5a41ac5ef1190)(value.page_url)
|
|
4252
|
-
};
|
|
4253
|
-
});
|
|
4143
|
+
children: (display_accessor, index)=>{
|
|
4254
4144
|
return [
|
|
4255
4145
|
(0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
4256
4146
|
get when () {
|
|
4257
|
-
return
|
|
4147
|
+
return display_accessor();
|
|
4258
4148
|
},
|
|
4259
4149
|
get fallback () {
|
|
4260
4150
|
return (0, $g9l4l$createComponent)((0, $g9l4l$Placeholder), {
|
|
@@ -4264,9 +4154,9 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4264
4154
|
},
|
|
4265
4155
|
get children () {
|
|
4266
4156
|
const _el$2 = $1b5a927e48d892a1$var$_tmpl$2.cloneNode(true);
|
|
4267
|
-
(0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)((ev)=>on_crumb_click_(ev,
|
|
4268
|
-
(0, $g9l4l$insert)(_el$2, ()=>
|
|
4269
|
-
(0, $g9l4l$effect)(()=>(0, $g9l4l$setAttribute)(_el$2, "href",
|
|
4157
|
+
(0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)((ev)=>on_crumb_click_(ev, display_accessor())), true);
|
|
4158
|
+
(0, $g9l4l$insert)(_el$2, ()=>display_accessor().title);
|
|
4159
|
+
(0, $g9l4l$effect)(()=>(0, $g9l4l$setAttribute)(_el$2, "href", display_accessor().page_url));
|
|
4270
4160
|
return _el$2;
|
|
4271
4161
|
}
|
|
4272
4162
|
}),
|
|
@@ -4303,9 +4193,7 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4303
4193
|
|
|
4304
4194
|
|
|
4305
4195
|
|
|
4306
|
-
|
|
4307
4196
|
const $6af87e1502f04aa3$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<nav class="quicklinks"></nav>`, 2), $6af87e1502f04aa3$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div>QuickLinks failed</div>`, 2), $6af87e1502f04aa3$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="quicklink"></a>`, 2);
|
|
4308
|
-
const $6af87e1502f04aa3$export$e2cf3f19dd3f8aac = "went_sideways_clear_filters";
|
|
4309
4197
|
function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklinks_data_ , on_link_click_: on_link_click_ , current_query_id_: current_query_id_ , slider_arrow_button_: slider_arrow_button_ , breadcrumb_data_: breadcrumb_data_ , i18n_: i18n_ }) {
|
|
4310
4198
|
let scrolling_logic_ran_for_query_id = false;
|
|
4311
4199
|
let last_scroll_position;
|
|
@@ -4427,43 +4315,20 @@ function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklink
|
|
|
4427
4315
|
get each () {
|
|
4428
4316
|
return place_holdey_quicklinks_data();
|
|
4429
4317
|
},
|
|
4430
|
-
children: (
|
|
4318
|
+
children: (display_accessor, index)=>{
|
|
4431
4319
|
const is_selected = (0, $g9l4l$createMemo)(()=>selected_index() === index);
|
|
4432
|
-
// Problem: if opening a sibling link in a new tab, filter clearing behavior is no longer consistent
|
|
4433
|
-
// Solution:
|
|
4434
|
-
// If current one in quick links they're siblings, don't add state to the url
|
|
4435
|
-
// If it's not in it, it's a child of the current one, so add state
|
|
4436
|
-
// (This brought up the issue on what happens if someone links to a filter that no longer exists, I chose to ignore that for now)
|
|
4437
|
-
// Problem: When you don't open a link in a new tab, we don't display the filter cleared toast
|
|
4438
|
-
// Solution: instead of not adding the state to the url, add a flag to the link if it's a sibling and then display the toast on load if the flag is set
|
|
4439
|
-
const is_child = (0, $g9l4l$createMemo)(()=>{
|
|
4440
|
-
const current_id = current_query_id_();
|
|
4441
|
-
return !quicklinks_data_()?.find(({ query_id: query_id })=>query_id === current_id);
|
|
4442
|
-
});
|
|
4443
|
-
const modified_display_accessor = (0, $g9l4l$createMemo)(()=>{
|
|
4444
|
-
const value = unmodified_display_accessor();
|
|
4445
|
-
if (!value) return value;
|
|
4446
|
-
const new_page_url = new URL(value.page_url, location.origin);
|
|
4447
|
-
(0, $36c8a3d571f01d23$export$bca5a41ac5ef1190)(new_page_url);
|
|
4448
|
-
if (!is_child()) new_page_url.searchParams.set($6af87e1502f04aa3$export$e2cf3f19dd3f8aac, "true");
|
|
4449
|
-
return {
|
|
4450
|
-
...value,
|
|
4451
|
-
// We don't want these links to delete the sort and filter state by default, only if `clear_filters_when_going_sideways` explicitly clears them
|
|
4452
|
-
page_url: new_page_url.href
|
|
4453
|
-
};
|
|
4454
|
-
});
|
|
4455
4320
|
return (()=>{
|
|
4456
4321
|
const _el$3 = $6af87e1502f04aa3$var$_tmpl$3.cloneNode(true);
|
|
4457
4322
|
(0, $g9l4l$addEventListener)(_el$3, "click", (0, $g9l4l$catchify)((ev)=>{
|
|
4458
4323
|
if (is_selected() && !ev.metaKey && !ev.ctrlKey && !ev.button) ev.preventDefault();
|
|
4459
|
-
else if (
|
|
4324
|
+
else if (display_accessor()) on_link_click_(ev, display_accessor());
|
|
4460
4325
|
}), true);
|
|
4461
|
-
(0, $g9l4l$insert)(_el$3, ()=>
|
|
4326
|
+
(0, $g9l4l$insert)(_el$3, ()=>display_accessor()?.title || (0, $g9l4l$createComponent)((0, $g9l4l$Placeholder), {
|
|
4462
4327
|
height: "1em",
|
|
4463
4328
|
width: "10ch"
|
|
4464
4329
|
}));
|
|
4465
4330
|
(0, $g9l4l$effect)((_p$)=>{
|
|
4466
|
-
const _v$ = !!is_selected(), _v$2 =
|
|
4331
|
+
const _v$ = !!is_selected(), _v$2 = display_accessor()?.page_url || "javascript:void(0)";
|
|
4467
4332
|
_v$ !== _p$._v$ && _el$3.classList.toggle("selected", _p$._v$ = _v$);
|
|
4468
4333
|
_v$2 !== _p$._v$2 && (0, $g9l4l$setAttribute)(_el$3, "href", _p$._v$2 = _v$2);
|
|
4469
4334
|
return _p$;
|
|
@@ -4638,7 +4503,6 @@ let $01115659405f3c64$export$44dad306455dddf;
|
|
|
4638
4503
|
})($01115659405f3c64$export$44dad306455dddf || ($01115659405f3c64$export$44dad306455dddf = {}));
|
|
4639
4504
|
|
|
4640
4505
|
|
|
4641
|
-
|
|
4642
4506
|
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);
|
|
4643
4507
|
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_ , on_category_link_click_: on_category_link_click_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , rr_options_: rr_options_ , get_product_id_: get_product_id_ }) {
|
|
4644
4508
|
let results_for;
|
|
@@ -4661,26 +4525,6 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4661
4525
|
const first_result_in_viewport_ = (0, $g9l4l$createSignal)();
|
|
4662
4526
|
const last_result_in_viewport_ = (0, $g9l4l$createSignal)();
|
|
4663
4527
|
const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = (0, $g9l4l$createSignal)(false);
|
|
4664
|
-
const tracking_function_for_plp_results = (0, $g9l4l$createReaction)(()=>{
|
|
4665
|
-
// 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
|
|
4666
|
-
const url_object = new URL(location.href);
|
|
4667
|
-
const { searchParams: searchParams } = url_object;
|
|
4668
|
-
if (searchParams.get((0, $6af87e1502f04aa3$export$e2cf3f19dd3f8aac)) !== "true") return;
|
|
4669
|
-
searchParams.delete((0, $6af87e1502f04aa3$export$e2cf3f19dd3f8aac));
|
|
4670
|
-
history.pushState(history.state, "", url_object.href);
|
|
4671
|
-
(0, $g9l4l$dlog)("Flag to clear filters was set, clearing filters");
|
|
4672
|
-
(0, $g9l4l$queueMacroTask)(()=>{
|
|
4673
|
-
// Do it next task so that all the filters have time to populate
|
|
4674
|
-
(0, $af89070cc0052779$export$8895d39404bd2bb1)({
|
|
4675
|
-
user_triggered_: false,
|
|
4676
|
-
i18n_: i18n_,
|
|
4677
|
-
also_clear_sorting_: false,
|
|
4678
|
-
selected_filters_: selected_filters_,
|
|
4679
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4680
|
-
local_filter_cache_: local_filter_cache_
|
|
4681
|
-
});
|
|
4682
|
-
});
|
|
4683
|
-
});
|
|
4684
4528
|
const query_base_ = (0, $930337c3b3b5f896$export$210f130a61ac1e8d)(()=>{
|
|
4685
4529
|
const sort_obj = get_sorting() && {
|
|
4686
4530
|
...get_sorting()
|
|
@@ -4712,7 +4556,6 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4712
4556
|
} : {}
|
|
4713
4557
|
})
|
|
4714
4558
|
})));
|
|
4715
|
-
tracking_function_for_plp_results(plp_results_);
|
|
4716
4559
|
const available_sortings_ = (0, $g9l4l$createMemo)(()=>plp_results_()?.sorts?.map((sort)=>({
|
|
4717
4560
|
...sort,
|
|
4718
4561
|
order: sort.order ?? "desc"
|
|
@@ -5089,7 +4932,6 @@ function $c7f938ac40924f3b$export$23fca46f3143581f(component, error_message) {
|
|
|
5089
4932
|
}
|
|
5090
4933
|
|
|
5091
4934
|
|
|
5092
|
-
|
|
5093
4935
|
const $ec52ef1e6c117813$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp category"></div>`, 2);
|
|
5094
4936
|
const $ec52ef1e6c117813$var$min_products_to_fetch_ = 20;
|
|
5095
4937
|
const $ec52ef1e6c117813$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
@@ -5135,20 +4977,17 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
|
|
|
5135
4977
|
$ec52ef1e6c117813$export$f34314aa9505732e.#has_been_constructed = true;
|
|
5136
4978
|
Object.assign(this, props_on_class); // set initial signal values
|
|
5137
4979
|
(0, $2864fd26f57ff474$export$5162a71f252e6122)();
|
|
5138
|
-
const
|
|
5139
|
-
|
|
5140
|
-
|
|
5141
|
-
|
|
5142
|
-
|
|
5143
|
-
|
|
5144
|
-
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
|
|
5148
|
-
|
|
5149
|
-
category_scroll_restoration_data: []
|
|
5150
|
-
})
|
|
5151
|
-
});
|
|
4980
|
+
const [reset_history_state_, state_] = (0, $3075a4497054bec6$export$9862539c89138352)(()=>({
|
|
4981
|
+
category_sorting: undefined,
|
|
4982
|
+
category_filters_open: false,
|
|
4983
|
+
category_sorting_open: false,
|
|
4984
|
+
category_expanded_filters: [],
|
|
4985
|
+
// WARNING, it is insanely important, when creating the signals like this using make_resettable_history_state, that the two lines below are in *precisely that order*. The reason for that is that make_resettable_history_state will write the values of the signals in the order that they are written here when a "popstate" event occurs. If the filter cache is popped before the selected filters are the code in create_modified_filters() in FilterBody.tsx is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters and we'll end up with too few filters in search_local_filter_cache in some cases
|
|
4986
|
+
category_selected_filters: [],
|
|
4987
|
+
category_local_filter_cache: [],
|
|
4988
|
+
category_expanded_hierarchical_filters: [],
|
|
4989
|
+
category_scroll_restoration_data: []
|
|
4990
|
+
}));
|
|
5152
4991
|
const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
|
|
5153
4992
|
const on_category_link_click_ = (e, d)=>{
|
|
5154
4993
|
if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
|
|
@@ -5173,8 +5012,6 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
|
|
|
5173
5012
|
reset_history_state_: reset_history_state_,
|
|
5174
5013
|
depict_api_: api ?? new (0, $3846bb34098c738f$export$e015ed2f2950f2e3)(),
|
|
5175
5014
|
on_category_link_click_: on_category_link_click_,
|
|
5176
|
-
selected_filters_: selected_filters_,
|
|
5177
|
-
current_sorting_: current_sorting_,
|
|
5178
5015
|
slider_arrow_button_: (0, $g9l4l$GenericSliderArrowButton)({
|
|
5179
5016
|
height_: 12,
|
|
5180
5017
|
width_: 6.46
|
|
@@ -5191,7 +5028,7 @@ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
5191
5028
|
grid_spacing: grid_spacing.horizontal
|
|
5192
5029
|
};
|
|
5193
5030
|
return (0, $c7f938ac40924f3b$export$23fca46f3143581f)(()=>{
|
|
5194
|
-
const { state_: { category_local_filter_cache: local_filter_cache_ , category_filters_open: category_filters_open_ , category_sorting_open: category_sorting_open_ , category_expanded_filters: expanded_filters_ , category_expanded_hierarchical_filters: expanded_hierarchical_filters_ ,
|
|
5031
|
+
const { state_: { category_local_filter_cache: local_filter_cache_ , category_sorting: current_sorting_ , category_filters_open: category_filters_open_ , category_sorting_open: category_sorting_open_ , category_expanded_filters: expanded_filters_ , category_expanded_hierarchical_filters: expanded_hierarchical_filters_ , category_selected_filters: selected_filters_ , category_scroll_restoration_data: scroll_restoration_data_ } , reset_history_state_: reset_history_state_ , depict_api_: depict_api_ , i18n_: i18n_ , on_category_link_click_: on_category_link_click_ , breadcrumb_signal_: breadcrumb_signal_ , quicklinks_signal_: quicklinks_signal_ , slider_arrow_button_: slider_arrow_button_ } = shared_properties;
|
|
5195
5032
|
(0, $g9l4l$onCleanup)(reset_history_state_);
|
|
5196
5033
|
return (0, $1ae892b13d7746ab$export$f7d2f673fc2f091d)({
|
|
5197
5034
|
tenant_: ()=>depict_category.merchant,
|
|
@@ -5520,14 +5357,18 @@ function $7a7079d66c12b788$export$d757d54550ebfb3d({ category_suggestion_: categ
|
|
|
5520
5357
|
|
|
5521
5358
|
|
|
5522
5359
|
const $6ded59a142c93078$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<button class="back" type="button"></button>`, 2), $6ded59a142c93078$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="search-field"><div class="field"><input class="query" tabindex="0"><button type="button" class="clear"></button></div><button class="submit major" type="button"></button></div>`, 9);
|
|
5523
|
-
function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search_field_value_ , input_field_ref_: input_field_ref_ , field_element_ref_: field_element_ref_ , submit_query_: submit_query_ , override_on_enter_: override_on_enter_ , clear_filters_: clear_filters_ , disabled_: disabled_ = false , on_back_: on_back_ , i18n_: i18n_ }) {
|
|
5524
|
-
let
|
|
5360
|
+
function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search_field_value_ , input_field_ref_: input_field_ref_ , field_element_ref_: field_element_ref_ , submit_query_: submit_query_ , override_on_enter_: override_on_enter_ , clear_filters_: clear_filters_ , disabled_: disabled_ = false , on_back_: on_back_ , i18n_: i18n_ , after_focusing_: after_focusing_ }) {
|
|
5361
|
+
let input_element;
|
|
5362
|
+
// This is the div where we recommend (and ourselves do) attach the event listener to that opens the search modal.
|
|
5363
|
+
let field_div;
|
|
5525
5364
|
(0, $g9l4l$createEffect)((0, $g9l4l$catchify)(async ()=>{
|
|
5526
5365
|
if (disabled_) return;
|
|
5527
5366
|
// we aren't in DOM yet unfortunately, wouldn't even be with onMount
|
|
5528
|
-
await (0, $g9l4l$observer).wait_for_element(
|
|
5529
|
-
|
|
5367
|
+
await (0, $g9l4l$observer).wait_for_element(input_element);
|
|
5368
|
+
input_element.focus();
|
|
5369
|
+
after_focusing_?.(input_element);
|
|
5530
5370
|
})); // focus field on render
|
|
5371
|
+
const owner_of_field_element = (0, $g9l4l$getOwner)();
|
|
5531
5372
|
return (()=>{
|
|
5532
5373
|
const _el$ = $6ded59a142c93078$var$_tmpl$2.cloneNode(true), _el$3 = _el$.firstChild, _el$4 = _el$3.firstChild, _el$5 = _el$4.nextSibling, _el$6 = _el$3.nextSibling;
|
|
5533
5374
|
(0, $g9l4l$insert)(_el$, (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
@@ -5540,48 +5381,55 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5540
5381
|
return _el$2;
|
|
5541
5382
|
}
|
|
5542
5383
|
}), _el$3);
|
|
5543
|
-
(0, $g9l4l$use)((el)=>
|
|
5544
|
-
|
|
5545
|
-
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5384
|
+
(0, $g9l4l$use)((el)=>{
|
|
5385
|
+
field_div = el;
|
|
5386
|
+
field_element_ref_?.(el);
|
|
5387
|
+
}, _el$3);
|
|
5388
|
+
_el$4.$$pointerdown = ({ pointerType: pointerType })=>{
|
|
5389
|
+
// When selecting text with a mouse we want a SearchField to be focussed even when releasing the mouse outside the .field element (we assume the event listener which opens the modal is attached to that).
|
|
5390
|
+
if (pointerType === "mouse") {
|
|
5391
|
+
const handler = (0, $g9l4l$catchify)(({ pointerType: pointerType , target: target })=>{
|
|
5392
|
+
if (pointerType !== "mouse" || !(target instanceof Node) || target === field_div || field_div.contains(target)) return;
|
|
5393
|
+
input_element.click();
|
|
5394
|
+
});
|
|
5395
|
+
window.addEventListener("pointerup", handler, {
|
|
5550
5396
|
once: true
|
|
5551
5397
|
});
|
|
5398
|
+
if (owner_of_field_element) (0, $g9l4l$runWithOwner)(owner_of_field_element, ()=>(0, $g9l4l$onCleanup)(()=>window.removeEventListener("pointerup", handler)));
|
|
5552
5399
|
}
|
|
5400
|
+
};
|
|
5401
|
+
(0, $g9l4l$addEventListener)(_el$4, "select", (0, $g9l4l$catchify)(()=>{
|
|
5402
|
+
if (disabled_) // just in case. The field not actually being disabled when being disabled_ is so that you can focus it and open the modal. We don't want any of the other input-field-interaction features to work
|
|
5403
|
+
return;
|
|
5404
|
+
if (input_element.selectionStart === 0 && input_element.selectionEnd === input_element.value.length) // everything was selected, clear filters on next submit on next input
|
|
5405
|
+
input_element.addEventListener("input", (0, $g9l4l$catchify)(clear_filters_), {
|
|
5406
|
+
once: true
|
|
5407
|
+
});
|
|
5553
5408
|
}));
|
|
5554
5409
|
(0, $g9l4l$addEventListener)(_el$4, "input", (0, $g9l4l$catchify)(()=>{
|
|
5555
|
-
const { value: value } =
|
|
5556
|
-
if (!disabled_ && !value.length) clear_filters_(
|
|
5410
|
+
const { value: value } = input_element;
|
|
5411
|
+
if (!disabled_ && !value.length) clear_filters_(); // if the user clears the whole field, reset filters on next submit
|
|
5557
5412
|
search_field_value_[1](value);
|
|
5558
5413
|
}), true);
|
|
5559
5414
|
(0, $g9l4l$addEventListener)(_el$4, "keydown", (0, $g9l4l$catchify)((e)=>{
|
|
5560
5415
|
if (disabled_) {
|
|
5561
5416
|
if (e.key !== "Tab" && e.key !== "Shift") // alow tab-selecting the input field and then open the modal when the user start writing but also to move past the field with tab
|
|
5562
|
-
|
|
5417
|
+
input_element.click();
|
|
5563
5418
|
} else if (e.key === "Enter") {
|
|
5564
5419
|
const dont_submit = override_on_enter_?.(e);
|
|
5565
5420
|
if (!dont_submit) submit_query_();
|
|
5566
5421
|
}
|
|
5567
5422
|
}), true);
|
|
5568
|
-
(0, $g9l4l$addEventListener)(_el$4, "focus", (0, $g9l4l$catchify)(()=>{
|
|
5569
|
-
if (disabled_) {
|
|
5570
|
-
const last_pos = input_field.value.length;
|
|
5571
|
-
input_field.setSelectionRange(last_pos, last_pos);
|
|
5572
|
-
}
|
|
5573
|
-
}));
|
|
5574
5423
|
const _ref$ = (0, $g9l4l$catchify)((el)=>{
|
|
5575
|
-
|
|
5424
|
+
input_element = el;
|
|
5576
5425
|
input_field_ref_?.(el);
|
|
5577
5426
|
});
|
|
5578
5427
|
typeof _ref$ === "function" && (0, $g9l4l$use)(_ref$, _el$4);
|
|
5579
5428
|
_el$4.classList.toggle("has-adjacent-back-button", !!on_back_);
|
|
5580
5429
|
(0, $g9l4l$addEventListener)(_el$5, "click", (0, $g9l4l$catchify)(()=>{
|
|
5581
5430
|
search_field_value_[1]("");
|
|
5582
|
-
clear_filters_(
|
|
5583
|
-
if (disabled_)
|
|
5584
|
-
input_field.focus();
|
|
5431
|
+
clear_filters_();
|
|
5432
|
+
if (!disabled_) input_element.focus();
|
|
5585
5433
|
}), true);
|
|
5586
5434
|
(0, $g9l4l$insert)(_el$5, (0, $g9l4l$createComponent)((0, $g9l4l$CrossIcon), {}));
|
|
5587
5435
|
(0, $g9l4l$addEventListener)(_el$6, "click", (0, $g9l4l$catchify)(()=>submit_query_()), true);
|
|
@@ -5608,7 +5456,8 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5608
5456
|
(0, $g9l4l$delegateEvents)([
|
|
5609
5457
|
"click",
|
|
5610
5458
|
"keydown",
|
|
5611
|
-
"input"
|
|
5459
|
+
"input",
|
|
5460
|
+
"pointerdown"
|
|
5612
5461
|
]);
|
|
5613
5462
|
|
|
5614
5463
|
|
|
@@ -5797,27 +5646,27 @@ function $079defea521d5e2a$export$b3ad617e9036868(modal_body_style, input_field,
|
|
|
5797
5646
|
|
|
5798
5647
|
|
|
5799
5648
|
function $a0d89ff25220eb8d$export$e026af0c7b64ea5f({ selected_filters_: selected_filters_ , search_query_: [get_search_query] , current_sorting_: current_sorting_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , local_filter_cache_: local_filter_cache_ }) {
|
|
5800
|
-
const [get_selected_filters] = selected_filters_;
|
|
5801
|
-
//
|
|
5802
|
-
// 0 - we should not clear next submit
|
|
5803
|
-
// 1 - we should clear next submit due to internal heuristics
|
|
5804
|
-
// 2 - we should clear next submit due to EXPLICIT user action (i.e. clear button pressed)
|
|
5805
|
-
const clear_filters_next_submit_ = (0, $g9l4l$createSignal)(0); // we store this here (and not in history.state) (maybe there's a better place) because it's a very temporary thing. I.e. as soon as anything breaks the "flow of intent" to make a new search we want this reset
|
|
5649
|
+
const [get_selected_filters, set_selected_filters] = selected_filters_;
|
|
5650
|
+
const clear_filters_next_submit_ = (0, $g9l4l$createSignal)(false); // we store this here (and not in history.state) (maybe there's a better place) because it's a very temporary thing. I.e. as soon as anything breaks the "flow of intent" to make a new search we want this reset
|
|
5806
5651
|
const [get_clear_filters_next_submit, set_clear_filters_next_submit] = clear_filters_next_submit_;
|
|
5807
|
-
const clear_filters = (
|
|
5652
|
+
const clear_filters = ()=>set_clear_filters_next_submit(true);
|
|
5808
5653
|
(0, $g9l4l$createComputed)((0, $g9l4l$on)(get_selected_filters, ()=>{
|
|
5809
5654
|
// if the selected filters update, clear the clearing signal
|
|
5810
|
-
set_clear_filters_next_submit(
|
|
5655
|
+
set_clear_filters_next_submit(false);
|
|
5811
5656
|
}, {
|
|
5812
5657
|
defer: true
|
|
5813
5658
|
}));
|
|
5814
5659
|
(0, $g9l4l$createComputed)((0, $g9l4l$on)(get_search_query, (0, $g9l4l$catchify)(()=>{
|
|
5815
5660
|
// when a query was submitted, clear filters if clear was pressed before
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5661
|
+
if ((0, $g9l4l$untrack)(get_clear_filters_next_submit)) {
|
|
5662
|
+
set_clear_filters_next_submit(false);
|
|
5663
|
+
set_selected_filters([]);
|
|
5664
|
+
// also collapse expanded filters in hierarchical filter tree again
|
|
5665
|
+
expanded_hierarchical_filters_[1]([]);
|
|
5666
|
+
// also clear sorting
|
|
5667
|
+
current_sorting_[1](undefined);
|
|
5819
5668
|
(0, $af89070cc0052779$export$8895d39404bd2bb1)({
|
|
5820
|
-
user_triggered_:
|
|
5669
|
+
user_triggered_: true,
|
|
5821
5670
|
selected_filters_: selected_filters_,
|
|
5822
5671
|
i18n_: i18n_,
|
|
5823
5672
|
also_clear_sorting_: true,
|
|
@@ -5960,7 +5809,7 @@ function $4ad18a8b237ff7f6$export$2542ffb77b620b02(params_to_default_value) {
|
|
|
5960
5809
|
|
|
5961
5810
|
|
|
5962
5811
|
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);
|
|
5963
|
-
const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n })=>{
|
|
5812
|
+
const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n , market: market })=>{
|
|
5964
5813
|
const display = (0, $g9l4l$createMemo)(()=>{
|
|
5965
5814
|
const display = display_or_variant_container();
|
|
5966
5815
|
// Support for backend's new display format
|
|
@@ -5972,7 +5821,12 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
|
|
|
5972
5821
|
};
|
|
5973
5822
|
}
|
|
5974
5823
|
if (display.page_url) return display;
|
|
5975
|
-
// Support for
|
|
5824
|
+
// Support for post-migration (but still old basic format) Stronger displays, with slug but without page_url
|
|
5825
|
+
if (display.slug) {
|
|
5826
|
+
display.page_url = `/${market}/` + display.slug;
|
|
5827
|
+
return display;
|
|
5828
|
+
}
|
|
5829
|
+
// Support for Spendrups displays, used by our frontend script and Spendrups coming react-ui integration.
|
|
5976
5830
|
if (!display?.variants?.length) return;
|
|
5977
5831
|
return display.variants.filter((v)=>v.product_id == display.product_id)[0];
|
|
5978
5832
|
});
|
|
@@ -6959,7 +6813,7 @@ function $b24f16c875c2baa6$export$f021bdedd3ec901a(props) {
|
|
|
6959
6813
|
|
|
6960
6814
|
|
|
6961
6815
|
const $a9f6faeac82c322b$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="discover-more"><button class="major" type="button"></button></div>`, 4), $a9f6faeac82c322b$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<b></b>`, 2), $a9f6faeac82c322b$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict-search-modal"><div class="body"><div class="padded"></div></div></div>`, 6), $a9f6faeac82c322b$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"><div class="depict-search-modal-backdrop"></div></div>`, 4);
|
|
6962
|
-
function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: search_field_value_ , search_query_: search_query_ , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $g9l4l$createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: submit_query_ , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , after_submit_: after_submit_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ }) {
|
|
6816
|
+
function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: search_field_value_ , search_query_: search_query_ , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $g9l4l$createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: submit_query_ , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , after_submit_: after_submit_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , selected_text_range_: selected_text_range_ }) {
|
|
6963
6817
|
let on_enter_in_search_field_function;
|
|
6964
6818
|
const [input_field, set_input_field] = (0, $g9l4l$createSignal)();
|
|
6965
6819
|
const [get_search_field_value_] = search_field_value_;
|
|
@@ -7021,7 +6875,14 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: search
|
|
|
7021
6875
|
search_field_value_: search_field_value_,
|
|
7022
6876
|
submit_query_: submit_query_,
|
|
7023
6877
|
clear_filters_: clear_filters_,
|
|
7024
|
-
i18n_: i18n_
|
|
6878
|
+
i18n_: i18n_,
|
|
6879
|
+
after_focusing_: (input_el)=>{
|
|
6880
|
+
// Restore the selection range from the SearchField that was used to open the modal, if it was saved.
|
|
6881
|
+
if (!selected_text_range_) return;
|
|
6882
|
+
const [start, end] = selected_text_range_;
|
|
6883
|
+
if (start === null || end === null) return;
|
|
6884
|
+
input_el.setSelectionRange(start, end);
|
|
6885
|
+
}
|
|
7025
6886
|
});
|
|
7026
6887
|
search_field.classList.add("in-modal");
|
|
7027
6888
|
const modal_element = (()=>{
|
|
@@ -7291,28 +7152,38 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
|
|
|
7291
7152
|
})));
|
|
7292
7153
|
const available_filters_ = (0, $g9l4l$createMemo)(()=>search_results_()?.filters);
|
|
7293
7154
|
const modal_body_style = (0, $g9l4l$createSignal)({});
|
|
7294
|
-
let
|
|
7155
|
+
let search_field;
|
|
7295
7156
|
if (include_input_field_) {
|
|
7296
7157
|
const SafeSearchField = (0, $g9l4l$catchify)((0, $6ded59a142c93078$export$b94867ecbd698f21));
|
|
7297
|
-
|
|
7158
|
+
let input_element;
|
|
7159
|
+
let div_with_field_class;
|
|
7160
|
+
search_field = SafeSearchField({
|
|
7298
7161
|
i18n_: i18n_,
|
|
7299
|
-
disabled_: true,
|
|
7300
7162
|
search_query_: search_query_,
|
|
7301
7163
|
search_field_value_: search_field_value_,
|
|
7302
7164
|
submit_query_: submit_query_,
|
|
7303
|
-
clear_filters_: clear_filters_on_next_submit_
|
|
7165
|
+
clear_filters_: clear_filters_on_next_submit_,
|
|
7166
|
+
input_field_ref_: (el)=>input_element = el,
|
|
7167
|
+
field_element_ref_: (el)=>div_with_field_class = el,
|
|
7168
|
+
disabled_: true
|
|
7304
7169
|
});
|
|
7305
|
-
if (
|
|
7170
|
+
if (search_field) {
|
|
7306
7171
|
opts?.modal_body_style_ref_?.(modal_body_style);
|
|
7307
|
-
const align_position = (0, $g9l4l$catchify)((0, $079defea521d5e2a$export$b3ad617e9036868))(modal_body_style,
|
|
7308
|
-
|
|
7172
|
+
const align_position = (0, $g9l4l$catchify)((0, $079defea521d5e2a$export$b3ad617e9036868))(modal_body_style, search_field, undefined, true);
|
|
7173
|
+
div_with_field_class.addEventListener("click", (0, $g9l4l$catchify)((e)=>{
|
|
7309
7174
|
const target = e.target;
|
|
7310
7175
|
const sel = ".submit";
|
|
7311
7176
|
if (target?.matches?.(sel) || target?.closest?.(sel)) // the search button is just decor, don't do anything when clicked
|
|
7312
7177
|
return;
|
|
7178
|
+
// When selecting text in the SearchField that's in the page we want the same selection to persist. It doesn't by itself, since the SearchModal has an entirely different SearchField. Therefore, we manually copy the selection over.
|
|
7179
|
+
const selected_text_range_ = [
|
|
7180
|
+
input_element.selectionStart,
|
|
7181
|
+
input_element.selectionEnd
|
|
7182
|
+
];
|
|
7313
7183
|
align_position?.();
|
|
7314
7184
|
open_modal_({
|
|
7315
|
-
style_props_: modal_body_style
|
|
7185
|
+
style_props_: modal_body_style,
|
|
7186
|
+
selected_text_range_: selected_text_range_
|
|
7316
7187
|
}, ()=>include_input_field_?.on_close_?.());
|
|
7317
7188
|
include_input_field_?.on_open_?.();
|
|
7318
7189
|
}));
|
|
@@ -7388,7 +7259,7 @@ function $b76e8f62b1f313ef$export$a54ec244c8863715(opts) {
|
|
|
7388
7259
|
document.createComment("Search page based on Depict SDK"),
|
|
7389
7260
|
(()=>{
|
|
7390
7261
|
const _el$2 = $b76e8f62b1f313ef$var$_tmpl$2.cloneNode(true), _el$3 = _el$2.firstChild;
|
|
7391
|
-
(0, $g9l4l$insert)(_el$3,
|
|
7262
|
+
(0, $g9l4l$insert)(_el$3, search_field, null);
|
|
7392
7263
|
(0, $g9l4l$insert)(_el$3, make_category_suggestion_card_ ? (0, $g9l4l$createComponent)((0, $a406ebe9523f192f$export$b69d0d92862de18b), {
|
|
7393
7264
|
severity_: "error",
|
|
7394
7265
|
message_: "Category suggestions failed",
|
|
@@ -7543,7 +7414,6 @@ function $a79ffb1cbfbd2a09$export$828dcdd425fd3231(aligner) {
|
|
|
7543
7414
|
}
|
|
7544
7415
|
|
|
7545
7416
|
|
|
7546
|
-
|
|
7547
7417
|
const $540e930c58500cbe$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"></div>`, 2);
|
|
7548
7418
|
/**
|
|
7549
7419
|
* Type for the private properties that are shared between the different exported search SDK wrapper functions. SDK users are not allowed to change/access these, they're an internal implementation detail.
|
|
@@ -7556,7 +7426,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7556
7426
|
#market_signal = (0, $g9l4l$createSignal)();
|
|
7557
7427
|
#modal_open_signal = (0, $g9l4l$createSignal)(false);
|
|
7558
7428
|
static #has_been_constructed = false;
|
|
7559
|
-
constructor({ search_query_url_param_name: search_query_url_param_name = "
|
|
7429
|
+
constructor({ search_query_url_param_name: search_query_url_param_name = "search_query" , url_transformer: url_transformer , on_navigation: raw_on_navigation , enable_category_suggestions: enable_category_suggestions = true , disable_scrolling_during_modal: // Stuff needed for non-standard customer deployments that we shouldn't actually expose
|
|
7560
7430
|
disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal_: bottom_distance_under_modal_ , render_instant_card: render_instant_card , ...props_on_class }){
|
|
7561
7431
|
if ($540e930c58500cbe$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
|
|
7562
7432
|
Object.assign(this, props_on_class);
|
|
@@ -7578,22 +7448,19 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7578
7448
|
target_url.searchParams.set(search_param_name, new_search_query);
|
|
7579
7449
|
on_navigation(target_url.href);
|
|
7580
7450
|
});
|
|
7581
|
-
const
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7586
|
-
|
|
7587
|
-
|
|
7588
|
-
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
search_scroll_restoration_data: []
|
|
7595
|
-
})
|
|
7596
|
-
});
|
|
7451
|
+
const [reset_history_state_, state_] = (0, $3075a4497054bec6$export$9862539c89138352)(()=>({
|
|
7452
|
+
search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
|
|
7453
|
+
search_sorting: undefined,
|
|
7454
|
+
search_filters_open: false,
|
|
7455
|
+
search_sorting_open: false,
|
|
7456
|
+
search_expanded_filters: [],
|
|
7457
|
+
// WARNING, it is insanely important, when creating the signals like this using make_resettable_history_state, that the two lines below are in *precisely that order*. The reason for that is that make_resettable_history_state will write the values of the signals in the order that they are written here when a "popstate" event occurs. If the filter cache is popped before the selected filters are the code in create_modified_filters() in FilterBody.tsx is going to re-calculate search_local_filter_cache without knowing the real value of search_selected_filters, and we'll end up with too few filters in search_local_filter_cache in some cases
|
|
7458
|
+
search_selected_filters: [],
|
|
7459
|
+
search_local_filter_cache: [],
|
|
7460
|
+
search_expanded_hierarchical_filters: [],
|
|
7461
|
+
search_showing_recommendation_rows: (0, $aee0c68312d971f4$export$1c8c715550dc689d),
|
|
7462
|
+
search_scroll_restoration_data: []
|
|
7463
|
+
}));
|
|
7597
7464
|
const search_query_updating_blocked_ = (0, $g9l4l$createSignal)(false);
|
|
7598
7465
|
const { [search_query_url_param_name]: raw_search_query_signal } = (0, $4ad18a8b237ff7f6$export$2542ffb77b620b02)({
|
|
7599
7466
|
[search_query_url_param_name]: ""
|
|
@@ -7615,9 +7482,9 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7615
7482
|
});
|
|
7616
7483
|
const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
|
|
7617
7484
|
const clear_filters_on_next_submit_ = (0, $a0d89ff25220eb8d$export$e026af0c7b64ea5f)({
|
|
7618
|
-
selected_filters_:
|
|
7485
|
+
selected_filters_: state_.search_selected_filters,
|
|
7619
7486
|
search_query_: search_query_signal_,
|
|
7620
|
-
current_sorting_:
|
|
7487
|
+
current_sorting_: state_.search_sorting,
|
|
7621
7488
|
expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
|
|
7622
7489
|
i18n_: i18n_,
|
|
7623
7490
|
local_filter_cache_: state_.search_local_filter_cache
|
|
@@ -7640,9 +7507,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7640
7507
|
configured_submit_query_: configured_submit_query_,
|
|
7641
7508
|
search_query_signal_: search_query_signal_,
|
|
7642
7509
|
i18n_: i18n_,
|
|
7643
|
-
search_query_updating_blocked_: search_query_updating_blocked_
|
|
7644
|
-
current_sorting_: current_sorting_,
|
|
7645
|
-
selected_filters_: selected_filters_
|
|
7510
|
+
search_query_updating_blocked_: search_query_updating_blocked_
|
|
7646
7511
|
});
|
|
7647
7512
|
(0, $2864fd26f57ff474$export$5162a71f252e6122)();
|
|
7648
7513
|
(0, $g9l4l$catchify)(async ()=>{
|
|
@@ -7669,7 +7534,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7669
7534
|
min_products_to_fetch_: $540e930c58500cbe$var$min_products_to_fetch_,
|
|
7670
7535
|
render_instant_card_: render_instant_card,
|
|
7671
7536
|
render_instant_card_placeholder_: (0, $aaacfac0064e97d9$export$ee1733d9a8495996),
|
|
7672
|
-
has_sort_or_filters_: (0, $g9l4l$createMemo)(()=>!!(Object.keys(
|
|
7537
|
+
has_sort_or_filters_: (0, $g9l4l$createMemo)(()=>!!(Object.keys(state_.search_selected_filters[0]())?.length || state_.search_sorting[0]()))
|
|
7673
7538
|
},
|
|
7674
7539
|
i18n_: i18n_,
|
|
7675
7540
|
enable_category_suggestions_: enable_category_suggestions,
|
|
@@ -7809,7 +7674,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
7809
7674
|
});
|
|
7810
7675
|
});
|
|
7811
7676
|
},
|
|
7812
|
-
current_sorting_:
|
|
7677
|
+
current_sorting_: state_.search_sorting,
|
|
7813
7678
|
search_filters_open_: state_.search_filters_open,
|
|
7814
7679
|
search_sorting_open_: state_.search_sorting_open,
|
|
7815
7680
|
expanded_filters_: state_.search_expanded_filters,
|
|
@@ -7820,7 +7685,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
7820
7685
|
});
|
|
7821
7686
|
} : false,
|
|
7822
7687
|
expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
|
|
7823
|
-
selected_filters_:
|
|
7688
|
+
selected_filters_: state_.search_selected_filters,
|
|
7824
7689
|
showing_recommendation_rows_: state_.search_showing_recommendation_rows,
|
|
7825
7690
|
scroll_restoration_data_: state_.search_scroll_restoration_data,
|
|
7826
7691
|
include_input_field_: include_input_field,
|
|
@@ -7851,7 +7716,8 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
7851
7716
|
function $540e930c58500cbe$export$316f6f283ae64765({ depict_search: depict_search , modal_dispose_handler: modal_dispose_handler , click_handler: click_handler , aligner_ref: aligner_ref }) {
|
|
7852
7717
|
const shared_properties = $540e930c58500cbe$var$get_shared_properties(depict_search);
|
|
7853
7718
|
return (0, $c7f938ac40924f3b$export$23fca46f3143581f)(()=>{
|
|
7854
|
-
|
|
7719
|
+
let input_element;
|
|
7720
|
+
const search_field = (0, $g9l4l$createComponent)((0, $6ded59a142c93078$export$b94867ecbd698f21), {
|
|
7855
7721
|
get search_query_ () {
|
|
7856
7722
|
return shared_properties.search_query_signal_;
|
|
7857
7723
|
},
|
|
@@ -7868,35 +7734,40 @@ function $540e930c58500cbe$export$316f6f283ae64765({ depict_search: depict_searc
|
|
|
7868
7734
|
return shared_properties.i18n_;
|
|
7869
7735
|
},
|
|
7870
7736
|
disabled_: true,
|
|
7737
|
+
input_field_ref_: (el)=>input_element = el,
|
|
7871
7738
|
field_element_ref_: (field)=>{
|
|
7872
7739
|
const style_props_ = (0, $g9l4l$createSignal)({
|
|
7873
7740
|
position: "fixed"
|
|
7874
7741
|
});
|
|
7875
7742
|
const defaultHandler = (0, $g9l4l$catchify)(()=>{
|
|
7876
|
-
|
|
7743
|
+
// When selecting text in the SearchField that's in the page we want the same selection to persist. It doesn't by itself, since the SearchModal has an entirely different SearchField. Therefore, we manually copy the selection over.
|
|
7744
|
+
const selected_text_range_ = [
|
|
7745
|
+
input_element.selectionStart,
|
|
7746
|
+
input_element.selectionEnd
|
|
7747
|
+
];
|
|
7748
|
+
const { cleanup: cleanup } = $540e930c58500cbe$var$align_field_modal(style_props_, search_field, aligner_ref);
|
|
7877
7749
|
const complete_modal_dispose_handler = ()=>{
|
|
7878
7750
|
modal_dispose_handler?.();
|
|
7879
7751
|
cleanup();
|
|
7880
7752
|
};
|
|
7881
7753
|
depict_search.modal_open = [
|
|
7882
7754
|
{
|
|
7883
|
-
style_props_: style_props_
|
|
7755
|
+
style_props_: style_props_,
|
|
7756
|
+
selected_text_range_: selected_text_range_
|
|
7884
7757
|
},
|
|
7885
7758
|
complete_modal_dispose_handler
|
|
7886
7759
|
];
|
|
7887
7760
|
});
|
|
7888
7761
|
const handler = click_handler ?? defaultHandler;
|
|
7889
7762
|
field.addEventListener("click", handler);
|
|
7890
|
-
(0, $g9l4l$onCleanup)(()=>
|
|
7891
|
-
field.removeEventListener("click", handler);
|
|
7892
|
-
});
|
|
7763
|
+
(0, $g9l4l$onCleanup)(()=>field.removeEventListener("click", handler));
|
|
7893
7764
|
}
|
|
7894
7765
|
});
|
|
7895
7766
|
// We assume this to be an array containing exactly on div in js-ui
|
|
7896
7767
|
return [
|
|
7897
7768
|
(()=>{
|
|
7898
7769
|
const _el$ = $540e930c58500cbe$var$_tmpl$.cloneNode(true);
|
|
7899
|
-
(0, $g9l4l$insert)(_el$,
|
|
7770
|
+
(0, $g9l4l$insert)(_el$, search_field);
|
|
7900
7771
|
return _el$;
|
|
7901
7772
|
})()
|
|
7902
7773
|
];
|
|
@@ -7926,6 +7797,7 @@ function $540e930c58500cbe$var$align_field_modal(style_props_, input, aligner_re
|
|
|
7926
7797
|
|
|
7927
7798
|
|
|
7928
7799
|
|
|
7800
|
+
|
|
7929
7801
|
const $7cbfd6122dbaf087$export$d86a33413558014e = (openModalParams)=>{
|
|
7930
7802
|
const { search: search } = openModalParams;
|
|
7931
7803
|
openModalParams.location ||= "centered";
|
|
@@ -8183,4 +8055,4 @@ class $ba6c9609228edf6b$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8183
8055
|
(0, $g9l4l$add_to_version_info)("ui", (0, $18bf1d29fb889cca$export$83d89fbfd8236492));
|
|
8184
8056
|
|
|
8185
8057
|
|
|
8186
|
-
export {$e95f1855a5e3864f$export$58e808b1db15d3bc as fetchDepictRecommendations, $ec52ef1e6c117813$export$de035477d6fef996 as QuickLinks, $ec52ef1e6c117813$export$5b7c3ce0ebe51f86 as BreadCrumbs, $6340962f8bafd049$export$b91cec6bdc6b32a1 as CategoryTitle, $9b693ea3ff420de6$export$824dde41348efed1 as embedded_num_products, $80a49d3809ecb080$export$643598a327b5833e as get_categories, $ec52ef1e6c117813$export$f34314aa9505732e as DepictCategory, $ec52ef1e6c117813$export$e2bf8ce7779e827e as CategoryPage, $540e930c58500cbe$export$ac6237957a15b3f0 as DepictSearch, $540e930c58500cbe$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $540e930c58500cbe$export$f2dc7e4e4aa11abb as SearchPage, $540e930c58500cbe$export$316f6f283ae64765 as SearchField, $7cbfd6122dbaf087$export$d86a33413558014e as open_modal_with_alignment, $aaacfac0064e97d9$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $079defea521d5e2a$export$b3ad617e9036868 as align_field, $b4e6a093ae83373b$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $246aa49a8f85c7f3$export$1233ca167bf71f9a as styles_to_valid_css_string, $a1123c5ed9b0ee29$export$fe334901e8bebd57 as disable_scrolling, $a3e81b85527bc866$export$d0596b5cae35ad4 as open_search_with_shift_slash, $972ebf2641490830$export$26df08e242fe83a3 as push_state_with_query_param_value, $3846bb34098c738f$export$e015ed2f2950f2e3 as DepictAPI, $fefe7683325039b3$export$d9f36cf74e24d595 as media_query_to_accessor, $36316d7b4c897a03$export$689e204eadb33baf as setup_fast_leave, $886fa987db4f3805$export$5196e4c01fa56fcb as show_toast, $5178263ed1e394ca$export$469c7af753d08925 as solid_format_price, $a79ffb1cbfbd2a09$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $ba6c9609228edf6b$export$3ccaa27d81dd8556 as PageReplacer, $18bf1d29fb889cca$export$83d89fbfd8236492 as version};
|
|
8058
|
+
export {$e95f1855a5e3864f$export$58e808b1db15d3bc as fetchDepictRecommendations, $ec52ef1e6c117813$export$de035477d6fef996 as QuickLinks, $ec52ef1e6c117813$export$5b7c3ce0ebe51f86 as BreadCrumbs, $6340962f8bafd049$export$b91cec6bdc6b32a1 as CategoryTitle, $9b693ea3ff420de6$export$824dde41348efed1 as embedded_num_products, $80a49d3809ecb080$export$643598a327b5833e as get_categories, $ec52ef1e6c117813$export$f34314aa9505732e as DepictCategory, $ec52ef1e6c117813$export$e2bf8ce7779e827e as CategoryPage, $540e930c58500cbe$export$ac6237957a15b3f0 as DepictSearch, $540e930c58500cbe$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $540e930c58500cbe$export$f2dc7e4e4aa11abb as SearchPage, $540e930c58500cbe$export$316f6f283ae64765 as SearchField, $22d7fd594100c3d0$export$aa14a9f43128f61f as ProductCardError, $7cbfd6122dbaf087$export$d86a33413558014e as open_modal_with_alignment, $aaacfac0064e97d9$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $079defea521d5e2a$export$b3ad617e9036868 as align_field, $b4e6a093ae83373b$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $246aa49a8f85c7f3$export$1233ca167bf71f9a as styles_to_valid_css_string, $a1123c5ed9b0ee29$export$fe334901e8bebd57 as disable_scrolling, $a3e81b85527bc866$export$d0596b5cae35ad4 as open_search_with_shift_slash, $972ebf2641490830$export$26df08e242fe83a3 as push_state_with_query_param_value, $3846bb34098c738f$export$e015ed2f2950f2e3 as DepictAPI, $fefe7683325039b3$export$d9f36cf74e24d595 as media_query_to_accessor, $36316d7b4c897a03$export$689e204eadb33baf as setup_fast_leave, $886fa987db4f3805$export$5196e4c01fa56fcb as show_toast, $5178263ed1e394ca$export$469c7af753d08925 as solid_format_price, $a79ffb1cbfbd2a09$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $ba6c9609228edf6b$export$3ccaa27d81dd8556 as PageReplacer, $18bf1d29fb889cca$export$83d89fbfd8236492 as version};
|