@depict-ai/ui 0.0.63 → 0.0.64
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 +6 -6
- package/dist/main.js +458 -226
- package/dist/module.js +460 -228
- package/dist/moduule.js +7872 -0
- package/package.json +5 -4
- package/dist/typescript_schema/BaseSearchRequest.d.ts +0 -197
- package/dist/typescript_schema/ProductListingQueriesRequest.d.ts +0 -14
- package/dist/typescript_schema/ProductListingQueriesResponse.d.ts +0 -10
- package/dist/typescript_schema/ProductListingRequest.d.ts +0 -221
- package/dist/typescript_schema/ProductListingResponse.d.ts +0 -232
- package/dist/typescript_schema/RecommendResponse.d.ts +0 -15
- package/dist/typescript_schema/SearchRequest.d.ts +0 -213
- package/dist/typescript_schema/SearchResponse.d.ts +0 -192
- package/dist/typescript_schema/SearchSuggestionsRequest.d.ts +0 -18
- package/dist/typescript_schema/SearchSuggestionsResponse.d.ts +0 -182
- package/dist/typescript_schema/TrackV2Request.d.ts +0 -115
package/dist/module.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, 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,
|
|
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, queueMacroTask as $g9l4l$queueMacroTask, 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, 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, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, instant_exec_on_suspect_history_change as $g9l4l$instant_exec_on_suspect_history_change, 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
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, memo as $g9l4l$memo, style as $g9l4l$style, mergeProps as $g9l4l$mergeProps, classList as $g9l4l$classList, 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, on as $g9l4l$on, Index as $g9l4l$Index, For as $g9l4l$For, ErrorBoundary as $g9l4l$ErrorBoundary} from "solid-js";
|
|
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, createReaction as $g9l4l$createReaction, 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, on as $g9l4l$on, Index as $g9l4l$Index, For as $g9l4l$For, ErrorBoundary as $g9l4l$ErrorBoundary} from "solid-js";
|
|
4
|
+
import {decompressFromBase64 as $g9l4l$decompressFromBase64, compressToBase64 as $g9l4l$compressToBase64} from "lz-string";
|
|
4
5
|
|
|
5
|
-
/*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.
|
|
6
|
+
/*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.64";
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
@@ -56,14 +57,16 @@ function $014a147d094b0d08$var$history_state_change(signals, entries, state) {
|
|
|
56
57
|
}
|
|
57
58
|
|
|
58
59
|
|
|
59
|
-
function $
|
|
60
|
-
const state = (0, $014a147d094b0d08$export$e183a13865960371)(
|
|
60
|
+
function $764ea8aa12c4fc5b$export$90a2b6b3fb2a1455({ get_default_values_: get_default_values_ , current_sorting_: [, set_current_sorting] , selected_filters_: [get_selected_filters, set_selected_filters] }) {
|
|
61
|
+
const state = (0, $014a147d094b0d08$export$e183a13865960371)(get_default_values_());
|
|
61
62
|
const reset_state = ()=>{
|
|
62
|
-
const new_defaults =
|
|
63
|
+
const new_defaults = get_default_values_();
|
|
63
64
|
for(const key in state){
|
|
64
65
|
const new_value = new_defaults[key];
|
|
65
66
|
state[key][1](new_value);
|
|
66
67
|
}
|
|
68
|
+
set_current_sorting();
|
|
69
|
+
if (get_selected_filters().length > 0) set_selected_filters([]);
|
|
67
70
|
};
|
|
68
71
|
return [
|
|
69
72
|
reset_state,
|
|
@@ -2746,156 +2749,6 @@ var $7b224b353182ce9a$export$2e2bcd8739ae039 = {
|
|
|
2746
2749
|
|
|
2747
2750
|
|
|
2748
2751
|
|
|
2749
|
-
function $dd3727f29e682893$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
|
|
2750
|
-
let last_remote_state;
|
|
2751
|
-
(0, $g9l4l$createComputed)(()=>{
|
|
2752
|
-
const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
|
|
2753
|
-
JSON.stringify([
|
|
2754
|
-
filter.field,
|
|
2755
|
-
filter.op,
|
|
2756
|
-
filter?.meta?.type
|
|
2757
|
-
]),
|
|
2758
|
-
filter
|
|
2759
|
-
]) || []);
|
|
2760
|
-
const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
|
|
2761
|
-
JSON.stringify([
|
|
2762
|
-
filter.field,
|
|
2763
|
-
filter.op,
|
|
2764
|
-
filter?.meta?.type
|
|
2765
|
-
]),
|
|
2766
|
-
filter
|
|
2767
|
-
]));
|
|
2768
|
-
const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
|
|
2769
|
-
JSON.stringify([
|
|
2770
|
-
filter_obj.field,
|
|
2771
|
-
filter_obj.op
|
|
2772
|
-
]),
|
|
2773
|
-
filter_obj
|
|
2774
|
-
]));
|
|
2775
|
-
const new_local_filter_state = [];
|
|
2776
|
-
// 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
|
|
2777
|
-
for (const filter_id of [
|
|
2778
|
-
...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
|
|
2779
|
-
...Object.keys(remote_filters)
|
|
2780
|
-
]){
|
|
2781
|
-
const local_filter = local_filters[filter_id];
|
|
2782
|
-
const remote_filter = remote_filters[filter_id];
|
|
2783
|
-
const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
|
|
2784
|
-
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
|
|
2785
|
-
{
|
|
2786
|
-
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]));
|
|
2787
|
-
} else if (!local_filter) // just take the remote one
|
|
2788
|
-
new_local_filter_state.push(remote_filter);
|
|
2789
|
-
else {
|
|
2790
|
-
// both exist, merge them if needed
|
|
2791
|
-
const remote_meta = remote_filter.meta;
|
|
2792
|
-
const local_meta = local_filter.meta;
|
|
2793
|
-
const this_applied_filter = selected_filters[filter_id_without_meta_type];
|
|
2794
|
-
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
|
|
2795
|
-
new_local_filter_state.push(remote_filter);
|
|
2796
|
-
else {
|
|
2797
|
-
const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
|
|
2798
|
-
JSON.stringify(value),
|
|
2799
|
-
{
|
|
2800
|
-
value_: value,
|
|
2801
|
-
count_: remote_meta.counts?.[index],
|
|
2802
|
-
name_: remote_meta.names?.[index]
|
|
2803
|
-
}
|
|
2804
|
-
]));
|
|
2805
|
-
const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
|
|
2806
|
-
JSON.stringify(value),
|
|
2807
|
-
{
|
|
2808
|
-
value_: value,
|
|
2809
|
-
count_: 0,
|
|
2810
|
-
name_: local_meta.names?.[index]
|
|
2811
|
-
}
|
|
2812
|
-
]));
|
|
2813
|
-
const new_data = [
|
|
2814
|
-
...Object.keys(data_objs_in_local).filter((key)=>{
|
|
2815
|
-
// put data entries that are selected and don't exist in new remote state first
|
|
2816
|
-
if (key in data_objs_in_remote) return false;
|
|
2817
|
-
const selected_values = this_applied_filter.data;
|
|
2818
|
-
return selected_values.some((value)=>{
|
|
2819
|
-
const is_equal = JSON.stringify(value) === key;
|
|
2820
|
-
if (is_equal) return true;
|
|
2821
|
-
if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
|
|
2822
|
-
// 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.
|
|
2823
|
-
const selected_values = data_objs_in_local[key].value_;
|
|
2824
|
-
const values_length = value?.length;
|
|
2825
|
-
if (values_length > 1 && values_length - 1 === selected_values.length) {
|
|
2826
|
-
let is_parent = true;
|
|
2827
|
-
for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
|
|
2828
|
-
return is_parent;
|
|
2829
|
-
}
|
|
2830
|
-
}
|
|
2831
|
-
return false;
|
|
2832
|
-
});
|
|
2833
|
-
}).map((key)=>data_objs_in_local[key]),
|
|
2834
|
-
...Object.values(data_objs_in_remote)
|
|
2835
|
-
];
|
|
2836
|
-
const new_values = new_data.map(({ value_: value_ })=>value_);
|
|
2837
|
-
const result = {
|
|
2838
|
-
...remote_filter,
|
|
2839
|
-
meta: {
|
|
2840
|
-
...remote_filter.meta,
|
|
2841
|
-
values: new_values,
|
|
2842
|
-
names: new_data.map(({ name_: name_ })=>name_),
|
|
2843
|
-
counts: new_data.map(({ count_: count_ })=>count_)
|
|
2844
|
-
}
|
|
2845
|
-
};
|
|
2846
|
-
new_local_filter_state.push(result);
|
|
2847
|
-
}
|
|
2848
|
-
}
|
|
2849
|
-
}
|
|
2850
|
-
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
|
|
2851
|
-
JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
|
|
2852
|
-
write_local_cache(new_local_filter_state);
|
|
2853
|
-
last_remote_state = available_filters_();
|
|
2854
|
-
});
|
|
2855
|
-
return read_local_cache;
|
|
2856
|
-
}
|
|
2857
|
-
/**
|
|
2858
|
-
* 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.
|
|
2859
|
-
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
2860
|
-
*/ function $dd3727f29e682893$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
2861
|
-
const old_meta = local_filter_object.meta;
|
|
2862
|
-
const selected_filter_data = selected_filter.data;
|
|
2863
|
-
const modified_filter_object = {
|
|
2864
|
-
...local_filter_object
|
|
2865
|
-
};
|
|
2866
|
-
if (old_meta) {
|
|
2867
|
-
const new_meta = {
|
|
2868
|
-
...old_meta
|
|
2869
|
-
};
|
|
2870
|
-
modified_filter_object.meta = new_meta;
|
|
2871
|
-
// set counts to 0
|
|
2872
|
-
if ("counts" in new_meta) {
|
|
2873
|
-
const counts = new_meta.counts;
|
|
2874
|
-
if (counts) new_meta.counts = counts.map(()=>0);
|
|
2875
|
-
}
|
|
2876
|
-
if (Array.isArray(selected_filter_data) && "values" in new_meta) {
|
|
2877
|
-
// we have an array of values and want to strip the ones from the available ones that aren't selected
|
|
2878
|
-
const values = new_meta.values;
|
|
2879
|
-
if (Array.isArray(values)) {
|
|
2880
|
-
const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
|
|
2881
|
-
const indexes_to_remove = new Set();
|
|
2882
|
-
for(let i = 0; i < values.length; i++){
|
|
2883
|
-
const value = values[i];
|
|
2884
|
-
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
|
|
2885
|
-
indexes_to_remove.add(i);
|
|
2886
|
-
}
|
|
2887
|
-
new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
|
|
2888
|
-
if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
|
|
2889
|
-
if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
|
|
2890
|
-
new_meta.counts.length -= indexes_to_remove.size;
|
|
2891
|
-
}
|
|
2892
|
-
}
|
|
2893
|
-
}
|
|
2894
|
-
return modified_filter_object;
|
|
2895
|
-
}
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
2752
|
|
|
2900
2753
|
|
|
2901
2754
|
|
|
@@ -3062,11 +2915,7 @@ function $8aff437d739a524d$export$3f1a388cc0d8fed7(props) {
|
|
|
3062
2915
|
});
|
|
3063
2916
|
}
|
|
3064
2917
|
function $8aff437d739a524d$var$ActualFilterBody(props) {
|
|
3065
|
-
const modified_available_filters_with_selected_unexisting_ones_injected_from_local_state =
|
|
3066
|
-
available_filters_: props.available_filters_,
|
|
3067
|
-
selected_filters_: props.selected_filters_,
|
|
3068
|
-
local_filter_cache_: props.local_filter_cache_
|
|
3069
|
-
});
|
|
2918
|
+
const [modified_available_filters_with_selected_unexisting_ones_injected_from_local_state] = props.local_filter_cache_;
|
|
3070
2919
|
const togglable_filters = (0, $g9l4l$createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>item?.meta?.group_title));
|
|
3071
2920
|
const untogglable_filters = (0, $g9l4l$createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>!item?.meta?.group_title));
|
|
3072
2921
|
const togglable_filters_grouped_by_collapsible = (0, $g9l4l$createMemo)(()=>{
|
|
@@ -3267,9 +3116,10 @@ function $8aff437d739a524d$var$ActualFilterBody(props) {
|
|
|
3267
3116
|
|
|
3268
3117
|
|
|
3269
3118
|
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);
|
|
3270
|
-
function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_:
|
|
3119
|
+
function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: [get_current_sorting, set_current_sorting] }) {
|
|
3271
3120
|
const title_radio_name = (0, $g9l4l$make_random_classname)();
|
|
3272
3121
|
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);
|
|
3273
3123
|
return (0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
3274
3124
|
get when () {
|
|
3275
3125
|
return available_sortings_()?.length;
|
|
@@ -3301,14 +3151,14 @@ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: availa
|
|
|
3301
3151
|
},
|
|
3302
3152
|
children: (item, index)=>{
|
|
3303
3153
|
const is_checked = (0, $g9l4l$createMemo)(()=>{
|
|
3304
|
-
const sort =
|
|
3154
|
+
const sort = get_current_sorting();
|
|
3305
3155
|
if (!sort) // if no sortings are selected, "select" first sort
|
|
3306
3156
|
return index === 0;
|
|
3307
3157
|
return sort.field === item().field && (sort.order === item().order || item().meta.values?.length > 1);
|
|
3308
3158
|
});
|
|
3309
3159
|
return /* wrapping div for flex gap polyfill scss mixin */ (()=>{
|
|
3310
3160
|
const _el$8 = $c23bd3d951eee1f2$var$_tmpl$4.cloneNode(true), _el$9 = _el$8.firstChild, _el$10 = _el$9.firstChild, _el$11 = _el$10.nextSibling;
|
|
3311
|
-
(0, $g9l4l$addEventListener)(_el$10, "change", (0, $g9l4l$catchify)(()=>
|
|
3161
|
+
(0, $g9l4l$addEventListener)(_el$10, "change", (0, $g9l4l$catchify)(()=>set_current_sorting(item())));
|
|
3312
3162
|
(0, $g9l4l$setAttribute)(_el$10, "name", title_radio_name);
|
|
3313
3163
|
(0, $g9l4l$insert)(_el$9, ()=>item().meta.title, null);
|
|
3314
3164
|
(0, $g9l4l$effect)(()=>_el$10.checked = is_checked());
|
|
@@ -3320,27 +3170,25 @@ function $c23bd3d951eee1f2$export$1f1775a58da589b5({ available_sortings_: availa
|
|
|
3320
3170
|
})(),
|
|
3321
3171
|
(0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
3322
3172
|
get when () {
|
|
3323
|
-
return
|
|
3173
|
+
return meta_of_currently_selected_sorting()?.values?.length > 1;
|
|
3324
3174
|
},
|
|
3325
3175
|
get children () {
|
|
3326
3176
|
const _el$2 = $c23bd3d951eee1f2$var$_tmpl$2.cloneNode(true);
|
|
3327
3177
|
(0, $g9l4l$insert)(_el$2, (0, $g9l4l$createComponent)((0, $g9l4l$Index), {
|
|
3328
3178
|
get each () {
|
|
3329
|
-
return
|
|
3179
|
+
return meta_of_currently_selected_sorting()?.values;
|
|
3330
3180
|
},
|
|
3331
3181
|
children: (order_value, index)=>{
|
|
3182
|
+
const is_checked = (0, $g9l4l$createMemo)(()=>get_current_sorting()?.order === order_value());
|
|
3332
3183
|
return (()=>{
|
|
3333
3184
|
const _el$12 = $c23bd3d951eee1f2$var$_tmpl$4.cloneNode(true), _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling;
|
|
3334
|
-
(0, $g9l4l$addEventListener)(_el$14, "change", (0, $g9l4l$catchify)(()=>
|
|
3185
|
+
(0, $g9l4l$addEventListener)(_el$14, "change", (0, $g9l4l$catchify)(()=>set_current_sorting((c)=>c && {
|
|
3335
3186
|
...c,
|
|
3336
3187
|
order: order_value()
|
|
3337
3188
|
})));
|
|
3338
3189
|
(0, $g9l4l$setAttribute)(_el$14, "name", order_radio_name);
|
|
3339
|
-
(0, $g9l4l$insert)(_el$13, ()=>
|
|
3340
|
-
(0, $g9l4l$effect)(()=>_el$14.checked = (
|
|
3341
|
-
const sort = current_sorting_[0]();
|
|
3342
|
-
return sort?.order === order_value();
|
|
3343
|
-
})());
|
|
3190
|
+
(0, $g9l4l$insert)(_el$13, ()=>meta_of_currently_selected_sorting()?.names?.[index], null);
|
|
3191
|
+
(0, $g9l4l$effect)(()=>_el$14.checked = is_checked());
|
|
3344
3192
|
return _el$12;
|
|
3345
3193
|
})();
|
|
3346
3194
|
}
|
|
@@ -3685,12 +3533,167 @@ function $fd7da6fb3e08aa40$export$9bf11afa910f536e({ args_for_sorting_: args_for
|
|
|
3685
3533
|
|
|
3686
3534
|
|
|
3687
3535
|
|
|
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
|
+
|
|
3688
3685
|
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);
|
|
3689
3686
|
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_ }) {
|
|
3690
3687
|
return (0, $a406ebe9523f192f$export$b69d0d92862de18b)({
|
|
3691
3688
|
severity_: "error",
|
|
3692
3689
|
message_: "Sorting and filters failed",
|
|
3693
3690
|
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
|
+
});
|
|
3694
3697
|
const cleanup_promise = new Promise((r)=>(0, $g9l4l$onCleanup)(r));
|
|
3695
3698
|
const [filters_open, set_filters_open] = search_filters_open_;
|
|
3696
3699
|
const [sorting_open, set_sorting_open] = search_sorting_open_;
|
|
@@ -4061,6 +4064,166 @@ function $4a2667e8d77eb55a$var$ActualFloatingButtons({ search_filters_open_: [ge
|
|
|
4061
4064
|
|
|
4062
4065
|
|
|
4063
4066
|
|
|
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
|
+
|
|
4064
4227
|
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);
|
|
4065
4228
|
function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_data , on_crumb_click_: on_crumb_click_ , i18n_: i18n_ }) {
|
|
4066
4229
|
const placeholder_crumb_data = [
|
|
@@ -4078,11 +4241,20 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4078
4241
|
get each () {
|
|
4079
4242
|
return crumb_data();
|
|
4080
4243
|
},
|
|
4081
|
-
children: (
|
|
4244
|
+
children: (unmodified_display_accessor, index)=>{
|
|
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
|
+
});
|
|
4082
4254
|
return [
|
|
4083
4255
|
(0, $g9l4l$createComponent)((0, $g9l4l$Show), {
|
|
4084
4256
|
get when () {
|
|
4085
|
-
return
|
|
4257
|
+
return modified_display_accessor();
|
|
4086
4258
|
},
|
|
4087
4259
|
get fallback () {
|
|
4088
4260
|
return (0, $g9l4l$createComponent)((0, $g9l4l$Placeholder), {
|
|
@@ -4092,9 +4264,9 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4092
4264
|
},
|
|
4093
4265
|
get children () {
|
|
4094
4266
|
const _el$2 = $1b5a927e48d892a1$var$_tmpl$2.cloneNode(true);
|
|
4095
|
-
(0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)((ev)=>on_crumb_click_(ev,
|
|
4096
|
-
(0, $g9l4l$insert)(_el$2, ()=>
|
|
4097
|
-
(0, $g9l4l$effect)(()=>(0, $g9l4l$setAttribute)(_el$2, "href",
|
|
4267
|
+
(0, $g9l4l$addEventListener)(_el$2, "click", (0, $g9l4l$catchify)((ev)=>on_crumb_click_(ev, modified_display_accessor())), true);
|
|
4268
|
+
(0, $g9l4l$insert)(_el$2, ()=>modified_display_accessor().title);
|
|
4269
|
+
(0, $g9l4l$effect)(()=>(0, $g9l4l$setAttribute)(_el$2, "href", modified_display_accessor().page_url));
|
|
4098
4270
|
return _el$2;
|
|
4099
4271
|
}
|
|
4100
4272
|
}),
|
|
@@ -4131,7 +4303,9 @@ function $1b5a927e48d892a1$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4131
4303
|
|
|
4132
4304
|
|
|
4133
4305
|
|
|
4306
|
+
|
|
4134
4307
|
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";
|
|
4135
4309
|
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_ }) {
|
|
4136
4310
|
let scrolling_logic_ran_for_query_id = false;
|
|
4137
4311
|
let last_scroll_position;
|
|
@@ -4253,20 +4427,43 @@ function $6af87e1502f04aa3$export$466cdc317043f6cb({ quicklinks_data_: quicklink
|
|
|
4253
4427
|
get each () {
|
|
4254
4428
|
return place_holdey_quicklinks_data();
|
|
4255
4429
|
},
|
|
4256
|
-
children: (
|
|
4430
|
+
children: (unmodified_display_accessor, index)=>{
|
|
4257
4431
|
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
|
+
});
|
|
4258
4455
|
return (()=>{
|
|
4259
4456
|
const _el$3 = $6af87e1502f04aa3$var$_tmpl$3.cloneNode(true);
|
|
4260
4457
|
(0, $g9l4l$addEventListener)(_el$3, "click", (0, $g9l4l$catchify)((ev)=>{
|
|
4261
4458
|
if (is_selected() && !ev.metaKey && !ev.ctrlKey && !ev.button) ev.preventDefault();
|
|
4262
|
-
else if (
|
|
4459
|
+
else if (modified_display_accessor()) on_link_click_(ev, modified_display_accessor());
|
|
4263
4460
|
}), true);
|
|
4264
|
-
(0, $g9l4l$insert)(_el$3, ()=>
|
|
4461
|
+
(0, $g9l4l$insert)(_el$3, ()=>modified_display_accessor()?.title || (0, $g9l4l$createComponent)((0, $g9l4l$Placeholder), {
|
|
4265
4462
|
height: "1em",
|
|
4266
4463
|
width: "10ch"
|
|
4267
4464
|
}));
|
|
4268
4465
|
(0, $g9l4l$effect)((_p$)=>{
|
|
4269
|
-
const _v$ = !!is_selected(), _v$2 =
|
|
4466
|
+
const _v$ = !!is_selected(), _v$2 = modified_display_accessor()?.page_url || "javascript:void(0)";
|
|
4270
4467
|
_v$ !== _p$._v$ && _el$3.classList.toggle("selected", _p$._v$ = _v$);
|
|
4271
4468
|
_v$2 !== _p$._v$2 && (0, $g9l4l$setAttribute)(_el$3, "href", _p$._v$2 = _v$2);
|
|
4272
4469
|
return _p$;
|
|
@@ -4441,6 +4638,7 @@ let $01115659405f3c64$export$44dad306455dddf;
|
|
|
4441
4638
|
})($01115659405f3c64$export$44dad306455dddf || ($01115659405f3c64$export$44dad306455dddf = {}));
|
|
4442
4639
|
|
|
4443
4640
|
|
|
4641
|
+
|
|
4444
4642
|
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);
|
|
4445
4643
|
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_ }) {
|
|
4446
4644
|
let results_for;
|
|
@@ -4463,6 +4661,26 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4463
4661
|
const first_result_in_viewport_ = (0, $g9l4l$createSignal)();
|
|
4464
4662
|
const last_result_in_viewport_ = (0, $g9l4l$createSignal)();
|
|
4465
4663
|
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
|
+
});
|
|
4466
4684
|
const query_base_ = (0, $930337c3b3b5f896$export$210f130a61ac1e8d)(()=>{
|
|
4467
4685
|
const sort_obj = get_sorting() && {
|
|
4468
4686
|
...get_sorting()
|
|
@@ -4494,6 +4712,7 @@ function $1ae892b13d7746ab$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4494
4712
|
} : {}
|
|
4495
4713
|
})
|
|
4496
4714
|
})));
|
|
4715
|
+
tracking_function_for_plp_results(plp_results_);
|
|
4497
4716
|
const available_sortings_ = (0, $g9l4l$createMemo)(()=>plp_results_()?.sorts?.map((sort)=>({
|
|
4498
4717
|
...sort,
|
|
4499
4718
|
order: sort.order ?? "desc"
|
|
@@ -4870,6 +5089,7 @@ function $c7f938ac40924f3b$export$23fca46f3143581f(component, error_message) {
|
|
|
4870
5089
|
}
|
|
4871
5090
|
|
|
4872
5091
|
|
|
5092
|
+
|
|
4873
5093
|
const $ec52ef1e6c117813$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp category"></div>`, 2);
|
|
4874
5094
|
const $ec52ef1e6c117813$var$min_products_to_fetch_ = 20;
|
|
4875
5095
|
const $ec52ef1e6c117813$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
@@ -4915,17 +5135,20 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
|
|
|
4915
5135
|
$ec52ef1e6c117813$export$f34314aa9505732e.#has_been_constructed = true;
|
|
4916
5136
|
Object.assign(this, props_on_class); // set initial signal values
|
|
4917
5137
|
(0, $2864fd26f57ff474$export$5162a71f252e6122)();
|
|
4918
|
-
const
|
|
4919
|
-
|
|
4920
|
-
|
|
4921
|
-
|
|
4922
|
-
|
|
4923
|
-
|
|
4924
|
-
|
|
4925
|
-
|
|
4926
|
-
|
|
4927
|
-
|
|
4928
|
-
|
|
5138
|
+
const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $4ebab5f2b1a65493$export$7bcff1eb3eca57d7)();
|
|
5139
|
+
const [reset_history_state_, state_] = (0, $764ea8aa12c4fc5b$export$90a2b6b3fb2a1455)({
|
|
5140
|
+
selected_filters_: selected_filters_,
|
|
5141
|
+
current_sorting_: current_sorting_,
|
|
5142
|
+
get_default_values_: ()=>({
|
|
5143
|
+
category_filters_open: false,
|
|
5144
|
+
category_sorting_open: false,
|
|
5145
|
+
category_expanded_filters: [],
|
|
5146
|
+
// 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
|
|
5147
|
+
category_local_filter_cache: [],
|
|
5148
|
+
category_expanded_hierarchical_filters: [],
|
|
5149
|
+
category_scroll_restoration_data: []
|
|
5150
|
+
})
|
|
5151
|
+
});
|
|
4929
5152
|
const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
|
|
4930
5153
|
const on_category_link_click_ = (e, d)=>{
|
|
4931
5154
|
if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
|
|
@@ -4950,6 +5173,8 @@ class $ec52ef1e6c117813$export$f34314aa9505732e {
|
|
|
4950
5173
|
reset_history_state_: reset_history_state_,
|
|
4951
5174
|
depict_api_: api ?? new (0, $3846bb34098c738f$export$e015ed2f2950f2e3)(),
|
|
4952
5175
|
on_category_link_click_: on_category_link_click_,
|
|
5176
|
+
selected_filters_: selected_filters_,
|
|
5177
|
+
current_sorting_: current_sorting_,
|
|
4953
5178
|
slider_arrow_button_: (0, $g9l4l$GenericSliderArrowButton)({
|
|
4954
5179
|
height_: 12,
|
|
4955
5180
|
width_: 6.46
|
|
@@ -4966,7 +5191,7 @@ function $ec52ef1e6c117813$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
4966
5191
|
grid_spacing: grid_spacing.horizontal
|
|
4967
5192
|
};
|
|
4968
5193
|
return (0, $c7f938ac40924f3b$export$23fca46f3143581f)(()=>{
|
|
4969
|
-
const { state_: { category_local_filter_cache: local_filter_cache_ ,
|
|
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_ , category_scroll_restoration_data: scroll_restoration_data_ } , current_sorting_: current_sorting_ , selected_filters_: selected_filters_ , 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;
|
|
4970
5195
|
(0, $g9l4l$onCleanup)(reset_history_state_);
|
|
4971
5196
|
return (0, $1ae892b13d7746ab$export$f7d2f673fc2f091d)({
|
|
4972
5197
|
tenant_: ()=>depict_category.merchant,
|
|
@@ -5320,14 +5545,15 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5320
5545
|
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
|
|
5321
5546
|
{
|
|
5322
5547
|
if (input_field.selectionStart === 0 && input_field.selectionEnd === input_field.value.length) // everything was selected, clear filters on next submit on next input
|
|
5323
|
-
input_field.addEventListener("input", (0, $g9l4l$catchify)(clear_filters_),
|
|
5548
|
+
input_field.addEventListener("input", (0, $g9l4l$catchify)(()=>clear_filters_(false)), // We don't count this as user triggered since it wasn't explicit
|
|
5549
|
+
{
|
|
5324
5550
|
once: true
|
|
5325
5551
|
});
|
|
5326
5552
|
}
|
|
5327
5553
|
}));
|
|
5328
5554
|
(0, $g9l4l$addEventListener)(_el$4, "input", (0, $g9l4l$catchify)(()=>{
|
|
5329
5555
|
const { value: value } = input_field;
|
|
5330
|
-
if (!disabled_ && !value.length) clear_filters_(); // if the user clears the whole field, reset filters on next submit
|
|
5556
|
+
if (!disabled_ && !value.length) clear_filters_(false); // if the user clears the whole field, reset filters on next submit
|
|
5331
5557
|
search_field_value_[1](value);
|
|
5332
5558
|
}), true);
|
|
5333
5559
|
(0, $g9l4l$addEventListener)(_el$4, "keydown", (0, $g9l4l$catchify)((e)=>{
|
|
@@ -5353,7 +5579,7 @@ function $6ded59a142c93078$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5353
5579
|
_el$4.classList.toggle("has-adjacent-back-button", !!on_back_);
|
|
5354
5580
|
(0, $g9l4l$addEventListener)(_el$5, "click", (0, $g9l4l$catchify)(()=>{
|
|
5355
5581
|
search_field_value_[1]("");
|
|
5356
|
-
clear_filters_();
|
|
5582
|
+
clear_filters_(true);
|
|
5357
5583
|
if (disabled_) return;
|
|
5358
5584
|
input_field.focus();
|
|
5359
5585
|
}), true);
|
|
@@ -5571,27 +5797,27 @@ function $079defea521d5e2a$export$b3ad617e9036868(modal_body_style, input_field,
|
|
|
5571
5797
|
|
|
5572
5798
|
|
|
5573
5799
|
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_ }) {
|
|
5574
|
-
const [get_selected_filters
|
|
5575
|
-
|
|
5800
|
+
const [get_selected_filters] = selected_filters_;
|
|
5801
|
+
// Possible values:
|
|
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
|
|
5576
5806
|
const [get_clear_filters_next_submit, set_clear_filters_next_submit] = clear_filters_next_submit_;
|
|
5577
|
-
const clear_filters = ()=>set_clear_filters_next_submit(
|
|
5807
|
+
const clear_filters = (user_triggered)=>set_clear_filters_next_submit(user_triggered ? 2 : 1);
|
|
5578
5808
|
(0, $g9l4l$createComputed)((0, $g9l4l$on)(get_selected_filters, ()=>{
|
|
5579
5809
|
// if the selected filters update, clear the clearing signal
|
|
5580
|
-
set_clear_filters_next_submit(
|
|
5810
|
+
set_clear_filters_next_submit(0);
|
|
5581
5811
|
}, {
|
|
5582
5812
|
defer: true
|
|
5583
5813
|
}));
|
|
5584
5814
|
(0, $g9l4l$createComputed)((0, $g9l4l$on)(get_search_query, (0, $g9l4l$catchify)(()=>{
|
|
5585
5815
|
// when a query was submitted, clear filters if clear was pressed before
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
// also collapse expanded filters in hierarchical filter tree again
|
|
5590
|
-
expanded_hierarchical_filters_[1]([]);
|
|
5591
|
-
// also clear sorting
|
|
5592
|
-
current_sorting_[1](undefined);
|
|
5816
|
+
const clear_value = (0, $g9l4l$untrack)(get_clear_filters_next_submit);
|
|
5817
|
+
if (clear_value) {
|
|
5818
|
+
set_clear_filters_next_submit(0);
|
|
5593
5819
|
(0, $af89070cc0052779$export$8895d39404bd2bb1)({
|
|
5594
|
-
user_triggered_:
|
|
5820
|
+
user_triggered_: clear_value === 2,
|
|
5595
5821
|
selected_filters_: selected_filters_,
|
|
5596
5822
|
i18n_: i18n_,
|
|
5597
5823
|
also_clear_sorting_: true,
|
|
@@ -7317,6 +7543,7 @@ function $a79ffb1cbfbd2a09$export$828dcdd425fd3231(aligner) {
|
|
|
7317
7543
|
}
|
|
7318
7544
|
|
|
7319
7545
|
|
|
7546
|
+
|
|
7320
7547
|
const $540e930c58500cbe$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"></div>`, 2);
|
|
7321
7548
|
/**
|
|
7322
7549
|
* 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.
|
|
@@ -7329,7 +7556,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7329
7556
|
#market_signal = (0, $g9l4l$createSignal)();
|
|
7330
7557
|
#modal_open_signal = (0, $g9l4l$createSignal)(false);
|
|
7331
7558
|
static #has_been_constructed = false;
|
|
7332
|
-
constructor({ search_query_url_param_name: search_query_url_param_name = "
|
|
7559
|
+
constructor({ search_query_url_param_name: search_query_url_param_name = "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
|
|
7333
7560
|
disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal_: bottom_distance_under_modal_ , render_instant_card: render_instant_card , ...props_on_class }){
|
|
7334
7561
|
if ($540e930c58500cbe$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
|
|
7335
7562
|
Object.assign(this, props_on_class);
|
|
@@ -7351,19 +7578,22 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7351
7578
|
target_url.searchParams.set(search_param_name, new_search_query);
|
|
7352
7579
|
on_navigation(target_url.href);
|
|
7353
7580
|
});
|
|
7354
|
-
const
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
|
|
7361
|
-
|
|
7362
|
-
|
|
7363
|
-
|
|
7364
|
-
|
|
7365
|
-
|
|
7366
|
-
|
|
7581
|
+
const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ } = (0, $4ebab5f2b1a65493$export$7bcff1eb3eca57d7)();
|
|
7582
|
+
const [reset_history_state_, state_] = (0, $764ea8aa12c4fc5b$export$90a2b6b3fb2a1455)({
|
|
7583
|
+
selected_filters_: selected_filters_,
|
|
7584
|
+
current_sorting_: current_sorting_,
|
|
7585
|
+
get_default_values_: ()=>({
|
|
7586
|
+
search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
|
|
7587
|
+
search_filters_open: false,
|
|
7588
|
+
search_sorting_open: false,
|
|
7589
|
+
search_expanded_filters: [],
|
|
7590
|
+
// 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
|
|
7591
|
+
search_local_filter_cache: [],
|
|
7592
|
+
search_expanded_hierarchical_filters: [],
|
|
7593
|
+
search_showing_recommendation_rows: (0, $aee0c68312d971f4$export$1c8c715550dc689d),
|
|
7594
|
+
search_scroll_restoration_data: []
|
|
7595
|
+
})
|
|
7596
|
+
});
|
|
7367
7597
|
const search_query_updating_blocked_ = (0, $g9l4l$createSignal)(false);
|
|
7368
7598
|
const { [search_query_url_param_name]: raw_search_query_signal } = (0, $4ad18a8b237ff7f6$export$2542ffb77b620b02)({
|
|
7369
7599
|
[search_query_url_param_name]: ""
|
|
@@ -7385,9 +7615,9 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7385
7615
|
});
|
|
7386
7616
|
const i18n_ = (0, $0466953901b38f18$export$f091cbac892643a4)(this.#locale_signal[0]);
|
|
7387
7617
|
const clear_filters_on_next_submit_ = (0, $a0d89ff25220eb8d$export$e026af0c7b64ea5f)({
|
|
7388
|
-
selected_filters_:
|
|
7618
|
+
selected_filters_: selected_filters_,
|
|
7389
7619
|
search_query_: search_query_signal_,
|
|
7390
|
-
current_sorting_:
|
|
7620
|
+
current_sorting_: current_sorting_,
|
|
7391
7621
|
expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
|
|
7392
7622
|
i18n_: i18n_,
|
|
7393
7623
|
local_filter_cache_: state_.search_local_filter_cache
|
|
@@ -7410,7 +7640,9 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7410
7640
|
configured_submit_query_: configured_submit_query_,
|
|
7411
7641
|
search_query_signal_: search_query_signal_,
|
|
7412
7642
|
i18n_: i18n_,
|
|
7413
|
-
search_query_updating_blocked_: search_query_updating_blocked_
|
|
7643
|
+
search_query_updating_blocked_: search_query_updating_blocked_,
|
|
7644
|
+
current_sorting_: current_sorting_,
|
|
7645
|
+
selected_filters_: selected_filters_
|
|
7414
7646
|
});
|
|
7415
7647
|
(0, $2864fd26f57ff474$export$5162a71f252e6122)();
|
|
7416
7648
|
(0, $g9l4l$catchify)(async ()=>{
|
|
@@ -7437,7 +7669,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
|
|
|
7437
7669
|
min_products_to_fetch_: $540e930c58500cbe$var$min_products_to_fetch_,
|
|
7438
7670
|
render_instant_card_: render_instant_card,
|
|
7439
7671
|
render_instant_card_placeholder_: (0, $aaacfac0064e97d9$export$ee1733d9a8495996),
|
|
7440
|
-
has_sort_or_filters_: (0, $g9l4l$createMemo)(()=>!!(Object.keys(
|
|
7672
|
+
has_sort_or_filters_: (0, $g9l4l$createMemo)(()=>!!(Object.keys(selected_filters_[0]())?.length || current_sorting_[0]()))
|
|
7441
7673
|
},
|
|
7442
7674
|
i18n_: i18n_,
|
|
7443
7675
|
enable_category_suggestions_: enable_category_suggestions,
|
|
@@ -7577,7 +7809,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
7577
7809
|
});
|
|
7578
7810
|
});
|
|
7579
7811
|
},
|
|
7580
|
-
current_sorting_:
|
|
7812
|
+
current_sorting_: shared_properties.current_sorting_,
|
|
7581
7813
|
search_filters_open_: state_.search_filters_open,
|
|
7582
7814
|
search_sorting_open_: state_.search_sorting_open,
|
|
7583
7815
|
expanded_filters_: state_.search_expanded_filters,
|
|
@@ -7588,7 +7820,7 @@ function $540e930c58500cbe$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
7588
7820
|
});
|
|
7589
7821
|
} : false,
|
|
7590
7822
|
expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
|
|
7591
|
-
selected_filters_:
|
|
7823
|
+
selected_filters_: shared_properties.selected_filters_,
|
|
7592
7824
|
showing_recommendation_rows_: state_.search_showing_recommendation_rows,
|
|
7593
7825
|
scroll_restoration_data_: state_.search_scroll_restoration_data,
|
|
7594
7826
|
include_input_field_: include_input_field,
|