@depict-ai/ui 0.0.72 → 0.0.73
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/README.md +3 -3
- package/dist/index.d.ts +513 -515
- package/dist/main.js +774 -473
- package/dist/module.js +776 -474
- package/jest.setup.js +7 -0
- package/locales/index.d.ts +88 -88
- package/locales/index.js +2 -2
- package/locales/require.js +2 -2
- package/package.json +6 -4
- package/styles.scss +1 -1
- package/tsconfig.json +8 -8
package/dist/main.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var $46MJV$depictaiutilishared = require("@depict-ai/utilishared");
|
|
2
2
|
var $46MJV$solidjsweb = require("solid-js/web");
|
|
3
3
|
var $46MJV$solidjs = require("solid-js");
|
|
4
|
+
var $46MJV$lzstring = require("lz-string");
|
|
4
5
|
|
|
5
6
|
function $parcel$export(e, n, v, s) {
|
|
6
7
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
@@ -26,7 +27,6 @@ $parcel$export(module.exports, "convert_sdk_cols_at_size_to_layout", () => $7958
|
|
|
26
27
|
$parcel$export(module.exports, "styles_to_valid_css_string", () => $d3c94b3b96557917$export$1233ca167bf71f9a);
|
|
27
28
|
$parcel$export(module.exports, "disable_scrolling", () => $fa41c421eb980e23$export$fe334901e8bebd57);
|
|
28
29
|
$parcel$export(module.exports, "open_search_with_shift_slash", () => $308e64f91bb9f839$export$d0596b5cae35ad4);
|
|
29
|
-
$parcel$export(module.exports, "push_state_with_query_param_value", () => $405647fc79da2849$export$26df08e242fe83a3);
|
|
30
30
|
$parcel$export(module.exports, "DepictAPI", () => $9ce64f69303c371e$export$e015ed2f2950f2e3);
|
|
31
31
|
$parcel$export(module.exports, "media_query_to_accessor", () => $beec9d22e42ed2cf$export$d9f36cf74e24d595);
|
|
32
32
|
$parcel$export(module.exports, "setup_fast_leave", () => $d589470b68ce5b67$export$689e204eadb33baf);
|
|
@@ -35,7 +35,7 @@ $parcel$export(module.exports, "solid_format_price", () => $5fc9fc23df1591db$exp
|
|
|
35
35
|
$parcel$export(module.exports, "connect_search_field_height_to_aligner_height", () => $246e3e89a097f014$export$828dcdd425fd3231);
|
|
36
36
|
$parcel$export(module.exports, "PageReplacer", () => $37e96a5ebc768cc7$export$3ccaa27d81dd8556);
|
|
37
37
|
$parcel$export(module.exports, "version", () => $ae93561d5649a847$export$83d89fbfd8236492);
|
|
38
|
-
/*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.
|
|
38
|
+
/*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.73";
|
|
39
39
|
|
|
40
40
|
|
|
41
41
|
|
|
@@ -89,10 +89,10 @@ function $1ee6da2465098194$var$history_state_change(signals, entries, state) {
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
|
|
92
|
-
function $0de081f67b6d15b5$export$9862539c89138352(
|
|
93
|
-
const state = (0, $1ee6da2465098194$export$e183a13865960371)(
|
|
92
|
+
function $0de081f67b6d15b5$export$9862539c89138352(get_default_values_) {
|
|
93
|
+
const state = (0, $1ee6da2465098194$export$e183a13865960371)(get_default_values_());
|
|
94
94
|
const reset_state = ()=>{
|
|
95
|
-
const new_defaults =
|
|
95
|
+
const new_defaults = get_default_values_();
|
|
96
96
|
for(const key in state){
|
|
97
97
|
const new_value = new_defaults[key];
|
|
98
98
|
state[key][1](new_value);
|
|
@@ -810,8 +810,8 @@ function $2b4e3538e183d885$export$ef6006467f04ee41({ i18n_: i18n_ , expanded_hie
|
|
|
810
810
|
]);
|
|
811
811
|
|
|
812
812
|
|
|
813
|
-
/*
|
|
814
|
-
* Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
|
|
813
|
+
/*
|
|
814
|
+
* Usually product templates are somewhat height-elastic depending on the content, i.e. if the title is longer we might up to two extra rows for this. That means that the placeholders almost never will reflect the size of the actual content when we do scroll restoration. This magic number specifies how many extra placeholders we should render everytime to compensate for this, since if the placeholders are in total shorter than the old scroll location the scroll restoration won't work.
|
|
815
815
|
*/ const $39d15a684cb3e309$export$6c9030e511152266 = 30;
|
|
816
816
|
|
|
817
817
|
|
|
@@ -871,7 +871,7 @@ function $0f2f58dd60b11888$export$b69d0d92862de18b(props) {
|
|
|
871
871
|
|
|
872
872
|
const $8d94abc871e13baf$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="PLP-results"></div>`, 2), $8d94abc871e13baf$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="cards"></div>`, 2);
|
|
873
873
|
let $8d94abc871e13baf$var$cached_placeholder_element;
|
|
874
|
-
function $8d94abc871e13baf$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_
|
|
874
|
+
function $8d94abc871e13baf$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_ }) {
|
|
875
875
|
// The plp_results_ resource will be delayed because we're using createBatchedMemo to not make triplicate API requests, but we need to show the placeholders before already to match Chrome and Firefox's "content has to be there, ready for scroll restoration, before all popstate tasks have been completed"-requirement
|
|
876
876
|
const is_loading = (0, $46MJV$solidjs.createMemo)(()=>plp_results_.loading || query_base_.loading);
|
|
877
877
|
const cleanup_old_cards = [];
|
|
@@ -910,9 +910,7 @@ function $8d94abc871e13baf$export$3925f87b1545cfc6({ plp_results_: plp_results_
|
|
|
910
910
|
post_processors: [
|
|
911
911
|
...rr_options_.post_processors || [],
|
|
912
912
|
load_more_post_processor
|
|
913
|
-
]
|
|
914
|
-
view_tracking: disable_default_tracking_ ? [] : undefined,
|
|
915
|
-
click_tracking: disable_default_tracking_ ? [] : undefined
|
|
913
|
+
]
|
|
916
914
|
});
|
|
917
915
|
// check if we still should insert or something new happened while we were rendering
|
|
918
916
|
if ((0, $46MJV$solidjs.untrack)(has_no_results_or_failed) || (0, $46MJV$solidjs.untrack)(is_loading)) {
|
|
@@ -1072,8 +1070,6 @@ async function $8d94abc871e13baf$var$insert_placeholders({ scroll_restoration_da
|
|
|
1072
1070
|
type: "placeholder",
|
|
1073
1071
|
pre_processors: [],
|
|
1074
1072
|
post_processors: [],
|
|
1075
|
-
view_tracking: [],
|
|
1076
|
-
click_tracking: [],
|
|
1077
1073
|
...typeof rr_options_.template === "function" ? {
|
|
1078
1074
|
template: $8d94abc871e13baf$var$wrap_template_to_throw_into_error_boundary(rr_options_.template, root_in_root, ()=>(0, $46MJV$depictaiutilishared.queueMacroTask)((0, $46MJV$depictaiutilishared.catchify)(dispose_card)) // we just want it cloned and dead
|
|
1079
1075
|
)
|
|
@@ -2870,156 +2866,6 @@ var $6865c7388a79e957$export$2e2bcd8739ae039 = {
|
|
|
2870
2866
|
|
|
2871
2867
|
|
|
2872
2868
|
|
|
2873
|
-
function $0bc45cf6753f874a$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
|
|
2874
|
-
let last_remote_state;
|
|
2875
|
-
(0, $46MJV$solidjs.createComputed)(()=>{
|
|
2876
|
-
const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
|
|
2877
|
-
JSON.stringify([
|
|
2878
|
-
filter.field,
|
|
2879
|
-
filter.op,
|
|
2880
|
-
filter?.meta?.type
|
|
2881
|
-
]),
|
|
2882
|
-
filter
|
|
2883
|
-
]) || []);
|
|
2884
|
-
const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
|
|
2885
|
-
JSON.stringify([
|
|
2886
|
-
filter.field,
|
|
2887
|
-
filter.op,
|
|
2888
|
-
filter?.meta?.type
|
|
2889
|
-
]),
|
|
2890
|
-
filter
|
|
2891
|
-
]));
|
|
2892
|
-
const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
|
|
2893
|
-
JSON.stringify([
|
|
2894
|
-
filter_obj.field,
|
|
2895
|
-
filter_obj.op
|
|
2896
|
-
]),
|
|
2897
|
-
filter_obj
|
|
2898
|
-
]));
|
|
2899
|
-
const new_local_filter_state = [];
|
|
2900
|
-
// 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
|
|
2901
|
-
for (const filter_id of [
|
|
2902
|
-
...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
|
|
2903
|
-
...Object.keys(remote_filters)
|
|
2904
|
-
]){
|
|
2905
|
-
const local_filter = local_filters[filter_id];
|
|
2906
|
-
const remote_filter = remote_filters[filter_id];
|
|
2907
|
-
const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
|
|
2908
|
-
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
|
|
2909
|
-
{
|
|
2910
|
-
if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($0bc45cf6753f874a$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
|
|
2911
|
-
} else if (!local_filter) // just take the remote one
|
|
2912
|
-
new_local_filter_state.push(remote_filter);
|
|
2913
|
-
else {
|
|
2914
|
-
// both exist, merge them if needed
|
|
2915
|
-
const remote_meta = remote_filter.meta;
|
|
2916
|
-
const local_meta = local_filter.meta;
|
|
2917
|
-
const this_applied_filter = selected_filters[filter_id_without_meta_type];
|
|
2918
|
-
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
|
|
2919
|
-
new_local_filter_state.push(remote_filter);
|
|
2920
|
-
else {
|
|
2921
|
-
const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
|
|
2922
|
-
JSON.stringify(value),
|
|
2923
|
-
{
|
|
2924
|
-
value_: value,
|
|
2925
|
-
count_: remote_meta.counts?.[index],
|
|
2926
|
-
name_: remote_meta.names?.[index]
|
|
2927
|
-
}
|
|
2928
|
-
]));
|
|
2929
|
-
const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
|
|
2930
|
-
JSON.stringify(value),
|
|
2931
|
-
{
|
|
2932
|
-
value_: value,
|
|
2933
|
-
count_: 0,
|
|
2934
|
-
name_: local_meta.names?.[index]
|
|
2935
|
-
}
|
|
2936
|
-
]));
|
|
2937
|
-
const new_data = [
|
|
2938
|
-
...Object.keys(data_objs_in_local).filter((key)=>{
|
|
2939
|
-
// put data entries that are selected and don't exist in new remote state first
|
|
2940
|
-
if (key in data_objs_in_remote) return false;
|
|
2941
|
-
const selected_values = this_applied_filter.data;
|
|
2942
|
-
return selected_values.some((value)=>{
|
|
2943
|
-
const is_equal = JSON.stringify(value) === key;
|
|
2944
|
-
if (is_equal) return true;
|
|
2945
|
-
if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
|
|
2946
|
-
// 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.
|
|
2947
|
-
const selected_values = data_objs_in_local[key].value_;
|
|
2948
|
-
const values_length = value?.length;
|
|
2949
|
-
if (values_length > 1 && values_length - 1 === selected_values.length) {
|
|
2950
|
-
let is_parent = true;
|
|
2951
|
-
for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
|
|
2952
|
-
return is_parent;
|
|
2953
|
-
}
|
|
2954
|
-
}
|
|
2955
|
-
return false;
|
|
2956
|
-
});
|
|
2957
|
-
}).map((key)=>data_objs_in_local[key]),
|
|
2958
|
-
...Object.values(data_objs_in_remote)
|
|
2959
|
-
];
|
|
2960
|
-
const new_values = new_data.map(({ value_: value_ })=>value_);
|
|
2961
|
-
const result = {
|
|
2962
|
-
...remote_filter,
|
|
2963
|
-
meta: {
|
|
2964
|
-
...remote_filter.meta,
|
|
2965
|
-
values: new_values,
|
|
2966
|
-
names: new_data.map(({ name_: name_ })=>name_),
|
|
2967
|
-
counts: new_data.map(({ count_: count_ })=>count_)
|
|
2968
|
-
}
|
|
2969
|
-
};
|
|
2970
|
-
new_local_filter_state.push(result);
|
|
2971
|
-
}
|
|
2972
|
-
}
|
|
2973
|
-
}
|
|
2974
|
-
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
|
|
2975
|
-
JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
|
|
2976
|
-
write_local_cache(new_local_filter_state);
|
|
2977
|
-
last_remote_state = available_filters_();
|
|
2978
|
-
});
|
|
2979
|
-
return read_local_cache;
|
|
2980
|
-
}
|
|
2981
|
-
/**
|
|
2982
|
-
* 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.
|
|
2983
|
-
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
2984
|
-
*/ function $0bc45cf6753f874a$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
2985
|
-
const old_meta = local_filter_object.meta;
|
|
2986
|
-
const selected_filter_data = selected_filter.data;
|
|
2987
|
-
const modified_filter_object = {
|
|
2988
|
-
...local_filter_object
|
|
2989
|
-
};
|
|
2990
|
-
if (old_meta) {
|
|
2991
|
-
const new_meta = {
|
|
2992
|
-
...old_meta
|
|
2993
|
-
};
|
|
2994
|
-
modified_filter_object.meta = new_meta;
|
|
2995
|
-
// set counts to 0
|
|
2996
|
-
if ("counts" in new_meta) {
|
|
2997
|
-
const counts = new_meta.counts;
|
|
2998
|
-
if (counts) new_meta.counts = counts.map(()=>0);
|
|
2999
|
-
}
|
|
3000
|
-
if (Array.isArray(selected_filter_data) && "values" in new_meta) {
|
|
3001
|
-
// we have an array of values and want to strip the ones from the available ones that aren't selected
|
|
3002
|
-
const values = new_meta.values;
|
|
3003
|
-
if (Array.isArray(values)) {
|
|
3004
|
-
const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
|
|
3005
|
-
const indexes_to_remove = new Set();
|
|
3006
|
-
for(let i = 0; i < values.length; i++){
|
|
3007
|
-
const value = values[i];
|
|
3008
|
-
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
|
|
3009
|
-
indexes_to_remove.add(i);
|
|
3010
|
-
}
|
|
3011
|
-
new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
|
|
3012
|
-
if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
|
|
3013
|
-
if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
|
|
3014
|
-
new_meta.counts.length -= indexes_to_remove.size;
|
|
3015
|
-
}
|
|
3016
|
-
}
|
|
3017
|
-
}
|
|
3018
|
-
return modified_filter_object;
|
|
3019
|
-
}
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
-
|
|
3023
2869
|
|
|
3024
2870
|
|
|
3025
2871
|
|
|
@@ -3161,11 +3007,7 @@ function $1587765bd31f3722$export$3f1a388cc0d8fed7(props) {
|
|
|
3161
3007
|
});
|
|
3162
3008
|
}
|
|
3163
3009
|
function $1587765bd31f3722$var$ActualFilterBody(props) {
|
|
3164
|
-
const modified_available_filters_with_selected_unexisting_ones_injected_from_local_state =
|
|
3165
|
-
available_filters_: props.available_filters_,
|
|
3166
|
-
selected_filters_: props.selected_filters_,
|
|
3167
|
-
local_filter_cache_: props.local_filter_cache_
|
|
3168
|
-
});
|
|
3010
|
+
const [modified_available_filters_with_selected_unexisting_ones_injected_from_local_state] = props.local_filter_cache_;
|
|
3169
3011
|
const togglable_filters = (0, $46MJV$solidjs.createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>item?.meta?.group_title));
|
|
3170
3012
|
const untogglable_filters = (0, $46MJV$solidjs.createMemo)(()=>modified_available_filters_with_selected_unexisting_ones_injected_from_local_state().filter((item)=>!item?.meta?.group_title));
|
|
3171
3013
|
const togglable_filters_grouped_by_collapsible = (0, $46MJV$solidjs.createMemo)(()=>{
|
|
@@ -3366,7 +3208,7 @@ function $1587765bd31f3722$var$ActualFilterBody(props) {
|
|
|
3366
3208
|
|
|
3367
3209
|
|
|
3368
3210
|
const $cc8aaf130b1dc1ea$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="sorting-attributes"></div>`, 2), $cc8aaf130b1dc1ea$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="sorting-direction"></div>`, 2), $cc8aaf130b1dc1ea$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div><div class="input-row"><input type="radio"><span class="custom-indicator"></span></div></div>`, 7), $cc8aaf130b1dc1ea$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div><label class="input-row"><input type="radio"><span class="custom-indicator"></span></label></div>`, 7);
|
|
3369
|
-
function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_:
|
|
3211
|
+
function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: available_sortings_ , current_sorting_: [get_current_sorting, set_current_sorting] , meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_ }) {
|
|
3370
3212
|
const title_radio_name = (0, $46MJV$depictaiutilishared.make_random_classname)();
|
|
3371
3213
|
const order_radio_name = (0, $46MJV$depictaiutilishared.make_random_classname)();
|
|
3372
3214
|
return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
@@ -3400,14 +3242,14 @@ function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: availa
|
|
|
3400
3242
|
},
|
|
3401
3243
|
children: (item, index)=>{
|
|
3402
3244
|
const is_checked = (0, $46MJV$solidjs.createMemo)(()=>{
|
|
3403
|
-
const sort =
|
|
3245
|
+
const sort = get_current_sorting();
|
|
3404
3246
|
if (!sort) // if no sortings are selected, "select" first sort
|
|
3405
3247
|
return index === 0;
|
|
3406
3248
|
return sort.field === item().field && (sort.order === item().order || item().meta.values?.length > 1);
|
|
3407
3249
|
});
|
|
3408
3250
|
return /* wrapping div for flex gap polyfill scss mixin */ (()=>{
|
|
3409
3251
|
const _el$8 = $cc8aaf130b1dc1ea$var$_tmpl$4.cloneNode(true), _el$9 = _el$8.firstChild, _el$10 = _el$9.firstChild, _el$11 = _el$10.nextSibling;
|
|
3410
|
-
(0, $46MJV$solidjsweb.addEventListener)(_el$10, "change", (0, $46MJV$depictaiutilishared.catchify)(()=>
|
|
3252
|
+
(0, $46MJV$solidjsweb.addEventListener)(_el$10, "change", (0, $46MJV$depictaiutilishared.catchify)(()=>set_current_sorting(item())));
|
|
3411
3253
|
(0, $46MJV$solidjsweb.setAttribute)(_el$10, "name", title_radio_name);
|
|
3412
3254
|
(0, $46MJV$solidjsweb.insert)(_el$9, ()=>item().meta.title, null);
|
|
3413
3255
|
(0, $46MJV$solidjsweb.effect)(()=>_el$10.checked = is_checked());
|
|
@@ -3419,27 +3261,25 @@ function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: availa
|
|
|
3419
3261
|
})(),
|
|
3420
3262
|
(0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
3421
3263
|
get when () {
|
|
3422
|
-
return
|
|
3264
|
+
return meta_of_currently_selected_sorting_()?.values?.length > 1;
|
|
3423
3265
|
},
|
|
3424
3266
|
get children () {
|
|
3425
3267
|
const _el$2 = $cc8aaf130b1dc1ea$var$_tmpl$2.cloneNode(true);
|
|
3426
3268
|
(0, $46MJV$solidjsweb.insert)(_el$2, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Index), {
|
|
3427
3269
|
get each () {
|
|
3428
|
-
return
|
|
3270
|
+
return meta_of_currently_selected_sorting_()?.values;
|
|
3429
3271
|
},
|
|
3430
3272
|
children: (order_value, index)=>{
|
|
3273
|
+
const is_checked = (0, $46MJV$solidjs.createMemo)(()=>get_current_sorting()?.order === order_value());
|
|
3431
3274
|
return (()=>{
|
|
3432
3275
|
const _el$12 = $cc8aaf130b1dc1ea$var$_tmpl$4.cloneNode(true), _el$13 = _el$12.firstChild, _el$14 = _el$13.firstChild, _el$15 = _el$14.nextSibling;
|
|
3433
|
-
(0, $46MJV$solidjsweb.addEventListener)(_el$14, "change", (0, $46MJV$depictaiutilishared.catchify)(()=>
|
|
3276
|
+
(0, $46MJV$solidjsweb.addEventListener)(_el$14, "change", (0, $46MJV$depictaiutilishared.catchify)(()=>set_current_sorting((c)=>c && {
|
|
3434
3277
|
...c,
|
|
3435
3278
|
order: order_value()
|
|
3436
3279
|
})));
|
|
3437
3280
|
(0, $46MJV$solidjsweb.setAttribute)(_el$14, "name", order_radio_name);
|
|
3438
|
-
(0, $46MJV$solidjsweb.insert)(_el$13, ()=>
|
|
3439
|
-
(0, $46MJV$solidjsweb.effect)(()=>_el$14.checked = (
|
|
3440
|
-
const sort = current_sorting_[0]();
|
|
3441
|
-
return sort?.order === order_value();
|
|
3442
|
-
})());
|
|
3281
|
+
(0, $46MJV$solidjsweb.insert)(_el$13, ()=>meta_of_currently_selected_sorting_()?.names?.[index], null);
|
|
3282
|
+
(0, $46MJV$solidjsweb.effect)(()=>_el$14.checked = is_checked());
|
|
3443
3283
|
return _el$12;
|
|
3444
3284
|
})();
|
|
3445
3285
|
}
|
|
@@ -3784,20 +3624,177 @@ function $66ddbcbc40487f95$export$9bf11afa910f536e({ args_for_sorting_: args_for
|
|
|
3784
3624
|
|
|
3785
3625
|
|
|
3786
3626
|
|
|
3627
|
+
|
|
3628
|
+
function $0bc45cf6753f874a$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
|
|
3629
|
+
let last_remote_state;
|
|
3630
|
+
(0, $46MJV$solidjs.createComputed)(()=>{
|
|
3631
|
+
const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
|
|
3632
|
+
JSON.stringify([
|
|
3633
|
+
filter.field,
|
|
3634
|
+
filter.op,
|
|
3635
|
+
filter?.meta?.type
|
|
3636
|
+
]),
|
|
3637
|
+
filter
|
|
3638
|
+
]) || []);
|
|
3639
|
+
const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
|
|
3640
|
+
JSON.stringify([
|
|
3641
|
+
filter.field,
|
|
3642
|
+
filter.op,
|
|
3643
|
+
filter?.meta?.type
|
|
3644
|
+
]),
|
|
3645
|
+
filter
|
|
3646
|
+
]));
|
|
3647
|
+
const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
|
|
3648
|
+
JSON.stringify([
|
|
3649
|
+
filter_obj.field,
|
|
3650
|
+
filter_obj.op
|
|
3651
|
+
]),
|
|
3652
|
+
filter_obj
|
|
3653
|
+
]));
|
|
3654
|
+
const new_local_filter_state = [];
|
|
3655
|
+
// 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
|
|
3656
|
+
for (const filter_id of [
|
|
3657
|
+
...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
|
|
3658
|
+
...Object.keys(remote_filters)
|
|
3659
|
+
]){
|
|
3660
|
+
const local_filter = local_filters[filter_id];
|
|
3661
|
+
const remote_filter = remote_filters[filter_id];
|
|
3662
|
+
const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
|
|
3663
|
+
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
|
|
3664
|
+
{
|
|
3665
|
+
if (filter_id_without_meta_type in selected_filters) new_local_filter_state.push($0bc45cf6753f874a$var$modify_only_local_filter(local_filter, selected_filters[filter_id_without_meta_type]));
|
|
3666
|
+
} else if (!local_filter) // just take the remote one
|
|
3667
|
+
new_local_filter_state.push(remote_filter);
|
|
3668
|
+
else {
|
|
3669
|
+
// both exist, merge them if needed
|
|
3670
|
+
const remote_meta = remote_filter.meta;
|
|
3671
|
+
const local_meta = local_filter.meta;
|
|
3672
|
+
const this_applied_filter = selected_filters[filter_id_without_meta_type];
|
|
3673
|
+
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
|
|
3674
|
+
new_local_filter_state.push(remote_filter);
|
|
3675
|
+
else {
|
|
3676
|
+
const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
|
|
3677
|
+
JSON.stringify(value),
|
|
3678
|
+
{
|
|
3679
|
+
value_: value,
|
|
3680
|
+
count_: remote_meta.counts?.[index],
|
|
3681
|
+
name_: remote_meta.names?.[index]
|
|
3682
|
+
}
|
|
3683
|
+
]));
|
|
3684
|
+
const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
|
|
3685
|
+
JSON.stringify(value),
|
|
3686
|
+
{
|
|
3687
|
+
value_: value,
|
|
3688
|
+
count_: 0,
|
|
3689
|
+
name_: local_meta.names?.[index]
|
|
3690
|
+
}
|
|
3691
|
+
]));
|
|
3692
|
+
const new_data = [
|
|
3693
|
+
...Object.keys(data_objs_in_local).filter((key)=>{
|
|
3694
|
+
// put data entries that are selected and don't exist in new remote state first
|
|
3695
|
+
if (key in data_objs_in_remote) return false;
|
|
3696
|
+
const selected_values = this_applied_filter.data;
|
|
3697
|
+
return selected_values.some((value)=>{
|
|
3698
|
+
const is_equal = JSON.stringify(value) === key;
|
|
3699
|
+
if (is_equal) return true;
|
|
3700
|
+
if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
|
|
3701
|
+
// 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.
|
|
3702
|
+
const selected_values = data_objs_in_local[key].value_;
|
|
3703
|
+
const values_length = value?.length;
|
|
3704
|
+
if (values_length > 1 && values_length - 1 === selected_values.length) {
|
|
3705
|
+
let is_parent = true;
|
|
3706
|
+
for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
|
|
3707
|
+
return is_parent;
|
|
3708
|
+
}
|
|
3709
|
+
}
|
|
3710
|
+
return false;
|
|
3711
|
+
});
|
|
3712
|
+
}).map((key)=>data_objs_in_local[key]),
|
|
3713
|
+
...Object.values(data_objs_in_remote)
|
|
3714
|
+
];
|
|
3715
|
+
const new_values = new_data.map(({ value_: value_ })=>value_);
|
|
3716
|
+
const result = {
|
|
3717
|
+
...remote_filter,
|
|
3718
|
+
meta: {
|
|
3719
|
+
...remote_filter.meta,
|
|
3720
|
+
values: new_values,
|
|
3721
|
+
names: new_data.map(({ name_: name_ })=>name_),
|
|
3722
|
+
counts: new_data.map(({ count_: count_ })=>count_)
|
|
3723
|
+
}
|
|
3724
|
+
};
|
|
3725
|
+
new_local_filter_state.push(result);
|
|
3726
|
+
}
|
|
3727
|
+
}
|
|
3728
|
+
}
|
|
3729
|
+
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
|
|
3730
|
+
JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
|
|
3731
|
+
write_local_cache(new_local_filter_state);
|
|
3732
|
+
last_remote_state = available_filters_();
|
|
3733
|
+
});
|
|
3734
|
+
}
|
|
3735
|
+
/**
|
|
3736
|
+
* 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.
|
|
3737
|
+
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
3738
|
+
*/ function $0bc45cf6753f874a$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
3739
|
+
const old_meta = local_filter_object.meta;
|
|
3740
|
+
const selected_filter_data = selected_filter.data;
|
|
3741
|
+
const modified_filter_object = {
|
|
3742
|
+
...local_filter_object
|
|
3743
|
+
};
|
|
3744
|
+
if (old_meta) {
|
|
3745
|
+
const new_meta = {
|
|
3746
|
+
...old_meta
|
|
3747
|
+
};
|
|
3748
|
+
modified_filter_object.meta = new_meta;
|
|
3749
|
+
// set counts to 0
|
|
3750
|
+
if ("counts" in new_meta) {
|
|
3751
|
+
const counts = new_meta.counts;
|
|
3752
|
+
if (counts) new_meta.counts = counts.map(()=>0);
|
|
3753
|
+
}
|
|
3754
|
+
if (Array.isArray(selected_filter_data) && "values" in new_meta) {
|
|
3755
|
+
// we have an array of values and want to strip the ones from the available ones that aren't selected
|
|
3756
|
+
const values = new_meta.values;
|
|
3757
|
+
if (Array.isArray(values)) {
|
|
3758
|
+
const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
|
|
3759
|
+
const indexes_to_remove = new Set();
|
|
3760
|
+
for(let i = 0; i < values.length; i++){
|
|
3761
|
+
const value = values[i];
|
|
3762
|
+
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
|
|
3763
|
+
indexes_to_remove.add(i);
|
|
3764
|
+
}
|
|
3765
|
+
new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
|
|
3766
|
+
if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
|
|
3767
|
+
if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
|
|
3768
|
+
new_meta.counts.length -= indexes_to_remove.size;
|
|
3769
|
+
}
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
return modified_filter_object;
|
|
3773
|
+
}
|
|
3774
|
+
|
|
3775
|
+
|
|
3787
3776
|
const $881cb1745bafff7a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="filters"><div class="body"></div></div>`, 4), $881cb1745bafff7a$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="sorting"><div class="body"></div></div>`, 4), $881cb1745bafff7a$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="sort-and-filter-buttons"><div class="outer"><div class="inner"></div></div></div>`, 6), $881cb1745bafff7a$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="num-filters"></span>`, 2), $881cb1745bafff7a$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="open-filters-button-container"><button class="filter toggle-button major-minor-transition" type="button"><span></span></button></div>`, 6), $881cb1745bafff7a$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<button class="toggle-button for-sorting major-minor-transition"><span></span></button>`, 4);
|
|
3788
3777
|
function $881cb1745bafff7a$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_ }) {
|
|
3789
3778
|
return (0, $0f2f58dd60b11888$export$b69d0d92862de18b)({
|
|
3790
3779
|
severity_: "error",
|
|
3791
3780
|
message_: "Sorting and filters failed",
|
|
3792
3781
|
get children () {
|
|
3782
|
+
// 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
|
|
3783
|
+
(0, $0bc45cf6753f874a$export$b288c38ae3fddb56)({
|
|
3784
|
+
available_filters_: available_filters_,
|
|
3785
|
+
selected_filters_: selected_filters_,
|
|
3786
|
+
local_filter_cache_: local_filter_cache_
|
|
3787
|
+
});
|
|
3793
3788
|
const cleanup_promise = new Promise((r)=>(0, $46MJV$solidjs.onCleanup)(r));
|
|
3794
3789
|
const [filters_open, set_filters_open] = search_filters_open_;
|
|
3795
3790
|
const [sorting_open, set_sorting_open] = search_sorting_open_;
|
|
3791
|
+
const [get_current_sorting_] = current_sorting_;
|
|
3796
3792
|
const [is_small, set_is_small] = (0, $46MJV$solidjs.createSignal)(false);
|
|
3797
3793
|
const dismiss_modal_ = (0, $46MJV$depictaiutilishared.catchify)(()=>{
|
|
3798
3794
|
set_filters_open(false);
|
|
3799
3795
|
set_sorting_open(false);
|
|
3800
3796
|
});
|
|
3797
|
+
const meta_of_currently_selected_sorting_ = (0, $46MJV$solidjs.createMemo)(()=>available_sortings_()?.find?.((sorting)=>sorting.field === get_current_sorting_()?.field)?.meta);
|
|
3801
3798
|
const filter_options = {
|
|
3802
3799
|
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
3803
3800
|
local_filter_cache_: local_filter_cache_,
|
|
@@ -3808,7 +3805,8 @@ function $881cb1745bafff7a$export$d7841e452f2e59a8({ current_sorting_: current_s
|
|
|
3808
3805
|
};
|
|
3809
3806
|
const sorting_options = {
|
|
3810
3807
|
current_sorting_: current_sorting_,
|
|
3811
|
-
available_sortings_: available_sortings_
|
|
3808
|
+
available_sortings_: available_sortings_,
|
|
3809
|
+
meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_
|
|
3812
3810
|
};
|
|
3813
3811
|
const make_open_filters_button = (adhere_to_width = false, is_tabbable = false)=>(0, $46MJV$solidjsweb.createComponent)($881cb1745bafff7a$var$OpenFiltersButton, {
|
|
3814
3812
|
tabindex_: is_tabbable ? 0 : -1,
|
|
@@ -3821,11 +3819,12 @@ function $881cb1745bafff7a$export$d7841e452f2e59a8({ current_sorting_: current_s
|
|
|
3821
3819
|
const make_open_sorting_button = (adhere_to_width = false, is_tabbable = false)=>(0, $46MJV$solidjsweb.createComponent)($881cb1745bafff7a$var$OpenSortingButton, {
|
|
3822
3820
|
tabindex_: is_tabbable ? 0 : -1,
|
|
3823
3821
|
i18n_: i18n_,
|
|
3824
|
-
|
|
3822
|
+
get_current_sorting_: get_current_sorting_,
|
|
3825
3823
|
search_filters_open_: search_filters_open_,
|
|
3826
3824
|
search_sorting_open_: search_sorting_open_,
|
|
3827
3825
|
available_sortings_: available_sortings_,
|
|
3828
|
-
sort_button_width_: adhere_to_width ? sort_button_width_ : undefined
|
|
3826
|
+
sort_button_width_: adhere_to_width ? sort_button_width_ : undefined,
|
|
3827
|
+
meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_
|
|
3829
3828
|
});
|
|
3830
3829
|
let open_modal_;
|
|
3831
3830
|
let close_modal_;
|
|
@@ -3953,7 +3952,7 @@ function $881cb1745bafff7a$var$OpenFiltersButton({ i18n_: i18n_ , search_filters
|
|
|
3953
3952
|
return _el$8;
|
|
3954
3953
|
})();
|
|
3955
3954
|
}
|
|
3956
|
-
function $881cb1745bafff7a$var$OpenSortingButton({ i18n_: i18n_ ,
|
|
3955
|
+
function $881cb1745bafff7a$var$OpenSortingButton({ i18n_: i18n_ , get_current_sorting_: get_current_sorting_ , search_filters_open_: search_filters_open_ , available_sortings_: available_sortings_ , search_sorting_open_: search_sorting_open_ , sort_button_width_: sort_button_width_ , tabindex_: tabindex_ , meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_ }) {
|
|
3957
3956
|
const sorting_closed = (0, $46MJV$solidjs.createMemo)(()=>!search_sorting_open_[0]());
|
|
3958
3957
|
// We assume in embedded_num_products that this is a single HTMLElement so pls change there if you change it here
|
|
3959
3958
|
return (()=>{
|
|
@@ -3969,7 +3968,7 @@ function $881cb1745bafff7a$var$OpenSortingButton({ i18n_: i18n_ , current_sortin
|
|
|
3969
3968
|
(0, $46MJV$solidjsweb.setAttribute)(_el$12, "tabindex", tabindex_);
|
|
3970
3969
|
(0, $46MJV$solidjsweb.insert)(_el$13, (()=>{
|
|
3971
3970
|
const _c$ = (0, $46MJV$solidjsweb.memo)(()=>!!sorting_closed());
|
|
3972
|
-
return ()=>_c$() && (
|
|
3971
|
+
return ()=>_c$() && (meta_of_currently_selected_sorting_()?.title || available_sortings_()?.[0]?.meta?.title) || i18n_.sorting_text_();
|
|
3973
3972
|
})());
|
|
3974
3973
|
(0, $46MJV$solidjsweb.insert)(_el$12, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
3975
3974
|
get when () {
|
|
@@ -3979,7 +3978,7 @@ function $881cb1745bafff7a$var$OpenSortingButton({ i18n_: i18n_ , current_sortin
|
|
|
3979
3978
|
return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.MinusIcon), {});
|
|
3980
3979
|
},
|
|
3981
3980
|
get children () {
|
|
3982
|
-
return (0, $46MJV$solidjsweb.memo)(()=>
|
|
3981
|
+
return (0, $46MJV$solidjsweb.memo)(()=>get_current_sorting_()?.order === "asc")() ? (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.SortIconAsc), {}) : (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.SortIconDesc), {});
|
|
3983
3982
|
}
|
|
3984
3983
|
}), null);
|
|
3985
3984
|
(0, $46MJV$solidjsweb.effect)((_p$)=>{
|
|
@@ -4160,8 +4159,157 @@ function $fd64465f894d1f29$var$ActualFloatingButtons({ search_filters_open_: [ge
|
|
|
4160
4159
|
|
|
4161
4160
|
|
|
4162
4161
|
|
|
4162
|
+
|
|
4163
|
+
|
|
4164
|
+
const $c6a04c153e9853a7$var$operator_map = {
|
|
4165
|
+
"eq": "≡",
|
|
4166
|
+
"neq": "≠",
|
|
4167
|
+
"in": "∈",
|
|
4168
|
+
"nin": "∉",
|
|
4169
|
+
"leq": "≤",
|
|
4170
|
+
"geq": "≥",
|
|
4171
|
+
"inrange": "\uD83D\uDD22"
|
|
4172
|
+
};
|
|
4173
|
+
const $c6a04c153e9853a7$var$sorting_query_param = "sorting";
|
|
4174
|
+
const $c6a04c153e9853a7$var$ascending_token = "\uD83D\uDCC8";
|
|
4175
|
+
const $c6a04c153e9853a7$var$descending_token = "\uD83D\uDCC9";
|
|
4176
|
+
const $c6a04c153e9853a7$var$filter_query_param_prefix = "filter_";
|
|
4177
|
+
const $c6a04c153e9853a7$var$range_delimiter = "-";
|
|
4178
|
+
const $c6a04c153e9853a7$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
|
|
4179
|
+
const $c6a04c153e9853a7$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
|
|
4180
|
+
const $c6a04c153e9853a7$var$empty_item_replacement = "0️⃣";
|
|
4181
|
+
/**
|
|
4182
|
+
* Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
|
|
4183
|
+
* The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
|
|
4184
|
+
* No deep or mixed nesting levels are supported.
|
|
4185
|
+
*/ function $c6a04c153e9853a7$var$array_is_serializable(array, is_root = true) {
|
|
4186
|
+
if (array.every((item)=>Array.isArray(item))) {
|
|
4187
|
+
if (!is_root) // Deeply nested arrays are not supported, but also don't exist as filters (yet)
|
|
4188
|
+
return false;
|
|
4189
|
+
return array.every((item)=>$c6a04c153e9853a7$var$array_is_serializable(item, false));
|
|
4190
|
+
}
|
|
4191
|
+
if (array.some((item)=>typeof item !== "string")) // Numbers are not supported, since 1 and "1" would encode to the same thing
|
|
4192
|
+
return false;
|
|
4193
|
+
// Encoding reserved characters is not supported
|
|
4194
|
+
return !array.some((item)=>item.includes($c6a04c153e9853a7$var$array_item_delimiter) || item.includes($c6a04c153e9853a7$var$string_item_delimiter) || item === $c6a04c153e9853a7$var$empty_item_replacement);
|
|
4195
|
+
}
|
|
4196
|
+
/**
|
|
4197
|
+
* Human readable string[] or string[][] serialization for URLs.
|
|
4198
|
+
* @param array
|
|
4199
|
+
* @returns
|
|
4200
|
+
*/ function $c6a04c153e9853a7$var$encode_array(array) {
|
|
4201
|
+
const is_nested = array.every((item)=>Array.isArray(item));
|
|
4202
|
+
if (is_nested) return array.map($c6a04c153e9853a7$var$encode_array).join($c6a04c153e9853a7$var$array_item_delimiter) + $c6a04c153e9853a7$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
|
|
4203
|
+
return array.map((item)=>item === "" ? $c6a04c153e9853a7$var$empty_item_replacement : item).join($c6a04c153e9853a7$var$string_item_delimiter);
|
|
4204
|
+
}
|
|
4205
|
+
function $c6a04c153e9853a7$var$decode_array(encoded_array) {
|
|
4206
|
+
const is_nested = encoded_array.includes($c6a04c153e9853a7$var$array_item_delimiter);
|
|
4207
|
+
if (is_nested) return encoded_array.split($c6a04c153e9853a7$var$array_item_delimiter).filter((s)=>s !== "") // Remove empty segments, caused by trailing delimiter
|
|
4208
|
+
.map($c6a04c153e9853a7$var$decode_array);
|
|
4209
|
+
return encoded_array.split($c6a04c153e9853a7$var$string_item_delimiter).filter((s)=>s !== "") // Remove empty segments, caused by trailing delimiter in the single item special case
|
|
4210
|
+
.map((item)=>item === $c6a04c153e9853a7$var$empty_item_replacement ? "" : item);
|
|
4211
|
+
}
|
|
4212
|
+
function $c6a04c153e9853a7$var$encode_filter_data(op, data) {
|
|
4213
|
+
if (data === "true") // boolean encoding
|
|
4214
|
+
return "1";
|
|
4215
|
+
if (data === "false") // boolean encoding
|
|
4216
|
+
return "0";
|
|
4217
|
+
const data_is_array = Array.isArray(data);
|
|
4218
|
+
if (op === "inrange" && data_is_array && data.every((item)=>typeof item === "number")) // numeric range filter encoding
|
|
4219
|
+
return data.join($c6a04c153e9853a7$var$range_delimiter);
|
|
4220
|
+
if (data_is_array && $c6a04c153e9853a7$var$array_is_serializable(data)) {
|
|
4221
|
+
const encoded_data = $c6a04c153e9853a7$var$encode_array(data);
|
|
4222
|
+
if (!encoded_data.includes($c6a04c153e9853a7$var$array_item_delimiter) && !encoded_data.includes($c6a04c153e9853a7$var$string_item_delimiter)) // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
|
|
4223
|
+
// In that case we add a delimiter suffix at the end
|
|
4224
|
+
return encoded_data + $c6a04c153e9853a7$var$string_item_delimiter;
|
|
4225
|
+
return encoded_data;
|
|
4226
|
+
}
|
|
4227
|
+
// Fallback encoding
|
|
4228
|
+
return (0, $46MJV$lzstring.compressToBase64)(JSON.stringify(data));
|
|
4229
|
+
}
|
|
4230
|
+
function $c6a04c153e9853a7$var$decode_filter_data(op, encoded_data) {
|
|
4231
|
+
if (encoded_data === "1") return "true";
|
|
4232
|
+
if (encoded_data === "0") return "false";
|
|
4233
|
+
if (op === "inrange" && encoded_data.includes($c6a04c153e9853a7$var$range_delimiter)) return encoded_data.split($c6a04c153e9853a7$var$range_delimiter).map((x)=>parseFloat(x));
|
|
4234
|
+
if (encoded_data.includes($c6a04c153e9853a7$var$string_item_delimiter) || encoded_data.includes($c6a04c153e9853a7$var$array_item_delimiter)) return $c6a04c153e9853a7$var$decode_array(encoded_data);
|
|
4235
|
+
try {
|
|
4236
|
+
return JSON.parse((0, $46MJV$lzstring.decompressFromBase64)(encoded_data));
|
|
4237
|
+
} catch (e) {
|
|
4238
|
+
(0, $46MJV$depictaiutilishared.dlog)("Failed to fallback parse filter data", op, encoded_data, e);
|
|
4239
|
+
}
|
|
4240
|
+
return null;
|
|
4241
|
+
}
|
|
4242
|
+
function $c6a04c153e9853a7$export$58aa3f171519b6d7(filters, search_params) {
|
|
4243
|
+
for (const filter of filters){
|
|
4244
|
+
const { field: field , op: op , data: data } = filter;
|
|
4245
|
+
const encoded_data = $c6a04c153e9853a7$var$encode_filter_data(op, data);
|
|
4246
|
+
search_params.set($c6a04c153e9853a7$var$filter_query_param_prefix + field + $c6a04c153e9853a7$var$operator_map[op], encoded_data);
|
|
4247
|
+
}
|
|
4248
|
+
}
|
|
4249
|
+
function $c6a04c153e9853a7$export$f934fa24c3a86811(search_params) {
|
|
4250
|
+
const found_filters = [];
|
|
4251
|
+
for (const key of search_params.keys()){
|
|
4252
|
+
if (!key.startsWith($c6a04c153e9853a7$var$filter_query_param_prefix)) continue;
|
|
4253
|
+
const encoded_data = search_params.get(key);
|
|
4254
|
+
if (!encoded_data) continue;
|
|
4255
|
+
for (const op of Object.keys($c6a04c153e9853a7$var$operator_map)){
|
|
4256
|
+
const token = $c6a04c153e9853a7$var$operator_map[op];
|
|
4257
|
+
if (!key.endsWith(token)) continue;
|
|
4258
|
+
const data = $c6a04c153e9853a7$var$decode_filter_data(op, encoded_data);
|
|
4259
|
+
if (!data) continue;
|
|
4260
|
+
const field = key.slice($c6a04c153e9853a7$var$filter_query_param_prefix.length, -token.length);
|
|
4261
|
+
found_filters.push({
|
|
4262
|
+
field: field,
|
|
4263
|
+
op: op,
|
|
4264
|
+
data: data
|
|
4265
|
+
});
|
|
4266
|
+
}
|
|
4267
|
+
}
|
|
4268
|
+
return found_filters;
|
|
4269
|
+
}
|
|
4270
|
+
function $c6a04c153e9853a7$export$62acb285a7579555(sorting, search_params) {
|
|
4271
|
+
if (!sorting) return;
|
|
4272
|
+
const { field: field , order: order } = sorting;
|
|
4273
|
+
const ascending = order === "asc";
|
|
4274
|
+
search_params.set($c6a04c153e9853a7$var$sorting_query_param, field + (ascending ? $c6a04c153e9853a7$var$ascending_token : $c6a04c153e9853a7$var$descending_token));
|
|
4275
|
+
}
|
|
4276
|
+
function $c6a04c153e9853a7$export$766e9676e74997d3(search_params) {
|
|
4277
|
+
const encoded_sorting = search_params.get($c6a04c153e9853a7$var$sorting_query_param);
|
|
4278
|
+
if (!encoded_sorting) return;
|
|
4279
|
+
if (encoded_sorting.endsWith($c6a04c153e9853a7$var$ascending_token)) return {
|
|
4280
|
+
field: encoded_sorting.slice(0, -$c6a04c153e9853a7$var$ascending_token.length),
|
|
4281
|
+
order: "asc"
|
|
4282
|
+
};
|
|
4283
|
+
if (encoded_sorting.endsWith($c6a04c153e9853a7$var$descending_token)) return {
|
|
4284
|
+
field: encoded_sorting.slice(0, -$c6a04c153e9853a7$var$descending_token.length),
|
|
4285
|
+
order: "desc"
|
|
4286
|
+
};
|
|
4287
|
+
(0, $46MJV$depictaiutilishared.dlog)("Invalid sorting query param value", encoded_sorting);
|
|
4288
|
+
return;
|
|
4289
|
+
}
|
|
4290
|
+
function $c6a04c153e9853a7$export$af4a870a0ee262c4(search_params) {
|
|
4291
|
+
// We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
|
|
4292
|
+
const keys = [
|
|
4293
|
+
...search_params.keys()
|
|
4294
|
+
];
|
|
4295
|
+
for (const key of keys)if (key.startsWith($c6a04c153e9853a7$var$filter_query_param_prefix) || key === $c6a04c153e9853a7$var$sorting_query_param) search_params.delete(key);
|
|
4296
|
+
}
|
|
4297
|
+
const $c6a04c153e9853a7$export$e2cf3f19dd3f8aac = "went_sideways_clear_filters";
|
|
4298
|
+
function $c6a04c153e9853a7$export$43cd1e747fecd42e(to_url, set_clearing_flag, from_search_params = new URLSearchParams(location.search)) {
|
|
4299
|
+
if (!to_url) return to_url;
|
|
4300
|
+
const was_url_object = to_url instanceof URL;
|
|
4301
|
+
const url_object = was_url_object ? to_url : new URL(to_url);
|
|
4302
|
+
const { searchParams: searchParams } = url_object;
|
|
4303
|
+
if (set_clearing_flag) searchParams.set($c6a04c153e9853a7$export$e2cf3f19dd3f8aac, "true");
|
|
4304
|
+
if (from_search_params.has($c6a04c153e9853a7$var$sorting_query_param)) searchParams.set($c6a04c153e9853a7$var$sorting_query_param, from_search_params.get($c6a04c153e9853a7$var$sorting_query_param));
|
|
4305
|
+
for (const key of from_search_params.keys())if (key.startsWith($c6a04c153e9853a7$var$filter_query_param_prefix)) searchParams.set(key, from_search_params.get(key));
|
|
4306
|
+
if (was_url_object) return url_object;
|
|
4307
|
+
return url_object.href;
|
|
4308
|
+
}
|
|
4309
|
+
|
|
4310
|
+
|
|
4163
4311
|
const $495e9998757c5d32$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<nav class="crumbs"></nav>`, 2), $495e9998757c5d32$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="crumb"></a>`, 2), $495e9998757c5d32$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="separator"></span>`, 2);
|
|
4164
|
-
function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_data ,
|
|
4312
|
+
function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_data , router_: router_ , i18n_: i18n_ }) {
|
|
4165
4313
|
const placeholder_crumb_data = [
|
|
4166
4314
|
,
|
|
4167
4315
|
,
|
|
@@ -4178,6 +4326,7 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4178
4326
|
return crumb_data();
|
|
4179
4327
|
},
|
|
4180
4328
|
children: (display_accessor, index)=>{
|
|
4329
|
+
const href = (0, $46MJV$solidjs.createMemo)(()=>(0, $c6a04c153e9853a7$export$43cd1e747fecd42e)(display_accessor()?.page_url));
|
|
4181
4330
|
return [
|
|
4182
4331
|
(0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
4183
4332
|
get when () {
|
|
@@ -4191,9 +4340,13 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4191
4340
|
},
|
|
4192
4341
|
get children () {
|
|
4193
4342
|
const _el$2 = $495e9998757c5d32$var$_tmpl$2.cloneNode(true);
|
|
4194
|
-
(0, $46MJV$solidjsweb.addEventListener)(_el$2, "click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>
|
|
4343
|
+
(0, $46MJV$solidjsweb.addEventListener)(_el$2, "click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>router_.navigate_.go_to_({
|
|
4344
|
+
new_url_: href(),
|
|
4345
|
+
is_replace_: false,
|
|
4346
|
+
event_: ev
|
|
4347
|
+
})), true);
|
|
4195
4348
|
(0, $46MJV$solidjsweb.insert)(_el$2, ()=>display_accessor().title);
|
|
4196
|
-
(0, $46MJV$solidjsweb.effect)(()=>(0, $46MJV$solidjsweb.setAttribute)(_el$2, "href",
|
|
4349
|
+
(0, $46MJV$solidjsweb.effect)(()=>(0, $46MJV$solidjsweb.setAttribute)(_el$2, "href", href()));
|
|
4197
4350
|
return _el$2;
|
|
4198
4351
|
}
|
|
4199
4352
|
}),
|
|
@@ -4230,8 +4383,9 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4230
4383
|
|
|
4231
4384
|
|
|
4232
4385
|
|
|
4386
|
+
|
|
4233
4387
|
const $cdc2c00c0a7da86e$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<nav class="quicklinks"></nav>`, 2), $cdc2c00c0a7da86e$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div>QuickLinks failed</div>`, 2), $cdc2c00c0a7da86e$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="quicklink"></a>`, 2);
|
|
4234
|
-
function $cdc2c00c0a7da86e$export$466cdc317043f6cb({ quicklinks_data_: quicklinks_data_ ,
|
|
4388
|
+
function $cdc2c00c0a7da86e$export$466cdc317043f6cb({ quicklinks_data_: quicklinks_data_ , router_: router_ , current_query_id_: current_query_id_ , slider_arrow_button_: slider_arrow_button_ , breadcrumb_data_: breadcrumb_data_ , i18n_: i18n_ }) {
|
|
4235
4389
|
let scrolling_logic_ran_for_query_id = false;
|
|
4236
4390
|
let last_scroll_position;
|
|
4237
4391
|
let scroll_to_element_on_dom_insertion;
|
|
@@ -4354,18 +4508,37 @@ function $cdc2c00c0a7da86e$export$466cdc317043f6cb({ quicklinks_data_: quicklink
|
|
|
4354
4508
|
},
|
|
4355
4509
|
children: (display_accessor, index)=>{
|
|
4356
4510
|
const is_selected = (0, $46MJV$solidjs.createMemo)(()=>selected_index() === index);
|
|
4511
|
+
// Problem: if opening a sibling link in a new tab, filter clearing behavior is no longer consistent
|
|
4512
|
+
// Solution:
|
|
4513
|
+
// If id of current category is in quick links they're siblings, don't add state to the url
|
|
4514
|
+
// If it's not in it, it's a child of the current one, so add state
|
|
4515
|
+
// (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)
|
|
4516
|
+
// Problem: When you don't open a link in a new tab, we don't display the filter cleared toast
|
|
4517
|
+
// 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
|
|
4518
|
+
const is_sibling = (0, $46MJV$solidjs.createMemo)(()=>{
|
|
4519
|
+
const current_id = current_query_id_();
|
|
4520
|
+
return quicklinks_data_()?.some(({ query_id: query_id })=>query_id === current_id);
|
|
4521
|
+
});
|
|
4522
|
+
const href = (0, $46MJV$solidjs.createMemo)(()=>// 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
|
|
4523
|
+
(0, $c6a04c153e9853a7$export$43cd1e747fecd42e)(display_accessor()?.page_url, is_sibling()));
|
|
4357
4524
|
return (()=>{
|
|
4358
4525
|
const _el$3 = $cdc2c00c0a7da86e$var$_tmpl$3.cloneNode(true);
|
|
4359
4526
|
(0, $46MJV$solidjsweb.addEventListener)(_el$3, "click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>{
|
|
4360
|
-
|
|
4361
|
-
|
|
4527
|
+
const url = href();
|
|
4528
|
+
if (is_selected() && !ev.metaKey && !ev.ctrlKey && !ev.button || !url) // allow open currently selected one in new tab but otherwise prevent clicks
|
|
4529
|
+
ev.preventDefault();
|
|
4530
|
+
else if (href()) router_.navigate_.go_to_({
|
|
4531
|
+
new_url_: url,
|
|
4532
|
+
is_replace_: false,
|
|
4533
|
+
event_: ev
|
|
4534
|
+
});
|
|
4362
4535
|
}), true);
|
|
4363
4536
|
(0, $46MJV$solidjsweb.insert)(_el$3, ()=>display_accessor()?.title || (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.Placeholder), {
|
|
4364
4537
|
height: "1em",
|
|
4365
4538
|
width: "10ch"
|
|
4366
4539
|
}));
|
|
4367
4540
|
(0, $46MJV$solidjsweb.effect)((_p$)=>{
|
|
4368
|
-
const _v$ = !!is_selected(), _v$2 =
|
|
4541
|
+
const _v$ = !!is_selected(), _v$2 = href();
|
|
4369
4542
|
_v$ !== _p$._v$ && _el$3.classList.toggle("selected", _p$._v$ = _v$);
|
|
4370
4543
|
_v$2 !== _p$._v$2 && (0, $46MJV$solidjsweb.setAttribute)(_el$3, "href", _p$._v$2 = _v$2);
|
|
4371
4544
|
return _p$;
|
|
@@ -4392,7 +4565,17 @@ function $cdc2c00c0a7da86e$export$466cdc317043f6cb({ quicklinks_data_: quicklink
|
|
|
4392
4565
|
|
|
4393
4566
|
|
|
4394
4567
|
|
|
4395
|
-
|
|
4568
|
+
|
|
4569
|
+
function $207f7b30db90d048$export$3945d6db2dfd3d12({ crumb_data_: crumb_data_ , query_id_: query_id_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , plp_results_: plp_results_ }) {
|
|
4570
|
+
// If we just got opened in a new tab, clear filters instantly and remove the flag
|
|
4571
|
+
$207f7b30db90d048$var$clear_if_opened_new_tab_with_sideways_url_params_flag({
|
|
4572
|
+
plp_results_: plp_results_,
|
|
4573
|
+
local_filter_cache_: local_filter_cache_,
|
|
4574
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4575
|
+
selected_filters_: selected_filters_,
|
|
4576
|
+
i18n_: i18n_
|
|
4577
|
+
});
|
|
4578
|
+
// Code below is for when we're already open and the user navigates to a new category
|
|
4396
4579
|
let previous_crumb_data = (0, $46MJV$solidjs.untrack)(crumb_data_);
|
|
4397
4580
|
let query_id_when_we_got_previous_data = (0, $46MJV$solidjs.untrack)(query_id_);
|
|
4398
4581
|
let allow_filter_clearing = true; // set to false when going backwards/forwards
|
|
@@ -4409,7 +4592,41 @@ function $34f90ffb69e23732$export$3fe6942dd2836d9d({ crumb_data_: crumb_data_ ,
|
|
|
4409
4592
|
const went_downwards = previous_length < new_length;
|
|
4410
4593
|
const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
|
|
4411
4594
|
const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
|
|
4412
|
-
if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id)))
|
|
4595
|
+
if (!((went_upwards || went_downwards) && shorter_array.every(({ query_id: query_id }, index)=>longer_array[index].query_id === query_id))) {
|
|
4596
|
+
// We went sideways, not up or down. Clear filters.
|
|
4597
|
+
(0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
|
|
4598
|
+
user_triggered_: false,
|
|
4599
|
+
i18n_: i18n_,
|
|
4600
|
+
also_clear_sorting_: false,
|
|
4601
|
+
selected_filters_: selected_filters_,
|
|
4602
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4603
|
+
local_filter_cache_: local_filter_cache_
|
|
4604
|
+
});
|
|
4605
|
+
// Also ensure we don't have `sideways_url_params_flag` set anymore
|
|
4606
|
+
const url = new URL(location.href);
|
|
4607
|
+
const { searchParams: searchParams } = url;
|
|
4608
|
+
if (searchParams.has((0, $c6a04c153e9853a7$export$e2cf3f19dd3f8aac))) {
|
|
4609
|
+
searchParams.delete((0, $c6a04c153e9853a7$export$e2cf3f19dd3f8aac));
|
|
4610
|
+
history.replaceState(history.state, "", url.href);
|
|
4611
|
+
}
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
4614
|
+
query_id_when_we_got_previous_data = query_id_of_new_data;
|
|
4615
|
+
previous_crumb_data = new_crumb_data;
|
|
4616
|
+
if (!allow_filter_clearing) allow_filter_clearing = true;
|
|
4617
|
+
})));
|
|
4618
|
+
}
|
|
4619
|
+
function $207f7b30db90d048$var$clear_if_opened_new_tab_with_sideways_url_params_flag({ plp_results_: plp_results_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , i18n_: i18n_ , selected_filters_: selected_filters_ , local_filter_cache_: local_filter_cache_ }) {
|
|
4620
|
+
const tracking_function_for_plp_results = (0, $46MJV$solidjs.createReaction)(()=>{
|
|
4621
|
+
// 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
|
|
4622
|
+
const url_object = new URL(location.href);
|
|
4623
|
+
const { searchParams: searchParams } = url_object;
|
|
4624
|
+
if (searchParams.get((0, $c6a04c153e9853a7$export$e2cf3f19dd3f8aac)) !== "true") return;
|
|
4625
|
+
searchParams.delete((0, $c6a04c153e9853a7$export$e2cf3f19dd3f8aac));
|
|
4626
|
+
history.replaceState(history.state, "", url_object.href);
|
|
4627
|
+
(0, $46MJV$depictaiutilishared.dlog)("Flag to clear filters was set, clearing filters");
|
|
4628
|
+
(0, $46MJV$depictaiutilishared.queueMacroTask)(()=>{
|
|
4629
|
+
// Do it next task so that all the filters have time to populate
|
|
4413
4630
|
(0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
|
|
4414
4631
|
user_triggered_: false,
|
|
4415
4632
|
i18n_: i18n_,
|
|
@@ -4418,11 +4635,9 @@ function $34f90ffb69e23732$export$3fe6942dd2836d9d({ crumb_data_: crumb_data_ ,
|
|
|
4418
4635
|
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4419
4636
|
local_filter_cache_: local_filter_cache_
|
|
4420
4637
|
});
|
|
4421
|
-
}
|
|
4422
|
-
|
|
4423
|
-
|
|
4424
|
-
if (!allow_filter_clearing) allow_filter_clearing = true;
|
|
4425
|
-
})));
|
|
4638
|
+
});
|
|
4639
|
+
});
|
|
4640
|
+
tracking_function_for_plp_results(plp_results_);
|
|
4426
4641
|
}
|
|
4427
4642
|
|
|
4428
4643
|
|
|
@@ -4541,7 +4756,7 @@ let $29b757e2ae26852c$export$44dad306455dddf;
|
|
|
4541
4756
|
|
|
4542
4757
|
|
|
4543
4758
|
const $671632478f2a7ce7$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="product-count"> </div>`, 2), $671632478f2a7ce7$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div></div>`, 2), $671632478f2a7ce7$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="filter-results-for-one-row"></div>`, 2), $671632478f2a7ce7$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp category"><div class="listing-page"></div></div>`, 4);
|
|
4544
|
-
function $671632478f2a7ce7$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_ ,
|
|
4759
|
+
function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ , query_id_: query_id_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , category_filters_open_: category_filters_open_ , category_sorting_open_: category_sorting_open_ , expanded_filters_: expanded_filters_ , selected_filters_: selected_filters_ , get_quicklinks_accessor_: get_quicklinks_accessor_ , i18n_: incoming_i18n , get_breadcrumb_accessor_: get_breadcrumb_accessor_ , slider_arrow_button_: slider_arrow_button_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , local_filter_cache_: local_filter_cache_ , tenant_: tenant_ , market_: market_ , router_: router_ , show_quicklinks_: show_quicklinks_ , category_title_: category_title_ , show_breadcrumbs_: show_breadcrumbs_ , layout_options_: layout_options_ , scroll_restoration_data_: scroll_restoration_data_ , rr_options_: rr_options_ , get_product_id_: get_product_id_ }) {
|
|
4545
4760
|
let results_for;
|
|
4546
4761
|
let only_show_filters_opener_;
|
|
4547
4762
|
let middle_elements_;
|
|
@@ -4555,8 +4770,7 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4555
4770
|
TENANT: (0, $46MJV$solidjs.untrack)(tenant_),
|
|
4556
4771
|
MARKET: (0, $46MJV$solidjs.untrack)(market_),
|
|
4557
4772
|
GA_ID: "",
|
|
4558
|
-
get_product_id: get_product_id_
|
|
4559
|
-
pageview_tracking: !disable_default_tracking_
|
|
4773
|
+
get_product_id: get_product_id_
|
|
4560
4774
|
});
|
|
4561
4775
|
const [get_sorting] = current_sorting_;
|
|
4562
4776
|
const number_of_rendered_selected_filters_items_ = (0, $46MJV$solidjs.createSignal)(0);
|
|
@@ -4716,13 +4930,14 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4716
4930
|
selected_filters_: selected_filters_,
|
|
4717
4931
|
available_filters_: available_filters_
|
|
4718
4932
|
});
|
|
4719
|
-
(0, $
|
|
4933
|
+
(0, $207f7b30db90d048$export$3945d6db2dfd3d12)({
|
|
4720
4934
|
query_id_: query_id_,
|
|
4721
4935
|
crumb_data_: crumb_data_,
|
|
4722
4936
|
i18n_: i18n_,
|
|
4723
4937
|
selected_filters_: selected_filters_,
|
|
4724
4938
|
local_filter_cache_: local_filter_cache_,
|
|
4725
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_
|
|
4939
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4940
|
+
plp_results_: plp_results_
|
|
4726
4941
|
});
|
|
4727
4942
|
get_breadcrumb_accessor_?.(crumb_data_);
|
|
4728
4943
|
get_quicklinks_accessor_?.(quicklinks_data_);
|
|
@@ -4735,7 +4950,7 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4735
4950
|
get children () {
|
|
4736
4951
|
return (0, $46MJV$solidjsweb.createComponent)((0, $495e9998757c5d32$export$5646050d516e06bc), {
|
|
4737
4952
|
crumb_data_: crumb_data_,
|
|
4738
|
-
|
|
4953
|
+
router_: router_,
|
|
4739
4954
|
i18n_: i18n_
|
|
4740
4955
|
});
|
|
4741
4956
|
}
|
|
@@ -4746,7 +4961,7 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4746
4961
|
return (0, $46MJV$solidjsweb.createComponent)((0, $cdc2c00c0a7da86e$export$466cdc317043f6cb), {
|
|
4747
4962
|
quicklinks_data_: quicklinks_data_,
|
|
4748
4963
|
current_query_id_: query_id_,
|
|
4749
|
-
|
|
4964
|
+
router_: router_,
|
|
4750
4965
|
slider_arrow_button_: slider_arrow_button_,
|
|
4751
4966
|
breadcrumb_data_: crumb_data_,
|
|
4752
4967
|
i18n_: i18n_
|
|
@@ -4803,8 +5018,7 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4803
5018
|
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4804
5019
|
i18n_: i18n_,
|
|
4805
5020
|
local_filter_cache_: local_filter_cache_
|
|
4806
|
-
}
|
|
4807
|
-
disable_default_tracking_: disable_default_tracking_
|
|
5021
|
+
}
|
|
4808
5022
|
});
|
|
4809
5023
|
}
|
|
4810
5024
|
}), null);
|
|
@@ -4971,6 +5185,166 @@ function $f27b0b326e0a87e2$export$23fca46f3143581f(component, error_message) {
|
|
|
4971
5185
|
}
|
|
4972
5186
|
|
|
4973
5187
|
|
|
5188
|
+
|
|
5189
|
+
|
|
5190
|
+
|
|
5191
|
+
function $004640621ca953d0$export$7bcff1eb3eca57d7(router) {
|
|
5192
|
+
const current_sorting_ = (0, $46MJV$solidjs.createSignal)();
|
|
5193
|
+
const selected_filters_ = (0, $46MJV$solidjs.createSignal)([]);
|
|
5194
|
+
const [get_sorting, set_sorting] = current_sorting_;
|
|
5195
|
+
const [get_selected_filters, set_selected_filters] = selected_filters_;
|
|
5196
|
+
const [get_current_href, set_current_href] = (0, $46MJV$solidjs.createSignal)(location.href);
|
|
5197
|
+
const history_change_handler = ()=>set_current_href(location.href);
|
|
5198
|
+
const owner = (0, $46MJV$solidjs.getOwner)() || (0, $46MJV$solidjs.createRoot)(()=>(0, $46MJV$solidjs.getOwner)());
|
|
5199
|
+
let writer_started = false;
|
|
5200
|
+
(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).add(history_change_handler);
|
|
5201
|
+
(0, $46MJV$solidjs.onCleanup)(()=>(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).delete(history_change_handler));
|
|
5202
|
+
(0, $46MJV$solidjs.createComputed)(()=>{
|
|
5203
|
+
const { searchParams: searchParams } = new URL(get_current_href());
|
|
5204
|
+
(0, $46MJV$solidjs.batch)(()=>{
|
|
5205
|
+
const found_sorting = (0, $c6a04c153e9853a7$export$766e9676e74997d3)(searchParams);
|
|
5206
|
+
if (found_sorting) {
|
|
5207
|
+
const current_sorting = (0, $46MJV$solidjs.untrack)(get_sorting);
|
|
5208
|
+
// Do some diffing since we might assume in certain places of the code that if the signal changes it means the sorting has changed
|
|
5209
|
+
if (current_sorting?.field !== found_sorting.field || current_sorting?.order !== found_sorting.order) set_sorting(found_sorting);
|
|
5210
|
+
} else set_sorting();
|
|
5211
|
+
const found_filters = (0, $c6a04c153e9853a7$export$f934fa24c3a86811)(searchParams);
|
|
5212
|
+
const selected_filters = (0, $46MJV$solidjs.untrack)(get_selected_filters);
|
|
5213
|
+
const found_filters_map = new Map(found_filters.map(({ field: field , op: op , data: data })=>[
|
|
5214
|
+
JSON.stringify([
|
|
5215
|
+
field,
|
|
5216
|
+
op
|
|
5217
|
+
]),
|
|
5218
|
+
data
|
|
5219
|
+
]));
|
|
5220
|
+
// Sorry for this diffing algorithm lol. Looking forwards to Records and Tuples.
|
|
5221
|
+
if (selected_filters.length !== found_filters.length || !selected_filters.every(({ field: field , op: op , data: data })=>JSON.stringify(found_filters_map.get(JSON.stringify([
|
|
5222
|
+
field,
|
|
5223
|
+
op
|
|
5224
|
+
]))) === JSON.stringify(data))) set_selected_filters(found_filters);
|
|
5225
|
+
if (!writer_started) {
|
|
5226
|
+
// The owner here is the createComputed which gets disposed the next time the computation runs - but we actually just want to delay the start of the href_writer until our signals contain the current value of the URL, therefore the runWithOwner
|
|
5227
|
+
(0, $46MJV$solidjs.runWithOwner)(owner, ()=>$004640621ca953d0$var$start_href_writer(get_sorting, get_selected_filters, router));
|
|
5228
|
+
writer_started = true;
|
|
5229
|
+
}
|
|
5230
|
+
});
|
|
5231
|
+
});
|
|
5232
|
+
return {
|
|
5233
|
+
current_sorting_: current_sorting_,
|
|
5234
|
+
selected_filters_: selected_filters_
|
|
5235
|
+
};
|
|
5236
|
+
}
|
|
5237
|
+
/**
|
|
5238
|
+
* Writes the sorting and filters to the URL query parameters when they change.
|
|
5239
|
+
*/ function $004640621ca953d0$var$start_href_writer(get_sorting, get_selected_filters, router) {
|
|
5240
|
+
// 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)
|
|
5241
|
+
(0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)([
|
|
5242
|
+
get_sorting,
|
|
5243
|
+
get_selected_filters
|
|
5244
|
+
], ([sorting, filters])=>{
|
|
5245
|
+
const current_href = location.href;
|
|
5246
|
+
const url_object = new URL(current_href);
|
|
5247
|
+
const { searchParams: searchParams } = url_object;
|
|
5248
|
+
(0, $c6a04c153e9853a7$export$af4a870a0ee262c4)(searchParams);
|
|
5249
|
+
(0, $c6a04c153e9853a7$export$62acb285a7579555)(sorting, searchParams);
|
|
5250
|
+
(0, $c6a04c153e9853a7$export$58aa3f171519b6d7)(filters, searchParams);
|
|
5251
|
+
// 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
|
|
5252
|
+
const unmodified_search_params = [
|
|
5253
|
+
...new URL(current_href).searchParams
|
|
5254
|
+
];
|
|
5255
|
+
const new_search_params = [
|
|
5256
|
+
...searchParams
|
|
5257
|
+
];
|
|
5258
|
+
// Having the array middle step because if we'd check the "size" property of the map the algorithm could be fooled if there were two query parameters with the same key
|
|
5259
|
+
const new_search_params_map = new Map(new_search_params);
|
|
5260
|
+
if (unmodified_search_params.length !== new_search_params.length || !unmodified_search_params.every(([key, value])=>new_search_params_map.get(key) === value)) // Only update URL if it actually changed
|
|
5261
|
+
router.navigate_.go_to_({
|
|
5262
|
+
is_replace_: true,
|
|
5263
|
+
new_url_: url_object.href,
|
|
5264
|
+
force_spa_navigation_: true
|
|
5265
|
+
});
|
|
5266
|
+
}, {
|
|
5267
|
+
defer: true
|
|
5268
|
+
}));
|
|
5269
|
+
}
|
|
5270
|
+
|
|
5271
|
+
|
|
5272
|
+
|
|
5273
|
+
class $43940d5ca403c293$export$7e1297a3a19f10d8 {
|
|
5274
|
+
#forced_default_on_navigation({ is_replace: is_replace , new_url: new_url }) {
|
|
5275
|
+
history[is_replace ? "replaceState" : "pushState"](history.state, "", new_url);
|
|
5276
|
+
}
|
|
5277
|
+
/**
|
|
5278
|
+
* Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
|
|
5279
|
+
*/ #throwing_on_navigation(...args) {
|
|
5280
|
+
const { on_navigation_: on_navigation_ } = this;
|
|
5281
|
+
if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
|
|
5282
|
+
// make sure that we don't accidentally catchify if the SDK consumer has fucked up
|
|
5283
|
+
try {
|
|
5284
|
+
return on_navigation_(...args);
|
|
5285
|
+
} catch (e) {
|
|
5286
|
+
queueMicrotask(()=>{
|
|
5287
|
+
throw e;
|
|
5288
|
+
});
|
|
5289
|
+
}
|
|
5290
|
+
}
|
|
5291
|
+
/**
|
|
5292
|
+
* Checks if this tab shouldn't navigate because user wants to open in new tab
|
|
5293
|
+
*/ #dont_attempt_navigation(ev) {
|
|
5294
|
+
return ev?.button || ev?.metaKey || ev?.ctrlKey;
|
|
5295
|
+
}
|
|
5296
|
+
/**
|
|
5297
|
+
* Vue has async router that needs to be awaited (it navigates after a microtask)
|
|
5298
|
+
* This standardises waiting for all kinds of routers
|
|
5299
|
+
*/ #get_navigation_happened_promise(is_replace1) {
|
|
5300
|
+
return new Promise((resolve)=>{
|
|
5301
|
+
const handler = (what_happened)=>{
|
|
5302
|
+
if (what_happened === (is_replace1 ? "replaceState" : "pushState")) {
|
|
5303
|
+
resolve();
|
|
5304
|
+
(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).delete(handler);
|
|
5305
|
+
}
|
|
5306
|
+
};
|
|
5307
|
+
(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).add(handler);
|
|
5308
|
+
});
|
|
5309
|
+
}
|
|
5310
|
+
navigate_ = {
|
|
5311
|
+
/**
|
|
5312
|
+
* Call this if you *just* want to replace the state object in history.state
|
|
5313
|
+
*/ replace_state_: (new_state)=>{
|
|
5314
|
+
// This doesn't break any router, so we just do this directly for now, since many don't expose an interface for changing the state
|
|
5315
|
+
history.replaceState(new_state, "");
|
|
5316
|
+
},
|
|
5317
|
+
/**
|
|
5318
|
+
* Call this to change the URL
|
|
5319
|
+
* @param new_url_ new URL to go to
|
|
5320
|
+
* @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
|
|
5321
|
+
* @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
|
|
5322
|
+
* @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
|
|
5323
|
+
*/ go_to_: async ({ new_url_: new_url_ , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ })=>{
|
|
5324
|
+
const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
|
|
5325
|
+
if (this.#dont_attempt_navigation(event_)) return;
|
|
5326
|
+
if (wants_hard_navigation && !force_spa_navigation_) {
|
|
5327
|
+
if (!event_) // If we haven't gotten an event, nothing will happen by not calling prevent default, so we need to change the URL
|
|
5328
|
+
location.assign(new_url_);
|
|
5329
|
+
return;
|
|
5330
|
+
}
|
|
5331
|
+
event_?.preventDefault();
|
|
5332
|
+
const promise = this.#get_navigation_happened_promise(true);
|
|
5333
|
+
const navigation_function = // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
|
|
5334
|
+
force_spa_navigation_ && wants_hard_navigation ? this.#forced_default_on_navigation : this.#throwing_on_navigation;
|
|
5335
|
+
navigation_function.call(this, {
|
|
5336
|
+
is_replace: is_replace_,
|
|
5337
|
+
new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_)
|
|
5338
|
+
});
|
|
5339
|
+
await promise;
|
|
5340
|
+
}
|
|
5341
|
+
};
|
|
5342
|
+
constructor(on_navigation){
|
|
5343
|
+
this.on_navigation_ = on_navigation;
|
|
5344
|
+
}
|
|
5345
|
+
}
|
|
5346
|
+
|
|
5347
|
+
|
|
4974
5348
|
const $068a627cc18f7bb6$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp category"></div>`, 2);
|
|
4975
5349
|
const $068a627cc18f7bb6$var$min_products_to_fetch_ = 20;
|
|
4976
5350
|
const $068a627cc18f7bb6$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
@@ -4981,6 +5355,7 @@ const $068a627cc18f7bb6$var$InExternalAreaDiv = ({ children: children })=>(()=>
|
|
|
4981
5355
|
return _el$;
|
|
4982
5356
|
})();
|
|
4983
5357
|
class $068a627cc18f7bb6$export$f34314aa9505732e {
|
|
5358
|
+
#router = new (0, $43940d5ca403c293$export$7e1297a3a19f10d8)("hard_navigation");
|
|
4984
5359
|
#locale_signal = (0, $46MJV$solidjs.createSignal)();
|
|
4985
5360
|
#merchant_signal = (0, $46MJV$solidjs.createSignal)();
|
|
4986
5361
|
#market_signal = (0, $46MJV$solidjs.createSignal)();
|
|
@@ -5011,38 +5386,30 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
|
|
|
5011
5386
|
set market(market) {
|
|
5012
5387
|
this.#market_signal[1](market);
|
|
5013
5388
|
}
|
|
5389
|
+
get on_navigation() {
|
|
5390
|
+
// The only non-reactive public property on the class (I don't see it making sense to have it reactive)
|
|
5391
|
+
return this.#router.on_navigation_;
|
|
5392
|
+
}
|
|
5393
|
+
set on_navigation(new_function) {
|
|
5394
|
+
this.#router.on_navigation_ = new_function;
|
|
5395
|
+
}
|
|
5014
5396
|
constructor({ api: api , on_navigation: on_navigation , ...props_on_class }){
|
|
5015
5397
|
if ($068a627cc18f7bb6$export$f34314aa9505732e.#has_been_constructed) throw new Error("You can only have one instance of DepictCategory due to state limitations");
|
|
5016
5398
|
$068a627cc18f7bb6$export$f34314aa9505732e.#has_been_constructed = true;
|
|
5017
5399
|
Object.assign(this, props_on_class); // set initial signal values
|
|
5018
5400
|
(0, $33815c5a406b6cc0$export$5162a71f252e6122)();
|
|
5401
|
+
if (on_navigation) this.#router.on_navigation_ = on_navigation;
|
|
5402
|
+
const { selected_filters_: selected_filters_ , current_sorting_: current_sorting_ } = (0, $004640621ca953d0$export$7bcff1eb3eca57d7)(this.#router);
|
|
5019
5403
|
const [reset_history_state_, state_] = (0, $0de081f67b6d15b5$export$9862539c89138352)(()=>({
|
|
5020
|
-
category_sorting: undefined,
|
|
5021
5404
|
category_filters_open: false,
|
|
5022
5405
|
category_sorting_open: false,
|
|
5023
5406
|
category_expanded_filters: [],
|
|
5024
|
-
//
|
|
5025
|
-
category_selected_filters: [],
|
|
5407
|
+
// Please make sure that the signal created by below line always updates AFTER selected_filters_ updates on a "popstate" event. If the filter cache is popped before the selected filters are the code in create_modified_filters() 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
|
|
5026
5408
|
category_local_filter_cache: [],
|
|
5027
5409
|
category_expanded_hierarchical_filters: [],
|
|
5028
5410
|
category_scroll_restoration_data: []
|
|
5029
5411
|
}));
|
|
5030
5412
|
const i18n_ = (0, $623202ae203e9e59$export$f091cbac892643a4)(this.#locale_signal[0]);
|
|
5031
|
-
const on_category_link_click_ = (e, d)=>{
|
|
5032
|
-
if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
|
|
5033
|
-
return;
|
|
5034
|
-
try {
|
|
5035
|
-
const url_object = new URL(d.page_url);
|
|
5036
|
-
const relative_url = url_object.pathname + url_object.search + url_object.hash;
|
|
5037
|
-
on_navigation(relative_url, e, d);
|
|
5038
|
-
e.preventDefault();
|
|
5039
|
-
} catch (e) {
|
|
5040
|
-
queueMicrotask(()=>{
|
|
5041
|
-
// make sure to throw into the global scope if on_navigation throws
|
|
5042
|
-
throw e;
|
|
5043
|
-
});
|
|
5044
|
-
}
|
|
5045
|
-
};
|
|
5046
5413
|
$068a627cc18f7bb6$var$privately_shared_properties.set(this, {
|
|
5047
5414
|
state_: state_,
|
|
5048
5415
|
breadcrumb_signal_: (0, $46MJV$solidjs.createSignal)(),
|
|
@@ -5050,7 +5417,9 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
|
|
|
5050
5417
|
i18n_: i18n_,
|
|
5051
5418
|
reset_history_state_: reset_history_state_,
|
|
5052
5419
|
depict_api_: api ?? new (0, $9ce64f69303c371e$export$e015ed2f2950f2e3)(),
|
|
5053
|
-
|
|
5420
|
+
router_: this.#router,
|
|
5421
|
+
selected_filters_: selected_filters_,
|
|
5422
|
+
current_sorting_: current_sorting_,
|
|
5054
5423
|
slider_arrow_button_: (0, $46MJV$depictaiutilishared.GenericSliderArrowButton)({
|
|
5055
5424
|
height_: 12,
|
|
5056
5425
|
width_: 6.46
|
|
@@ -5058,7 +5427,7 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
|
|
|
5058
5427
|
});
|
|
5059
5428
|
}
|
|
5060
5429
|
}
|
|
5061
|
-
function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_category , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , get_product_id: get_product_id , show_breadcrumbs: show_breadcrumbs = true , show_quicklinks: show_quicklinks = true , category_title: category_title
|
|
5430
|
+
function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_category , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , get_product_id: get_product_id , show_breadcrumbs: show_breadcrumbs = true , show_quicklinks: show_quicklinks = true , category_title: category_title }) {
|
|
5062
5431
|
const shared_properties = $068a627cc18f7bb6$var$get_shared_properties(depict_category);
|
|
5063
5432
|
const grid_spacing_override = typeof grid_spacing === "string" ? {
|
|
5064
5433
|
grid_spacing: grid_spacing
|
|
@@ -5067,7 +5436,7 @@ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
5067
5436
|
grid_spacing: grid_spacing.horizontal
|
|
5068
5437
|
};
|
|
5069
5438
|
return (0, $f27b0b326e0a87e2$export$23fca46f3143581f)(()=>{
|
|
5070
|
-
const { state_: { category_local_filter_cache: local_filter_cache_ ,
|
|
5439
|
+
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_ , router_: router_ , breadcrumb_signal_: breadcrumb_signal_ , quicklinks_signal_: quicklinks_signal_ , slider_arrow_button_: slider_arrow_button_ } = shared_properties;
|
|
5071
5440
|
(0, $46MJV$solidjs.onCleanup)(reset_history_state_);
|
|
5072
5441
|
return (0, $671632478f2a7ce7$export$f7d2f673fc2f091d)({
|
|
5073
5442
|
tenant_: ()=>depict_category.merchant,
|
|
@@ -5081,7 +5450,7 @@ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
5081
5450
|
category_title_: category_title,
|
|
5082
5451
|
show_breadcrumbs_: show_breadcrumbs,
|
|
5083
5452
|
current_sorting_: current_sorting_,
|
|
5084
|
-
|
|
5453
|
+
router_: router_,
|
|
5085
5454
|
get_breadcrumb_accessor_: (accessor)=>(0, $46MJV$solidjs.createComputed)(()=>breadcrumb_signal_[1](accessor())),
|
|
5086
5455
|
get_quicklinks_accessor_: (accessor)=>(0, $46MJV$solidjs.createComputed)(()=>quicklinks_signal_[1](accessor())),
|
|
5087
5456
|
category_filters_open_: category_filters_open_,
|
|
@@ -5101,31 +5470,30 @@ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
5101
5470
|
const is_placeholder = info.rendering_options.type === "placeholder";
|
|
5102
5471
|
return product_card_template(is_placeholder ? null : display, info);
|
|
5103
5472
|
}
|
|
5104
|
-
}
|
|
5105
|
-
disable_default_tracking_: disable_default_tracking
|
|
5473
|
+
}
|
|
5106
5474
|
});
|
|
5107
5475
|
}, "Entire CategoryPage failed");
|
|
5108
5476
|
}
|
|
5109
5477
|
function $068a627cc18f7bb6$export$5b7c3ce0ebe51f86({ depict_category: depict_category }) {
|
|
5110
|
-
const { i18n_: i18n_ , breadcrumb_signal_: [crumb_data_] ,
|
|
5478
|
+
const { i18n_: i18n_ , breadcrumb_signal_: [crumb_data_] , router_: router_ } = $068a627cc18f7bb6$var$get_shared_properties(depict_category);
|
|
5111
5479
|
return (0, $46MJV$solidjsweb.createComponent)($068a627cc18f7bb6$var$InExternalAreaDiv, {
|
|
5112
5480
|
get children () {
|
|
5113
5481
|
return (0, $495e9998757c5d32$export$5646050d516e06bc)({
|
|
5114
5482
|
i18n_: i18n_,
|
|
5115
5483
|
crumb_data_: crumb_data_,
|
|
5116
|
-
|
|
5484
|
+
router_: router_
|
|
5117
5485
|
});
|
|
5118
5486
|
}
|
|
5119
5487
|
});
|
|
5120
5488
|
}
|
|
5121
5489
|
function $068a627cc18f7bb6$export$de035477d6fef996({ depict_category: depict_category }) {
|
|
5122
|
-
const { i18n_: i18n_ , quicklinks_signal_: [quicklinks_data_] , breadcrumb_signal_: [breadcrumb_data_] ,
|
|
5490
|
+
const { i18n_: i18n_ , quicklinks_signal_: [quicklinks_data_] , breadcrumb_signal_: [breadcrumb_data_] , router_: router_ , slider_arrow_button_: slider_arrow_button_ } = $068a627cc18f7bb6$var$get_shared_properties(depict_category);
|
|
5123
5491
|
return (0, $46MJV$solidjsweb.createComponent)($068a627cc18f7bb6$var$InExternalAreaDiv, {
|
|
5124
5492
|
get children () {
|
|
5125
5493
|
return (0, $cdc2c00c0a7da86e$export$466cdc317043f6cb)({
|
|
5126
5494
|
i18n_: i18n_,
|
|
5127
5495
|
quicklinks_data_: quicklinks_data_,
|
|
5128
|
-
|
|
5496
|
+
router_: router_,
|
|
5129
5497
|
current_query_id_: ()=>depict_category.category_id,
|
|
5130
5498
|
slider_arrow_button_: slider_arrow_button_,
|
|
5131
5499
|
breadcrumb_data_: breadcrumb_data_
|
|
@@ -5354,17 +5722,14 @@ function $17c49340edfdbb31$export$ee1733d9a8495996() {
|
|
|
5354
5722
|
|
|
5355
5723
|
|
|
5356
5724
|
const $67892c03cd3dfa66$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="parent-title"></span>`, 2), $67892c03cd3dfa66$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="category-suggestion"><span class="title"></span></a>`, 4);
|
|
5357
|
-
function $67892c03cd3dfa66$export$d757d54550ebfb3d({ category_suggestion_: category_suggestion_ ,
|
|
5725
|
+
function $67892c03cd3dfa66$export$d757d54550ebfb3d({ category_suggestion_: category_suggestion_ , router_: router_ }) {
|
|
5358
5726
|
return (()=>{
|
|
5359
5727
|
const _el$ = $67892c03cd3dfa66$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild;
|
|
5360
|
-
(0, $46MJV$solidjsweb.addEventListener)(_el$, "click", (0, $46MJV$depictaiutilishared.catchify)((e)=>{
|
|
5361
|
-
|
|
5362
|
-
|
|
5363
|
-
|
|
5364
|
-
|
|
5365
|
-
return on_navigation_(category_suggestion_().page_url);
|
|
5366
|
-
}
|
|
5367
|
-
}), true);
|
|
5728
|
+
(0, $46MJV$solidjsweb.addEventListener)(_el$, "click", (0, $46MJV$depictaiutilishared.catchify)((e)=>router_.navigate_.go_to_({
|
|
5729
|
+
new_url_: category_suggestion_().page_url,
|
|
5730
|
+
is_replace_: false,
|
|
5731
|
+
event_: e
|
|
5732
|
+
})), true);
|
|
5368
5733
|
(0, $46MJV$solidjsweb.insert)(_el$2, ()=>category_suggestion_().title);
|
|
5369
5734
|
(0, $46MJV$solidjsweb.insert)(_el$, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
5370
5735
|
get when () {
|
|
@@ -5442,13 +5807,14 @@ function $2989e355f64e18e1$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5442
5807
|
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
|
|
5443
5808
|
return;
|
|
5444
5809
|
if (input_element.selectionStart === 0 && input_element.selectionEnd === input_element.value.length) // everything was selected, clear filters on next submit on next input
|
|
5445
|
-
input_element.addEventListener("input", (0, $46MJV$depictaiutilishared.catchify)(clear_filters_),
|
|
5810
|
+
input_element.addEventListener("input", (0, $46MJV$depictaiutilishared.catchify)(()=>clear_filters_(false)), // We don't count this as user triggered since it wasn't explicit
|
|
5811
|
+
{
|
|
5446
5812
|
once: true
|
|
5447
5813
|
});
|
|
5448
5814
|
}));
|
|
5449
5815
|
(0, $46MJV$solidjsweb.addEventListener)(_el$4, "input", (0, $46MJV$depictaiutilishared.catchify)(()=>{
|
|
5450
5816
|
const { value: value } = input_element;
|
|
5451
|
-
if (!disabled_ && !value.length) clear_filters_(); // if the user clears the whole field, reset filters on next submit
|
|
5817
|
+
if (!disabled_ && !value.length) clear_filters_(false); // if the user clears the whole field, reset filters on next submit
|
|
5452
5818
|
search_field_value_[1](value);
|
|
5453
5819
|
}), true);
|
|
5454
5820
|
(0, $46MJV$solidjsweb.addEventListener)(_el$4, "keydown", (0, $46MJV$depictaiutilishared.catchify)((e)=>{
|
|
@@ -5468,7 +5834,7 @@ function $2989e355f64e18e1$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5468
5834
|
_el$4.classList.toggle("has-adjacent-back-button", !!on_back_);
|
|
5469
5835
|
(0, $46MJV$solidjsweb.addEventListener)(_el$5, "click", (0, $46MJV$depictaiutilishared.catchify)(()=>{
|
|
5470
5836
|
search_field_value_[1]("");
|
|
5471
|
-
clear_filters_();
|
|
5837
|
+
clear_filters_(true);
|
|
5472
5838
|
if (!disabled_) input_element.focus();
|
|
5473
5839
|
}), true);
|
|
5474
5840
|
(0, $46MJV$solidjsweb.insert)(_el$5, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.CrossIcon), {}));
|
|
@@ -5510,7 +5876,7 @@ function $2989e355f64e18e1$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5510
5876
|
|
|
5511
5877
|
const $9f81b7ced87aabf2$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="cards"></div>`, 2), $9f81b7ced87aabf2$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="search-recs"><h3 class="search-recs-title"></h3></div>`, 4), $9f81b7ced87aabf2$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<button class="show-more major" type="button"></button>`, 2);
|
|
5512
5878
|
const $9f81b7ced87aabf2$export$1c8c715550dc689d = 2;
|
|
5513
|
-
function $9f81b7ced87aabf2$export$7de92c4c2205ebf3({ depict_api_: depict_api_ , i18n_: i18n_ , tenant_object_: tenant_object_ , search_query_base_: search_query_base_ , rr_options_: rr_options_ , showing_recommendation_rows_: showing_recommendation_rows_ , view_more_button_: view_more_button_ = true , layout_options_: layout_options_
|
|
5879
|
+
function $9f81b7ced87aabf2$export$7de92c4c2205ebf3({ depict_api_: depict_api_ , i18n_: i18n_ , tenant_object_: tenant_object_ , search_query_base_: search_query_base_ , rr_options_: rr_options_ , showing_recommendation_rows_: showing_recommendation_rows_ , view_more_button_: view_more_button_ = true , layout_options_: layout_options_ }) {
|
|
5514
5880
|
const [is_showing_something, set_is_showing_something] = (0, $46MJV$solidjs.createSignal)(false);
|
|
5515
5881
|
const cards = $9f81b7ced87aabf2$var$_tmpl$.cloneNode(true);
|
|
5516
5882
|
const on_next_render = [];
|
|
@@ -5578,9 +5944,7 @@ function $9f81b7ced87aabf2$export$7de92c4c2205ebf3({ depict_api_: depict_api_ ,
|
|
|
5578
5944
|
template: (...args)=>(0, $46MJV$solidjs.runWithOwner)(owner_for_cards, ()=>// give template the possibility to know when it gets removed from the DOM by using solid-js onCleanup
|
|
5579
5945
|
// @ts-ignore
|
|
5580
5946
|
rr_options_.template(...args))
|
|
5581
|
-
} : {}
|
|
5582
|
-
view_tracking: disable_default_tracking_ ? [] : undefined,
|
|
5583
|
-
click_tracking: disable_default_tracking_ ? [] : undefined
|
|
5947
|
+
} : {}
|
|
5584
5948
|
});
|
|
5585
5949
|
const { elements: elements , should_stay_inserted: should_stay_inserted } = rendering_result;
|
|
5586
5950
|
let dead = false;
|
|
@@ -5688,27 +6052,27 @@ function $67b60b572b7b7059$export$b3ad617e9036868(modal_body_style, input_field,
|
|
|
5688
6052
|
|
|
5689
6053
|
|
|
5690
6054
|
function $8b282f736ce4f3b8$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_ }) {
|
|
5691
|
-
const [get_selected_filters
|
|
5692
|
-
|
|
6055
|
+
const [get_selected_filters] = selected_filters_;
|
|
6056
|
+
// Possible values:
|
|
6057
|
+
// 0 - we should not clear next submit
|
|
6058
|
+
// 1 - we should clear next submit due to internal heuristics
|
|
6059
|
+
// 2 - we should clear next submit due to EXPLICIT user action (i.e. clear button pressed)
|
|
6060
|
+
const clear_filters_next_submit_ = (0, $46MJV$solidjs.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
|
|
5693
6061
|
const [get_clear_filters_next_submit, set_clear_filters_next_submit] = clear_filters_next_submit_;
|
|
5694
|
-
const clear_filters = ()=>set_clear_filters_next_submit(
|
|
6062
|
+
const clear_filters = (user_triggered)=>set_clear_filters_next_submit(user_triggered ? 2 : 1);
|
|
5695
6063
|
(0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(get_selected_filters, ()=>{
|
|
5696
6064
|
// if the selected filters update, clear the clearing signal
|
|
5697
|
-
set_clear_filters_next_submit(
|
|
6065
|
+
set_clear_filters_next_submit(0);
|
|
5698
6066
|
}, {
|
|
5699
6067
|
defer: true
|
|
5700
6068
|
}));
|
|
5701
6069
|
(0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(get_search_query, (0, $46MJV$depictaiutilishared.catchify)(()=>{
|
|
5702
6070
|
// when a query was submitted, clear filters if clear was pressed before
|
|
5703
|
-
|
|
5704
|
-
|
|
5705
|
-
|
|
5706
|
-
// also collapse expanded filters in hierarchical filter tree again
|
|
5707
|
-
expanded_hierarchical_filters_[1]([]);
|
|
5708
|
-
// also clear sorting
|
|
5709
|
-
current_sorting_[1](undefined);
|
|
6071
|
+
const clear_value = (0, $46MJV$solidjs.untrack)(get_clear_filters_next_submit);
|
|
6072
|
+
if (clear_value) {
|
|
6073
|
+
set_clear_filters_next_submit(0);
|
|
5710
6074
|
(0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
|
|
5711
|
-
user_triggered_:
|
|
6075
|
+
user_triggered_: clear_value === 2,
|
|
5712
6076
|
selected_filters_: selected_filters_,
|
|
5713
6077
|
i18n_: i18n_,
|
|
5714
6078
|
also_clear_sorting_: true,
|
|
@@ -5753,26 +6117,8 @@ function $ad118c2ba257d9b7$export$84bba84a7b837187(search_query) {
|
|
|
5753
6117
|
|
|
5754
6118
|
|
|
5755
6119
|
|
|
5756
|
-
|
|
5757
|
-
|
|
5758
|
-
*/ function $405647fc79da2849$export$26df08e242fe83a3(url_param_name, value, url_transformer) {
|
|
5759
|
-
$405647fc79da2849$var$set_param(false, url_param_name, value, url_transformer);
|
|
5760
|
-
}
|
|
5761
|
-
function $405647fc79da2849$export$7a053411c76081d8(url_param_name, value, url_transformer) {
|
|
5762
|
-
$405647fc79da2849$var$set_param(true, url_param_name, value, url_transformer);
|
|
5763
|
-
}
|
|
5764
|
-
function $405647fc79da2849$var$set_param(replace, url_param_name, value, url_transformer) {
|
|
5765
|
-
const u_o = new URL(location.href);
|
|
5766
|
-
url_transformer?.(u_o);
|
|
5767
|
-
const { searchParams: searchParams } = u_o;
|
|
5768
|
-
if (value !== undefined) searchParams.set(url_param_name, value);
|
|
5769
|
-
else searchParams.delete(url_param_name);
|
|
5770
|
-
history[replace ? "replaceState" : "pushState"](history.state, "", u_o.href);
|
|
5771
|
-
}
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , search_param_name_: search_param_name_ , search_field_value_: [read_field_value, write_field_value] , search_query_: [read_search_query] , url_transformer_: url_transformer_ , on_submit_: on_submit_ = (0, $405647fc79da2849$export$26df08e242fe83a3) , after_submit_: after_submit_ }) {
|
|
5775
|
-
const new_search_query = (0, $46MJV$solidjs.untrack)(read_field_value);
|
|
6120
|
+
async function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , search_param_name_: search_param_name_ , set_search_field_value_: set_search_field_value_ , search_query_: [read_search_query] , url_transformer_: url_transformer_ , router_: router_ , after_submit_: after_submit_ , get_new_query: get_new_query }) {
|
|
6121
|
+
const new_search_query = get_new_query();
|
|
5776
6122
|
const previous_query = (0, $46MJV$solidjs.untrack)(read_search_query);
|
|
5777
6123
|
if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
|
|
5778
6124
|
// don't push a history entry / re-search if someone submits a search again
|
|
@@ -5780,9 +6126,16 @@ function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchanged_va
|
|
|
5780
6126
|
on_submit_with_unchanged_value_?.();
|
|
5781
6127
|
return;
|
|
5782
6128
|
}
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
6129
|
+
set_search_field_value_(previous_query); // restore the value to the previous query since this one goes to the new history entry
|
|
6130
|
+
const target_url = new URL(location.href);
|
|
6131
|
+
url_transformer_?.(target_url);
|
|
6132
|
+
target_url.searchParams.set(search_param_name_, new_search_query);
|
|
6133
|
+
await router_.navigate_.go_to_({
|
|
6134
|
+
new_url_: target_url,
|
|
6135
|
+
is_replace_: false,
|
|
6136
|
+
force_spa_navigation_: true
|
|
6137
|
+
});
|
|
6138
|
+
set_search_field_value_(new_search_query);
|
|
5786
6139
|
scrollTo(0, 0);
|
|
5787
6140
|
after_submit_?.();
|
|
5788
6141
|
}
|
|
@@ -5791,6 +6144,8 @@ function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchanged_va
|
|
|
5791
6144
|
|
|
5792
6145
|
|
|
5793
6146
|
function $690220645373c65e$export$2542ffb77b620b02(params_to_default_value) {
|
|
6147
|
+
// TODO: remove this abstraction, put it in same place as filters
|
|
6148
|
+
// TODO: make it only return an accessor
|
|
5794
6149
|
const signals = {};
|
|
5795
6150
|
const entries = Object.entries(params_to_default_value);
|
|
5796
6151
|
for (const [param, default_value] of entries)signals[param] = (0, $46MJV$solidjs.createSignal)(default_value ?? "");
|
|
@@ -5830,8 +6185,8 @@ function $690220645373c65e$export$2542ffb77b620b02(params_to_default_value) {
|
|
|
5830
6185
|
|
|
5831
6186
|
|
|
5832
6187
|
|
|
5833
|
-
/**
|
|
5834
|
-
* Expand an object where every value in the top-level is an accessor into a normal object. Used for converting solid_i18n objects into external i18n typed objects.
|
|
6188
|
+
/**
|
|
6189
|
+
* Expand an object where every value in the top-level is an accessor into a normal object. Used for converting solid_i18n objects into external i18n typed objects.
|
|
5835
6190
|
*/ const $850f0c7c629012e3$export$27b710c08412a7ad = (obj)=>{
|
|
5836
6191
|
return Object.fromEntries(Object.keys(obj).map((key)=>[
|
|
5837
6192
|
key,
|
|
@@ -6030,6 +6385,7 @@ function $4cadf33fd6aaf4b6$var$track_elements(display, index, elements, tenant,
|
|
|
6030
6385
|
click_location: type + "_" + (index + 1),
|
|
6031
6386
|
recommendation_type: type
|
|
6032
6387
|
});
|
|
6388
|
+
localStorage.setItem(`depict_attribution_${d.product_id}`, d.search_result_id);
|
|
6033
6389
|
};
|
|
6034
6390
|
while(disconnectors.length)// disconnect stuff from old display
|
|
6035
6391
|
disconnectors.pop()();
|
|
@@ -6120,47 +6476,26 @@ function $6ea05d3ebaa81958$export$50b90be27d8502d9(el, [get_style_props, set_sty
|
|
|
6120
6476
|
|
|
6121
6477
|
|
|
6122
6478
|
|
|
6123
|
-
function $41151dd3f5de2c98$export$91c3b6774e8be0f5({ param_: param_ , value_: value_ , url_transformer_: url_transformer_
|
|
6124
|
-
const [
|
|
6479
|
+
function $41151dd3f5de2c98$export$91c3b6774e8be0f5({ param_: param_ , value_: value_ , url_transformer_: url_transformer_ }) {
|
|
6480
|
+
const [get_current_href, set_current_href] = (0, $46MJV$solidjs.createSignal)(location.href);
|
|
6125
6481
|
const [exit_iterable, exitable_iterable] = (0, $46MJV$depictaiutilishared.make_asyncIterable_exiter)((0, $46MJV$depictaiutilishared.href_change_ipns));
|
|
6126
6482
|
(0, $46MJV$solidjs.onCleanup)(exit_iterable);
|
|
6127
6483
|
(0, $46MJV$depictaiutilishared.catchify)(async ()=>{
|
|
6128
|
-
for await (const href of exitable_iterable)
|
|
6129
|
-
|
|
6130
|
-
const u_o = new URL(href);
|
|
6131
|
-
url_transformer_?.(u_o);
|
|
6132
|
-
u_o.searchParams.set(param_, value_);
|
|
6133
|
-
write_link(u_o.href);
|
|
6134
|
-
}
|
|
6484
|
+
for await (const href of exitable_iterable)// use native links so ppl can cmdclick/right click and open in new tab and see target URL
|
|
6485
|
+
set_current_href(href);
|
|
6135
6486
|
})();
|
|
6136
|
-
|
|
6137
|
-
|
|
6138
|
-
|
|
6139
|
-
|
|
6140
|
-
|
|
6141
|
-
|
|
6142
|
-
on_submit_with_unchanged_value_?.();
|
|
6143
|
-
return;
|
|
6144
|
-
}
|
|
6145
|
-
set_search_field_value_((0, $46MJV$solidjs.untrack)(get_search_query_)); // fill in old query in previous history entry before making new one, like we do in submit_query
|
|
6146
|
-
if (typeof alternative_query_submitter_for_spas_ === "function") alternative_query_submitter_for_spas_(param_, value_, url_transformer_);
|
|
6147
|
-
else {
|
|
6148
|
-
history.pushState(history.state, "", (0, $46MJV$solidjs.untrack)((0, $46MJV$depictaiutilishared.catchify)(()=>read_link())));
|
|
6149
|
-
scrollTo(0, 0);
|
|
6150
|
-
}
|
|
6151
|
-
set_search_field_value_(value_);
|
|
6152
|
-
after_submit_?.();
|
|
6153
|
-
};
|
|
6154
|
-
return {
|
|
6155
|
-
read_link_: read_link,
|
|
6156
|
-
on_click_handler_: on_click_handler_
|
|
6157
|
-
};
|
|
6487
|
+
return (0, $46MJV$solidjs.createMemo)(()=>{
|
|
6488
|
+
const u_o = new URL(get_current_href());
|
|
6489
|
+
url_transformer_?.(u_o);
|
|
6490
|
+
u_o.searchParams.set(param_, value_());
|
|
6491
|
+
return u_o.href;
|
|
6492
|
+
});
|
|
6158
6493
|
}
|
|
6159
6494
|
|
|
6160
6495
|
|
|
6161
6496
|
|
|
6162
6497
|
const $d9dab2a87a9fc61a$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="previous-searches"><h2 class="text"></h2><div class="list"></div></div>`, 6), $d9dab2a87a9fc61a$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="item"><div class="left"><span></span></div><button class="delete"></button></a>`, 8);
|
|
6163
|
-
function $d9dab2a87a9fc61a$export$a146ac6fa8346a25({ text_: text_ , previous_searches_: previous_searches_ , search_query_param_name_: search_query_param_name_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_unfiltered_previous_searches_: set_unfiltered_previous_searches_ ,
|
|
6498
|
+
function $d9dab2a87a9fc61a$export$a146ac6fa8346a25({ text_: text_ , previous_searches_: previous_searches_ , search_query_param_name_: search_query_param_name_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_unfiltered_previous_searches_: set_unfiltered_previous_searches_ , selected_index_: [read_selected_index_, write_selected_index_] , url_transformer_: url_transformer_ , i18n_: i18n_ , submit_query_: submit_query_ }) {
|
|
6164
6499
|
const has_entries = (0, $46MJV$solidjs.createMemo)(()=>previous_searches_().length >= 1);
|
|
6165
6500
|
currently_showing_suggestions_[1]((value)=>{
|
|
6166
6501
|
value[0] = (0, $46MJV$solidjs.createMemo)(()=>previous_searches_().map((result)=>({
|
|
@@ -6186,20 +6521,20 @@ function $d9dab2a87a9fc61a$export$a146ac6fa8346a25({ text_: text_ , previous_sea
|
|
|
6186
6521
|
return previous_searches_();
|
|
6187
6522
|
},
|
|
6188
6523
|
children: (item, index)=>{
|
|
6189
|
-
const
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
|
|
6193
|
-
|
|
6194
|
-
set_search_field_value_: search_field_value_[1],
|
|
6195
|
-
get_search_query_: get_search_query_,
|
|
6196
|
-
after_submit_: after_submit_,
|
|
6197
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
6198
|
-
}));
|
|
6524
|
+
const href = (0, $41151dd3f5de2c98$export$91c3b6774e8be0f5)({
|
|
6525
|
+
param_: search_query_param_name_,
|
|
6526
|
+
value_: item,
|
|
6527
|
+
url_transformer_: url_transformer_
|
|
6528
|
+
});
|
|
6199
6529
|
return (()=>{
|
|
6200
6530
|
const _el$4 = $d9dab2a87a9fc61a$var$_tmpl$2.cloneNode(true), _el$5 = _el$4.firstChild, _el$6 = _el$5.firstChild, _el$7 = _el$5.nextSibling;
|
|
6201
6531
|
(0, $46MJV$solidjsweb.use)((element)=>element.addEventListener(// Viskan's Oscar Jacobson site requires us to add the event listener normally here. They do too much when this element is clicked. We work around it by blocking the event and just dispatching it non-bubbling on this element.
|
|
6202
|
-
"click", (0, $46MJV$depictaiutilishared.catchify)((
|
|
6532
|
+
"click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>{
|
|
6533
|
+
if (ev.button || ev.metaKey || ev.ctrlKey) // not button 0 or cmd/ctrl click
|
|
6534
|
+
return;
|
|
6535
|
+
ev.preventDefault();
|
|
6536
|
+
submit_query_(item());
|
|
6537
|
+
})), _el$4);
|
|
6203
6538
|
(0, $46MJV$solidjsweb.addEventListener)(_el$4, "mouseleave", (0, $46MJV$depictaiutilishared.catchify)(()=>write_selected_index_(undefined)));
|
|
6204
6539
|
(0, $46MJV$solidjsweb.addEventListener)(_el$4, "mouseenter", (0, $46MJV$depictaiutilishared.catchify)(()=>write_selected_index_([
|
|
6205
6540
|
0,
|
|
@@ -6224,7 +6559,7 @@ function $d9dab2a87a9fc61a$export$a146ac6fa8346a25({ text_: text_ , previous_sea
|
|
|
6224
6559
|
})), _el$7);
|
|
6225
6560
|
(0, $46MJV$solidjsweb.insert)(_el$7, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.CrossIcon), {}));
|
|
6226
6561
|
(0, $46MJV$solidjsweb.effect)((_p$)=>{
|
|
6227
|
-
const _v$ = !!(0, $46MJV$solidjs.createMemo)(()=>read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)(), _v$2 =
|
|
6562
|
+
const _v$ = !!(0, $46MJV$solidjs.createMemo)(()=>read_selected_index_()?.[0] === 0 && read_selected_index_()?.[1] === index)(), _v$2 = href(), _v$3 = i18n_.previous_searches_delete_entry_from_history_();
|
|
6228
6563
|
_v$ !== _p$._v$ && _el$4.classList.toggle("selected", _p$._v$ = _v$);
|
|
6229
6564
|
_v$2 !== _p$._v$2 && (0, $46MJV$solidjsweb.setAttribute)(_el$4, "href", _p$._v$2 = _v$2);
|
|
6230
6565
|
_v$3 !== _p$._v$3 && (0, $46MJV$solidjsweb.setAttribute)(_el$7, "title", _p$._v$3 = _v$3);
|
|
@@ -6323,41 +6658,34 @@ function $5a0afe153acd45d7$export$ba17c5b7e6dda39f({ whole_text_to_display_: who
|
|
|
6323
6658
|
|
|
6324
6659
|
|
|
6325
6660
|
const $aabe56c678fa29ec$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="suggestion"></a>`, 2), $aabe56c678fa29ec$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="search-icon"></div>`, 2), $aabe56c678fa29ec$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="type"></span>`, 2), $aabe56c678fa29ec$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div><span class="value"></span></div>`, 4), $aabe56c678fa29ec$var$_tmpl$5 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<h2 class="text"></h2>`, 2), $aabe56c678fa29ec$var$_tmpl$6 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="suggestion-container query"></div>`, 2), $aabe56c678fa29ec$var$_tmpl$7 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="suggestion-container page"></div>`, 2), $aabe56c678fa29ec$var$_tmpl$8 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="suggestions"></div>`, 2);
|
|
6326
|
-
function $aabe56c678fa29ec$export$e872e2339fb04a7f({ suggestion_memo_: suggestion_memo_ ,
|
|
6661
|
+
function $aabe56c678fa29ec$export$e872e2339fb04a7f({ suggestion_memo_: suggestion_memo_ , search_page_url_param_name_: search_page_url_param_name_ , selected_index_: [read_selected_index_, write_selected_index_] , url_transformer_: url_transformer_ , filtered_previous_searches_: filtered_previous_searches_ , currently_showing_suggestions_: currently_showing_suggestions_ , on_previous_searches_page_: on_previous_searches_page_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , searching_for_value_: searching_for_value_ , router_: router_ , submit_query_: submit_query_ }) {
|
|
6327
6662
|
const queries_memo = (0, $46MJV$solidjs.createMemo)(()=>suggestion_memo_().filter(({ type: type , title: title })=>type === (0, $81eea900c72d569b$export$3cf9497e790da491) && !filtered_previous_searches_().includes(title) // don't show the ones we already show from the history
|
|
6328
6663
|
));
|
|
6329
6664
|
const not_queries_memo = (0, $46MJV$solidjs.createMemo)(()=>suggestion_memo_().filter(({ type: type })=>type !== (0, $81eea900c72d569b$export$3cf9497e790da491)));
|
|
6330
6665
|
const render_entry = (input_obj, autocomplete_data_index, index, is_history = false)=>{
|
|
6331
6666
|
const is_query = (0, $46MJV$solidjs.createMemo)(()=>input_obj().type === (0, $81eea900c72d569b$export$3cf9497e790da491));
|
|
6332
|
-
const
|
|
6667
|
+
const href_with_changed_params_accessor = (0, $46MJV$solidjs.createMemo)(()=>is_query() ? (0, $41151dd3f5de2c98$export$91c3b6774e8be0f5)({
|
|
6333
6668
|
param_: search_page_url_param_name_,
|
|
6334
|
-
value_: input_obj().title,
|
|
6335
|
-
url_transformer_: url_transformer_
|
|
6336
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
6337
|
-
get_search_query_: get_search_query_,
|
|
6338
|
-
set_search_field_value_: search_field_value_[1],
|
|
6339
|
-
after_submit_: after_submit_,
|
|
6340
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
6669
|
+
value_: (0, $46MJV$solidjs.createMemo)(()=>input_obj().title),
|
|
6670
|
+
url_transformer_: url_transformer_
|
|
6341
6671
|
}) : undefined);
|
|
6342
|
-
const
|
|
6343
|
-
(0, $46MJV$solidjs.createComputed)(()=>{
|
|
6344
|
-
const new_href = is_query() ? param_change_obj().read_link_() : input_obj().page_url;
|
|
6345
|
-
// href will first show up in a tick from input_obj() updating, we don't want to assign undefined in the meantime
|
|
6346
|
-
if (new_href) set_href(new_href);
|
|
6347
|
-
});
|
|
6672
|
+
const href = (0, $46MJV$solidjs.createMemo)(()=>is_query() ? href_with_changed_params_accessor()() : input_obj().page_url);
|
|
6348
6673
|
return (()=>{
|
|
6349
6674
|
const _el$ = $aabe56c678fa29ec$var$_tmpl$.cloneNode(true);
|
|
6350
6675
|
(0, $46MJV$solidjsweb.use)((element)=>element.addEventListener("click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>{
|
|
6351
6676
|
// Viskan's Oscar Jacobson site requires us to add the event listener normally here. They do too much when this element is clicked. We work around it by blocking the event and just dispatching it non-bubbling on this element.
|
|
6352
|
-
if (is_query())
|
|
6353
|
-
else if (navigate_page_to_href_) {
|
|
6354
|
-
// single page navigate to category suggestions if enabled
|
|
6355
|
-
// object should have a href where we want to go
|
|
6677
|
+
if (is_query()) {
|
|
6356
6678
|
if (ev.button || ev.metaKey || ev.ctrlKey) // not button 0 or cmd/ctrl click
|
|
6357
6679
|
return;
|
|
6358
6680
|
ev.preventDefault();
|
|
6359
|
-
|
|
6681
|
+
submit_query_(input_obj().title);
|
|
6682
|
+
return;
|
|
6360
6683
|
}
|
|
6684
|
+
router_.navigate_.go_to_({
|
|
6685
|
+
new_url_: input_obj().page_url,
|
|
6686
|
+
is_replace_: false,
|
|
6687
|
+
event_: ev
|
|
6688
|
+
});
|
|
6361
6689
|
})), _el$);
|
|
6362
6690
|
(0, $46MJV$solidjsweb.addEventListener)(_el$, "mouseleave", (0, $46MJV$depictaiutilishared.catchify)(()=>write_selected_index_(undefined)));
|
|
6363
6691
|
(0, $46MJV$solidjsweb.addEventListener)(_el$, "mouseenter", (0, $46MJV$depictaiutilishared.catchify)(()=>write_selected_index_([
|
|
@@ -6582,6 +6910,7 @@ function $bc74fbd61efdd8a5$export$217899a935ef803b({ selected_index_: [read_sele
|
|
|
6582
6910
|
}
|
|
6583
6911
|
};
|
|
6584
6912
|
// TODO: if selected item stops existing, remove it
|
|
6913
|
+
// Is above actually not done???
|
|
6585
6914
|
$bc74fbd61efdd8a5$var$actual_navigation_working_on_fake_data({
|
|
6586
6915
|
...rest_of_props,
|
|
6587
6916
|
last_suggestion_index_: last_suggestion_index_,
|
|
@@ -6589,7 +6918,7 @@ function $bc74fbd61efdd8a5$export$217899a935ef803b({ selected_index_: [read_sele
|
|
|
6589
6918
|
write_selected_fake_index_: write_selected_fake_index_
|
|
6590
6919
|
});
|
|
6591
6920
|
}
|
|
6592
|
-
function $bc74fbd61efdd8a5$var$actual_navigation_working_on_fake_data({ element_: element_ , search_field_value_: [get_search_field_value, set_search_field_value] , updating_blocked_: [read_updating_blocked, write_updating_blocked] , last_suggestion_index_: last_suggestion_index_ , read_selected_fake_index_: read_selected_fake_index_ , write_selected_fake_index_: write_selected_fake_index_ , set_override_on_enter_fn_: set_override_on_enter_fn_ ,
|
|
6921
|
+
function $bc74fbd61efdd8a5$var$actual_navigation_working_on_fake_data({ element_: element_ , search_field_value_: [get_search_field_value, set_search_field_value] , updating_blocked_: [read_updating_blocked, write_updating_blocked] , last_suggestion_index_: last_suggestion_index_ , read_selected_fake_index_: read_selected_fake_index_ , write_selected_fake_index_: write_selected_fake_index_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , url_transformer_: url_transformer_ , search_query_param_name_: search_query_param_name_ , router_: router_ }) {
|
|
6593
6922
|
let previous_value;
|
|
6594
6923
|
(0, $46MJV$solidjs.createEffect)(()=>{
|
|
6595
6924
|
const sfv = get_search_field_value();
|
|
@@ -6627,6 +6956,7 @@ function $bc74fbd61efdd8a5$var$actual_navigation_working_on_fake_data({ element_
|
|
|
6627
6956
|
set_search_field_value(title);
|
|
6628
6957
|
override_on_enter_for_this_entry((e)=>{
|
|
6629
6958
|
// Open search query in new tab on cmd+enter
|
|
6959
|
+
// If it's not cmd+enter, pressing enter will just submit the value that was put into the field while selecting with the arrow keys ;)
|
|
6630
6960
|
const url = new URL(location);
|
|
6631
6961
|
url_transformer_?.(url);
|
|
6632
6962
|
url.searchParams.set(search_query_param_name_, title);
|
|
@@ -6634,11 +6964,11 @@ function $bc74fbd61efdd8a5$var$actual_navigation_working_on_fake_data({ element_
|
|
|
6634
6964
|
});
|
|
6635
6965
|
} else if (selected_entry?.type == "category") override_on_enter_for_this_entry((e)=>{
|
|
6636
6966
|
const { page_url: page_url } = selected_entry;
|
|
6637
|
-
if (!$bc74fbd61efdd8a5$var$open_link_on_cmd_pressed(e, page_url))
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
}
|
|
6967
|
+
if (!$bc74fbd61efdd8a5$var$open_link_on_cmd_pressed(e, page_url)) // Above fn will return true if it opened a new tab, and we won't make these checks anymore
|
|
6968
|
+
router_.navigate_.go_to_({
|
|
6969
|
+
new_url_: page_url,
|
|
6970
|
+
is_replace_: false
|
|
6971
|
+
});
|
|
6642
6972
|
return true;
|
|
6643
6973
|
});
|
|
6644
6974
|
else if (!selected_entry) {
|
|
@@ -6671,7 +7001,7 @@ function $bc74fbd61efdd8a5$var$open_link_on_cmd_pressed(e, href) {
|
|
|
6671
7001
|
|
|
6672
7002
|
|
|
6673
7003
|
const $81eea900c72d569b$export$3cf9497e790da491 = "query";
|
|
6674
|
-
function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search_field_value_ , search_query_: [get_search_query_] , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: unfiltered_previous_searches , previous_searches_text_: previous_searches_text_ , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , input_field_: input_field_ , url_transformer_: url_transformer_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , selected_index_: selected_index_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ ,
|
|
7004
|
+
function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search_field_value_ , search_query_: [get_search_query_] , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: unfiltered_previous_searches , previous_searches_text_: previous_searches_text_ , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , input_field_: input_field_ , url_transformer_: url_transformer_ , currently_showing_suggestions_: currently_showing_suggestions_ , set_override_on_enter_fn_: set_override_on_enter_fn_ , selected_index_: selected_index_ , i18n_: i18n_ , include_category_suggestions_: include_category_suggestions_ , submit_query_: submit_query_ , router_: router_ }) {
|
|
6675
7005
|
const [searching_for_value, set_searching_for_value] = (0, $46MJV$solidjs.createSignal)();
|
|
6676
7006
|
const [read_search_field_value] = search_field_value_;
|
|
6677
7007
|
const updating_blocked = (0, $46MJV$solidjs.createSignal)(false);
|
|
@@ -6714,7 +7044,7 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
|
|
|
6714
7044
|
set_override_on_enter_fn_: set_override_on_enter_fn_,
|
|
6715
7045
|
search_query_param_name_: search_page_url_param_name_,
|
|
6716
7046
|
url_transformer_: url_transformer_,
|
|
6717
|
-
|
|
7047
|
+
router_: router_
|
|
6718
7048
|
});
|
|
6719
7049
|
return [
|
|
6720
7050
|
(0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
@@ -6732,14 +7062,10 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
|
|
|
6732
7062
|
get previous_searches_ () {
|
|
6733
7063
|
return (0, $46MJV$solidjs.createMemo)(()=>filtered_previous_searches().slice(0, 5));
|
|
6734
7064
|
},
|
|
6735
|
-
search_field_value_: search_field_value_,
|
|
6736
7065
|
selected_index_: selected_index_,
|
|
6737
7066
|
currently_showing_suggestions_: currently_showing_suggestions_,
|
|
6738
7067
|
url_transformer_: url_transformer_,
|
|
6739
|
-
|
|
6740
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
6741
|
-
after_submit_: after_submit_,
|
|
6742
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
7068
|
+
submit_query_: submit_query_
|
|
6743
7069
|
});
|
|
6744
7070
|
}
|
|
6745
7071
|
}),
|
|
@@ -6757,18 +7083,14 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
|
|
|
6757
7083
|
on_previous_searches_page_: show_previous_searches_component,
|
|
6758
7084
|
i18n_: i18n_,
|
|
6759
7085
|
url_transformer_: url_transformer_,
|
|
6760
|
-
search_field_value_: search_field_value_,
|
|
6761
7086
|
searching_for_value_: searching_for_value,
|
|
6762
7087
|
search_page_url_param_name_: search_page_url_param_name_,
|
|
6763
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
6764
7088
|
selected_index_: selected_index_,
|
|
6765
7089
|
suggestion_memo_: read_suggestion_signal,
|
|
6766
7090
|
currently_showing_suggestions_: currently_showing_suggestions_,
|
|
6767
|
-
get_search_query_: get_search_query_,
|
|
6768
7091
|
include_category_suggestions_: include_category_suggestions_,
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
7092
|
+
router_: router_,
|
|
7093
|
+
submit_query_: submit_query_
|
|
6772
7094
|
})
|
|
6773
7095
|
];
|
|
6774
7096
|
}
|
|
@@ -6854,7 +7176,7 @@ function $4a976b492943589f$export$f021bdedd3ec901a(props) {
|
|
|
6854
7176
|
|
|
6855
7177
|
|
|
6856
7178
|
const $121d25ca6af2898f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="discover-more"><button class="major" type="button"></button></div>`, 4), $121d25ca6af2898f$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<b></b>`, 2), $121d25ca6af2898f$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict-search-modal"><div class="body"><div class="padded"></div></div></div>`, 6), $121d25ca6af2898f$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp search"><div class="depict-search-modal-backdrop"></div></div>`, 4);
|
|
6857
|
-
function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_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, $46MJV$solidjs.createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: props_submit_query , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ ,
|
|
7179
|
+
function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_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, $46MJV$solidjs.createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: props_submit_query , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , selected_text_range_: selected_text_range_ , dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_ = false , router_: router_ }) {
|
|
6858
7180
|
let on_enter_in_search_field_function;
|
|
6859
7181
|
// As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
|
|
6860
7182
|
// This is desired for when the modal is opened from a UI element that visually does not look connected with the search page or current query
|
|
@@ -6868,12 +7190,6 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
|
|
|
6868
7190
|
propagate_search_field_value_back?.();
|
|
6869
7191
|
return props_submit_query(...args);
|
|
6870
7192
|
};
|
|
6871
|
-
const after_submit_ = props_after_submit && ((...args)=>{
|
|
6872
|
-
// This will be called by link_to_param_change when clicking on a suggestion
|
|
6873
|
-
// the logic in link_to_param_change doesn't need to read the search field value before submitting, so we can just propagate the changes after submitting
|
|
6874
|
-
propagate_search_field_value_back?.();
|
|
6875
|
-
return props_after_submit(...args);
|
|
6876
|
-
});
|
|
6877
7193
|
const [input_field, set_input_field] = (0, $46MJV$solidjs.createSignal)();
|
|
6878
7194
|
const [get_search_field_value_] = search_field_value_;
|
|
6879
7195
|
const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $46MJV$solidjs.createSignal)();
|
|
@@ -6896,7 +7212,7 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
|
|
|
6896
7212
|
(matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
|
|
6897
7213
|
(matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((()=>{
|
|
6898
7214
|
const _el$ = $121d25ca6af2898f$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
|
|
6899
|
-
_el$2
|
|
7215
|
+
(0, $46MJV$solidjsweb.addEventListener)(_el$2, "click", (0, $46MJV$depictaiutilishared.catchify)(()=>submit_query_()), true);
|
|
6900
7216
|
(0, $46MJV$solidjsweb.insert)(_el$2, (()=>{
|
|
6901
7217
|
const _c$ = (0, $46MJV$solidjsweb.memo)(()=>!!get_search_field_value_());
|
|
6902
7218
|
return ()=>_c$() ? i18n_.modal_view_all_results_()((()=>{
|
|
@@ -6970,13 +7286,11 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
|
|
|
6970
7286
|
selected_index_: selected_index,
|
|
6971
7287
|
currently_showing_suggestions_: currently_showing_suggestions_,
|
|
6972
7288
|
depict_api_: depict_api_,
|
|
6973
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
6974
7289
|
url_transformer_: url_transformer_,
|
|
6975
7290
|
i18n_: i18n_,
|
|
6976
7291
|
include_category_suggestions_: enable_category_suggestions_ ?? true,
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
7292
|
+
router_: router_,
|
|
7293
|
+
submit_query_: submit_query_
|
|
6980
7294
|
});
|
|
6981
7295
|
}
|
|
6982
7296
|
}), null);
|
|
@@ -7068,7 +7382,7 @@ function $121d25ca6af2898f$var$close_modal_when_navigating_away(close_modal, sea
|
|
|
7068
7382
|
|
|
7069
7383
|
|
|
7070
7384
|
const $ea038dec4ee16624$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="category-suggestions"></div>`, 2), $ea038dec4ee16624$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="category-suggestion"></div>`, 2);
|
|
7071
|
-
function $ea038dec4ee16624$export$c05a196222ba1302({ suggestions_: suggestions_ , children: children ,
|
|
7385
|
+
function $ea038dec4ee16624$export$c05a196222ba1302({ suggestions_: suggestions_ , children: children , slider_arrow_button_: slider_arrow_button_ }) {
|
|
7072
7386
|
const category_suggestions_ = (0, $46MJV$solidjs.createMemo)(()=>suggestions_()?.suggestions.filter((s)=>s.type === "category"));
|
|
7073
7387
|
return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
7074
7388
|
get when () {
|
|
@@ -7099,7 +7413,7 @@ function $ea038dec4ee16624$export$c05a196222ba1302({ suggestions_: suggestions_
|
|
|
7099
7413
|
get each () {
|
|
7100
7414
|
return category_suggestions_();
|
|
7101
7415
|
},
|
|
7102
|
-
children: (suggestion, index)=>children(suggestion, index
|
|
7416
|
+
children: (suggestion, index)=>children(suggestion, index)
|
|
7103
7417
|
});
|
|
7104
7418
|
}
|
|
7105
7419
|
});
|
|
@@ -7151,13 +7465,12 @@ function $297ca03cb5dd5701$export$9dd50d35b9d94fdf({ search_query_: search_query
|
|
|
7151
7465
|
|
|
7152
7466
|
const $93779a41dce11249$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="filter-results-for-one-row"></div>`, 2), $93779a41dce11249$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp search"><div class="listing-page"></div></div>`, 4);
|
|
7153
7467
|
function $93779a41dce11249$export$a54ec244c8863715(opts) {
|
|
7154
|
-
const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , search_query_: search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , rr_options_: rr_options_ , recommendations_rr_options_: recommendations_rr_options_ = rr_options_ , search_recs_view_more_: search_recs_view_more_ , get_product_id_: get_product_id_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_
|
|
7468
|
+
const { depict_api_: depict_api_ , search_field_value_: search_field_value_ , search_query_: search_query_ , open_modal_: open_modal_ , submit_query_: submit_query_ , current_sorting_: current_sorting_ , min_products_to_fetch_: min_products_to_fetch_ , search_filters_open_: search_filters_open_ , search_sorting_open_: search_sorting_open_ , expanded_filters_: expanded_filters_ , input_modal_open_: input_modal_open_ , selected_filters_: selected_filters_ , i18n_: i18n_ , slider_arrow_button_: slider_arrow_button_ , make_category_suggestion_card_: make_category_suggestion_card_ , expanded_hierarchical_filters_: expanded_hierarchical_filters_ , clear_filters_on_next_submit_: clear_filters_on_next_submit_ , local_filter_cache_: local_filter_cache_ , include_input_field_: include_input_field_ , tenant_: tenant_ , market_: market_ , showing_recommendation_rows_: showing_recommendation_rows_ , rr_options_: rr_options_ , recommendations_rr_options_: recommendations_rr_options_ = rr_options_ , search_recs_view_more_: search_recs_view_more_ , get_product_id_: get_product_id_ , disable_search_recommendations_: disable_search_recommendations_ , layout_options_: layout_options_ , recommendations_layout_options_: recommendations_layout_options_ = layout_options_ , scroll_restoration_data_: scroll_restoration_data_ } = opts;
|
|
7155
7469
|
const tenant_object_ = new (0, $46MJV$depictaiutilishared.Tenant)({
|
|
7156
7470
|
TENANT: (0, $46MJV$solidjs.untrack)(tenant_),
|
|
7157
7471
|
MARKET: (0, $46MJV$solidjs.untrack)(market_),
|
|
7158
7472
|
GA_ID: "",
|
|
7159
|
-
get_product_id: get_product_id_
|
|
7160
|
-
pageview_tracking: !disable_default_tracking_
|
|
7473
|
+
get_product_id: get_product_id_
|
|
7161
7474
|
});
|
|
7162
7475
|
const [get_sorting] = current_sorting_;
|
|
7163
7476
|
const [get_search_query] = search_query_;
|
|
@@ -7325,7 +7638,6 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
|
|
|
7325
7638
|
message_: "Category suggestions failed",
|
|
7326
7639
|
get children () {
|
|
7327
7640
|
return (0, $46MJV$solidjsweb.createComponent)((0, $ea038dec4ee16624$export$c05a196222ba1302), {
|
|
7328
|
-
selected_filters_: selected_filters_,
|
|
7329
7641
|
suggestions_: suggestions,
|
|
7330
7642
|
slider_arrow_button_: slider_arrow_button_,
|
|
7331
7643
|
children: make_category_suggestion_card_
|
|
@@ -7382,8 +7694,7 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
|
|
|
7382
7694
|
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
7383
7695
|
local_filter_cache_: local_filter_cache_,
|
|
7384
7696
|
i18n_: i18n_
|
|
7385
|
-
}
|
|
7386
|
-
disable_default_tracking_: disable_default_tracking_
|
|
7697
|
+
}
|
|
7387
7698
|
});
|
|
7388
7699
|
}
|
|
7389
7700
|
}), null);
|
|
@@ -7405,8 +7716,7 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
|
|
|
7405
7716
|
showing_recommendation_rows_: showing_recommendation_rows_,
|
|
7406
7717
|
rr_options_: recommendations_rr_options_,
|
|
7407
7718
|
view_more_button_: search_recs_view_more_,
|
|
7408
|
-
tenant_object_: tenant_object_
|
|
7409
|
-
disable_default_tracking_: disable_default_tracking_
|
|
7719
|
+
tenant_object_: tenant_object_
|
|
7410
7720
|
});
|
|
7411
7721
|
}
|
|
7412
7722
|
});
|
|
@@ -7476,9 +7786,11 @@ function $246e3e89a097f014$export$828dcdd425fd3231(aligner) {
|
|
|
7476
7786
|
}
|
|
7477
7787
|
|
|
7478
7788
|
|
|
7789
|
+
|
|
7790
|
+
|
|
7479
7791
|
const $79fbf145b15af988$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp search"></div>`, 2);
|
|
7480
|
-
/**
|
|
7481
|
-
* 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.
|
|
7792
|
+
/**
|
|
7793
|
+
* 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.
|
|
7482
7794
|
*/ const $79fbf145b15af988$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
7483
7795
|
const $79fbf145b15af988$var$min_products_to_fetch_ = 20;
|
|
7484
7796
|
const $79fbf145b15af988$export$bde3eb976dfded9 = (depict_search)=>$79fbf145b15af988$var$privately_shared_properties.get(depict_search)?.search_query_updating_blocked_;
|
|
@@ -7488,36 +7800,18 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7488
7800
|
#market_signal = (0, $46MJV$solidjs.createSignal)();
|
|
7489
7801
|
#modal_open_signal = (0, $46MJV$solidjs.createSignal)(false);
|
|
7490
7802
|
static #has_been_constructed = false;
|
|
7491
|
-
|
|
7803
|
+
#router = new (0, $43940d5ca403c293$export$7e1297a3a19f10d8)("hard_navigation");
|
|
7804
|
+
constructor({ search_query_url_param_name: search_query_url_param_name = "query" , url_transformer: url_transformer , on_navigation: 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
|
|
7492
7805
|
disable_scrolling_during_modal = true , api: api , bottom_distance_under_modal_: bottom_distance_under_modal_ , render_instant_card: render_instant_card , ...props_on_class }){
|
|
7493
7806
|
if ($79fbf145b15af988$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
|
|
7494
7807
|
Object.assign(this, props_on_class);
|
|
7495
|
-
const
|
|
7496
|
-
const u_o = new URL(absolute_href);
|
|
7497
|
-
const relative_href = u_o.pathname + u_o.search + u_o.hash;
|
|
7498
|
-
// make sure that we don't accidentally catchify if the SDK consumer has fucked up
|
|
7499
|
-
try {
|
|
7500
|
-
return raw_on_navigation(relative_href);
|
|
7501
|
-
} catch (e) {
|
|
7502
|
-
queueMicrotask(()=>{
|
|
7503
|
-
throw e;
|
|
7504
|
-
});
|
|
7505
|
-
}
|
|
7506
|
-
});
|
|
7507
|
-
const alternative_query_submitter_for_spas_ = on_navigation && ((search_param_name, new_search_query, url_transformer)=>{
|
|
7508
|
-
const target_url = new URL(location.href);
|
|
7509
|
-
url_transformer?.(target_url);
|
|
7510
|
-
target_url.searchParams.set(search_param_name, new_search_query);
|
|
7511
|
-
on_navigation(target_url.href);
|
|
7512
|
-
});
|
|
7808
|
+
const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ } = (0, $004640621ca953d0$export$7bcff1eb3eca57d7)(this.#router);
|
|
7513
7809
|
const [reset_history_state_, state_] = (0, $0de081f67b6d15b5$export$9862539c89138352)(()=>({
|
|
7514
7810
|
search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
|
|
7515
|
-
search_sorting: undefined,
|
|
7516
7811
|
search_filters_open: false,
|
|
7517
7812
|
search_sorting_open: false,
|
|
7518
7813
|
search_expanded_filters: [],
|
|
7519
|
-
//
|
|
7520
|
-
search_selected_filters: [],
|
|
7814
|
+
// Please make sure that the signal created by below line always updates AFTER selected_filters_ updates on a "popstate" event. If the filter cache is popped before the selected filters are the code in create_modified_filters() 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
|
|
7521
7815
|
search_local_filter_cache: [],
|
|
7522
7816
|
search_expanded_hierarchical_filters: [],
|
|
7523
7817
|
search_showing_recommendation_rows: (0, $9f81b7ced87aabf2$export$1c8c715550dc689d),
|
|
@@ -7533,24 +7827,27 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7533
7827
|
const [, set_search_showing_recommendation_rows] = state_.search_showing_recommendation_rows;
|
|
7534
7828
|
const after_submit_ = ()=>set_search_showing_recommendation_rows((0, $9f81b7ced87aabf2$export$1c8c715550dc689d)); // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
|
|
7535
7829
|
const on_submit_with_unchanged_value_ = ()=>this.modal_open = false;
|
|
7536
|
-
const
|
|
7830
|
+
const [get_search_field_value_, set_search_field_value_] = state_.search_field_value;
|
|
7831
|
+
const configured_submit_query_ = (new_query)=>(0, $1c323edfb89c9dca$export$e16630ecb9644a1c)({
|
|
7537
7832
|
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
|
|
7538
|
-
|
|
7833
|
+
set_search_field_value_: set_search_field_value_,
|
|
7539
7834
|
search_query_: search_query_signal_,
|
|
7540
7835
|
search_param_name_: search_query_url_param_name,
|
|
7541
7836
|
url_transformer_: url_transformer,
|
|
7542
|
-
|
|
7543
|
-
|
|
7837
|
+
after_submit_: after_submit_,
|
|
7838
|
+
get_new_query: ()=>new_query || (0, $46MJV$solidjs.untrack)(get_search_field_value_),
|
|
7839
|
+
router_: this.#router
|
|
7544
7840
|
});
|
|
7545
7841
|
const i18n_ = (0, $623202ae203e9e59$export$f091cbac892643a4)(this.#locale_signal[0]);
|
|
7546
7842
|
const clear_filters_on_next_submit_ = (0, $8b282f736ce4f3b8$export$e026af0c7b64ea5f)({
|
|
7547
|
-
selected_filters_:
|
|
7843
|
+
selected_filters_: selected_filters_,
|
|
7548
7844
|
search_query_: search_query_signal_,
|
|
7549
|
-
current_sorting_:
|
|
7845
|
+
current_sorting_: current_sorting_,
|
|
7550
7846
|
expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
|
|
7551
7847
|
i18n_: i18n_,
|
|
7552
7848
|
local_filter_cache_: state_.search_local_filter_cache
|
|
7553
7849
|
});
|
|
7850
|
+
if (on_navigation) this.#router.on_navigation_ = on_navigation;
|
|
7554
7851
|
(0, $46MJV$solidjs.createComputed)(()=>{
|
|
7555
7852
|
const [get_search_query_updating_blocked] = search_query_updating_blocked_;
|
|
7556
7853
|
const [get_raw_search_query_signal] = raw_search_query_signal;
|
|
@@ -7561,7 +7858,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7561
7858
|
search_query_url_param_name_: search_query_url_param_name,
|
|
7562
7859
|
reset_history_state_: reset_history_state_,
|
|
7563
7860
|
state_: state_,
|
|
7564
|
-
|
|
7861
|
+
router_: this.#router,
|
|
7565
7862
|
url_transformer_: url_transformer,
|
|
7566
7863
|
depict_api_: depict_api_,
|
|
7567
7864
|
enable_category_suggestions_: enable_category_suggestions,
|
|
@@ -7569,16 +7866,17 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7569
7866
|
configured_submit_query_: configured_submit_query_,
|
|
7570
7867
|
search_query_signal_: search_query_signal_,
|
|
7571
7868
|
i18n_: i18n_,
|
|
7572
|
-
search_query_updating_blocked_: search_query_updating_blocked_
|
|
7869
|
+
search_query_updating_blocked_: search_query_updating_blocked_,
|
|
7870
|
+
current_sorting_: current_sorting_,
|
|
7871
|
+
selected_filters_: selected_filters_
|
|
7573
7872
|
});
|
|
7574
7873
|
(0, $33815c5a406b6cc0$export$5162a71f252e6122)();
|
|
7575
7874
|
(0, $46MJV$depictaiutilishared.catchify)(async ()=>{
|
|
7576
|
-
const owner = (0, $46MJV$solidjs.getOwner)(); // we might have an owner, if so, pass it on
|
|
7875
|
+
const owner = (0, $46MJV$solidjs.getOwner)() || (0, $46MJV$solidjs.createRoot)(()=>(0, $46MJV$solidjs.getOwner)()); // we might have an owner, if so, pass it on. Otherwise, create one so solid doesn't print warnings to the console
|
|
7577
7876
|
const { open_modal_: open_modal_ , close_modal_: close_modal_ } = await (0, $089c01924e13fae5$export$79b1565500412d9b)((...args)=>{
|
|
7578
7877
|
(0, $46MJV$solidjs.onCleanup)(()=>this.modal_open = false);
|
|
7579
7878
|
return (0, $121d25ca6af2898f$export$1c593cbd6f1e10bc)(...args);
|
|
7580
7879
|
}, {
|
|
7581
|
-
after_submit_: after_submit_,
|
|
7582
7880
|
search_field_value_: state_.search_field_value,
|
|
7583
7881
|
search_query_: search_query_signal_,
|
|
7584
7882
|
search_page_url_param_name_: search_query_url_param_name,
|
|
@@ -7588,15 +7886,13 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7588
7886
|
clear_filters_: clear_filters_on_next_submit_,
|
|
7589
7887
|
market_: this.#market_signal[0],
|
|
7590
7888
|
submit_query_: configured_submit_query_,
|
|
7591
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
7592
7889
|
url_transformer_: url_transformer,
|
|
7593
|
-
|
|
7594
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
|
|
7890
|
+
router_: this.#router,
|
|
7595
7891
|
instant_results_options_: {
|
|
7596
7892
|
min_products_to_fetch_: $79fbf145b15af988$var$min_products_to_fetch_,
|
|
7597
7893
|
render_instant_card_: render_instant_card,
|
|
7598
7894
|
render_instant_card_placeholder_: (0, $17c49340edfdbb31$export$ee1733d9a8495996),
|
|
7599
|
-
has_sort_or_filters_: (0, $46MJV$solidjs.createMemo)(()=>!!(Object.keys(
|
|
7895
|
+
has_sort_or_filters_: (0, $46MJV$solidjs.createMemo)(()=>!!(Object.keys(selected_filters_[0]())?.length || current_sorting_[0]()))
|
|
7600
7896
|
},
|
|
7601
7897
|
i18n_: i18n_,
|
|
7602
7898
|
enable_category_suggestions_: enable_category_suggestions,
|
|
@@ -7605,7 +7901,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7605
7901
|
});
|
|
7606
7902
|
// This will add some default behaviour to open_modal_ if no style_props_ are supplied
|
|
7607
7903
|
// The default behaviour is to align the modal with the input field if possible
|
|
7608
|
-
const
|
|
7904
|
+
const modal_opening_effect = ()=>{
|
|
7609
7905
|
const open_signal_value = this.modal_open;
|
|
7610
7906
|
const signal_value_is_options = Array.isArray(open_signal_value);
|
|
7611
7907
|
// Close modal if signal is false
|
|
@@ -7659,11 +7955,17 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7659
7955
|
style_props_: style_props_
|
|
7660
7956
|
});
|
|
7661
7957
|
};
|
|
7662
|
-
|
|
7663
|
-
else (0, $46MJV$solidjs.createComputed)(computation);
|
|
7958
|
+
(0, $46MJV$solidjs.runWithOwner)(owner, ()=>(0, $46MJV$solidjs.createEffect)(modal_opening_effect));
|
|
7664
7959
|
})();
|
|
7665
7960
|
$79fbf145b15af988$export$ac6237957a15b3f0.#has_been_constructed = true;
|
|
7666
7961
|
}
|
|
7962
|
+
get on_navigation() {
|
|
7963
|
+
// The only non-reactive public property on the class (I don't see it making sense to have it reactive)
|
|
7964
|
+
return this.#router.on_navigation_;
|
|
7965
|
+
}
|
|
7966
|
+
set on_navigation(new_function) {
|
|
7967
|
+
this.#router.on_navigation_ = new_function;
|
|
7968
|
+
}
|
|
7667
7969
|
get localization() {
|
|
7668
7970
|
// allow reactive access
|
|
7669
7971
|
return this.#locale_signal[0]();
|
|
@@ -7706,7 +8008,7 @@ function $79fbf145b15af988$var$get_shared_properties(depict_search) {
|
|
|
7706
8008
|
if (!shared_properties) throw new Error("Can't connect to provided DepictSearch instance");
|
|
7707
8009
|
return shared_properties;
|
|
7708
8010
|
}
|
|
7709
|
-
function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , get_product_id: get_product_id = (0, $46MJV$depictaiutilishared.normal_get_product_id) , extra_depict_options: extra_depict_options
|
|
8011
|
+
function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_search , include_input_field: include_input_field , grid_spacing: grid_spacing , cols_at_size: cols_at_size , product_card_template: product_card_template , get_product_id: get_product_id = (0, $46MJV$depictaiutilishared.normal_get_product_id) , extra_depict_options: extra_depict_options }) {
|
|
7710
8012
|
const shared_properties = $79fbf145b15af988$var$get_shared_properties(depict_search);
|
|
7711
8013
|
const grid_spacing_override = typeof grid_spacing === "string" ? {
|
|
7712
8014
|
grid_spacing: grid_spacing
|
|
@@ -7746,18 +8048,18 @@ function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
7746
8048
|
});
|
|
7747
8049
|
});
|
|
7748
8050
|
},
|
|
7749
|
-
current_sorting_:
|
|
8051
|
+
current_sorting_: shared_properties.current_sorting_,
|
|
7750
8052
|
search_filters_open_: state_.search_filters_open,
|
|
7751
8053
|
search_sorting_open_: state_.search_sorting_open,
|
|
7752
8054
|
expanded_filters_: state_.search_expanded_filters,
|
|
7753
8055
|
make_category_suggestion_card_: shared_properties.enable_category_suggestions_ ? (category_suggestion_)=>{
|
|
7754
8056
|
return (0, $67892c03cd3dfa66$export$d757d54550ebfb3d)({
|
|
7755
8057
|
category_suggestion_: category_suggestion_,
|
|
7756
|
-
|
|
8058
|
+
router_: shared_properties.router_
|
|
7757
8059
|
});
|
|
7758
8060
|
} : false,
|
|
7759
8061
|
expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
|
|
7760
|
-
selected_filters_:
|
|
8062
|
+
selected_filters_: shared_properties.selected_filters_,
|
|
7761
8063
|
showing_recommendation_rows_: state_.search_showing_recommendation_rows,
|
|
7762
8064
|
scroll_restoration_data_: state_.search_scroll_restoration_data,
|
|
7763
8065
|
include_input_field_: include_input_field,
|
|
@@ -7781,8 +8083,7 @@ function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
7781
8083
|
pre_processors: extra_depict_options?.pre_processors,
|
|
7782
8084
|
post_processors: extra_depict_options?.post_processors
|
|
7783
8085
|
},
|
|
7784
|
-
get_product_id_: get_product_id
|
|
7785
|
-
disable_default_tracking_: disable_default_tracking
|
|
8086
|
+
get_product_id_: get_product_id
|
|
7786
8087
|
});
|
|
7787
8088
|
}, "Entire SearchPage failed");
|
|
7788
8089
|
}
|
|
@@ -7896,8 +8197,8 @@ const $9c5a1d57540c06e5$export$d86a33413558014e = (openModalParams)=>{
|
|
|
7896
8197
|
}
|
|
7897
8198
|
const { cleanup: cleanup } = (0, $246e3e89a097f014$export$828dcdd425fd3231)(openModalParams.element);
|
|
7898
8199
|
let dispose_aligner;
|
|
7899
|
-
/**
|
|
7900
|
-
* Setting position to fixed is important to make the modal work with align_field.
|
|
8200
|
+
/**
|
|
8201
|
+
* Setting position to fixed is important to make the modal work with align_field.
|
|
7901
8202
|
*/ const style_props_ = (0, $46MJV$solidjs.createSignal)({
|
|
7902
8203
|
position: "fixed"
|
|
7903
8204
|
});
|
|
@@ -7941,7 +8242,6 @@ function $308e64f91bb9f839$export$d0596b5cae35ad4(open_search) {
|
|
|
7941
8242
|
|
|
7942
8243
|
|
|
7943
8244
|
|
|
7944
|
-
|
|
7945
8245
|
function $d589470b68ce5b67$export$689e204eadb33baf(pr) {
|
|
7946
8246
|
let old_url;
|
|
7947
8247
|
let disconnect_link_observer;
|
|
@@ -7994,8 +8294,8 @@ class $37e96a5ebc768cc7$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
7994
8294
|
})();
|
|
7995
8295
|
return new Set();
|
|
7996
8296
|
})();
|
|
7997
|
-
/**
|
|
7998
|
-
* Returns if the "replacement page" is currently open
|
|
8297
|
+
/**
|
|
8298
|
+
* Returns if the "replacement page" is currently open
|
|
7999
8299
|
*/ get open_() {
|
|
8000
8300
|
// make this "readonly" from the outside, the only way to open is by making the url change so that is_page_ returns true
|
|
8001
8301
|
return this.#is_open;
|
|
@@ -8076,39 +8376,40 @@ class $37e96a5ebc768cc7$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8076
8376
|
}, "failed to open page");
|
|
8077
8377
|
#empty_page_bugfix() {
|
|
8078
8378
|
// Called when a "page" is "opened" using PageReplacer
|
|
8079
|
-
const
|
|
8379
|
+
const on_maybe_popstate = (what_happened)=>{
|
|
8380
|
+
if (what_happened !== "popstate") return;
|
|
8080
8381
|
const cleaned_current_url = $37e96a5ebc768cc7$var$clean_url(location.href);
|
|
8081
8382
|
if (!$37e96a5ebc768cc7$export$3ccaa27d81dd8556.#visited_urls.has(cleaned_current_url)) {
|
|
8082
|
-
/*
|
|
8083
|
-
What does this check do? Well, there's a bug without it where people end up on a page that they shouldn't see (i.e. a somewhat blank page).
|
|
8084
|
-
The culprit of that bug is: the browser remembers where to make "hard"-navigations (i.e. a full document rebuild with a new `document` and `window` object) when going back and forwards in the history and where to just change the url. What it doesn't always correctly remember (observed in at least chrome and firefox), is *what document to hard-navigate to*. Therefore, we have to jump in and take care of that.
|
|
8085
|
-
The reproduction is this:
|
|
8086
|
-
Spendrups has set up a search page for us under /start/search. We don't want to hard-reload the page though to get there.
|
|
8087
|
-
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8088
|
-
2. Make a search
|
|
8089
|
-
We use PageReplacer to just replace the current page (and the url in the address bar) with the search page. The thing is though, that when going back now the URL just updates but the browser doesn't actually navigate - that's fine, PageReplacer will just restore the old page contents
|
|
8090
|
-
3. Try going back just for fun
|
|
8091
|
-
Everything works as expected
|
|
8092
|
-
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8093
|
-
Now the trouble comes when we introduce "hard" navigation.
|
|
8094
|
-
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8095
|
-
6. Click "back"
|
|
8096
|
-
What happens now, is that the browser hard-navigates to /start/search.
|
|
8097
|
-
7. Click "back" again
|
|
8098
|
-
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8099
|
-
PageReplacer unload itself and reveals the original document - it is expected to be the one under https://ehandel.spendrups.se/Product/1104201, but actually it is the one under /start/search - a white page.
|
|
8100
|
-
|
|
8101
|
-
|
|
8383
|
+
/*
|
|
8384
|
+
What does this check do? Well, there's a bug without it where people end up on a page that they shouldn't see (i.e. a somewhat blank page).
|
|
8385
|
+
The culprit of that bug is: the browser remembers where to make "hard"-navigations (i.e. a full document rebuild with a new `document` and `window` object) when going back and forwards in the history and where to just change the url. What it doesn't always correctly remember (observed in at least chrome and firefox), is *what document to hard-navigate to*. Therefore, we have to jump in and take care of that.
|
|
8386
|
+
The reproduction is this:
|
|
8387
|
+
Spendrups has set up a search page for us under /start/search. We don't want to hard-reload the page though to get there.
|
|
8388
|
+
1. Go to a product page like https://ehandel.spendrups.se/Product/1104201
|
|
8389
|
+
2. Make a search
|
|
8390
|
+
We use PageReplacer to just replace the current page (and the url in the address bar) with the search page. The thing is though, that when going back now the URL just updates but the browser doesn't actually navigate - that's fine, PageReplacer will just restore the old page contents
|
|
8391
|
+
3. Try going back just for fun
|
|
8392
|
+
Everything works as expected
|
|
8393
|
+
4. Go forwards again (just for fun, skip this if you skipped 3)
|
|
8394
|
+
Now the trouble comes when we introduce "hard" navigation.
|
|
8395
|
+
5. Click on a search result. The browser will now "hard" navigate to a new page.
|
|
8396
|
+
6. Click "back"
|
|
8397
|
+
What happens now, is that the browser hard-navigates to /start/search.
|
|
8398
|
+
7. Click "back" again
|
|
8399
|
+
What happens now, is that the browser "soft-navigates" (just changes the URL) to https://ehandel.spendrups.se/Product/1104201
|
|
8400
|
+
PageReplacer unload itself and reveals the original document - it is expected to be the one under https://ehandel.spendrups.se/Product/1104201, but actually it is the one under /start/search - a white page.
|
|
8401
|
+
The fix: is to remember all pages that we have visited since the creation of `window` (we do that by having a static property on PageReplacer since we assume the PageReplacer source code will only exist once on the page and will be loaded at page load, the latter assumption might be wrong, but I hope not). If we get a "popstate" event (meaning back or forwards button, not new page being pushed) to an unknown page we reload.
|
|
8402
|
+
*/ (0, $46MJV$depictaiutilishared.dlog)("PageReplacer: ", cleaned_current_url, " hasn't been visited since document was created, reloading since we won't be able to show this page otherwise");
|
|
8102
8403
|
location.reload();
|
|
8103
8404
|
$37e96a5ebc768cc7$export$3ccaa27d81dd8556.#reverting_permitted = false; // Disallow any reverting since we can't - it would flash a white page until the reload has finished.
|
|
8104
8405
|
this.#unload(); // Call unload to "kill" the solid-js stuff quicker so that it stops updating - the user is expecting the next thing that happens to be a navigation to the actual page the URL says they're on.
|
|
8105
8406
|
}
|
|
8106
8407
|
};
|
|
8107
|
-
(0, $46MJV$depictaiutilishared.
|
|
8108
|
-
this.#revert_fns.push(()=>(0, $46MJV$depictaiutilishared.
|
|
8408
|
+
(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).add(on_maybe_popstate);
|
|
8409
|
+
this.#revert_fns.push(()=>(0, $46MJV$depictaiutilishared.instant_exec_on_suspect_history_change).delete(on_maybe_popstate)); // Don't run the bugfixer if there isn't a PageReplacer page open since I assume the bug only happens when going back from a PageReplace'd page
|
|
8109
8410
|
}
|
|
8110
|
-
/**
|
|
8111
|
-
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8411
|
+
/**
|
|
8412
|
+
* Stops listening to URL changes and closes the page (if it is currently open)
|
|
8112
8413
|
*/ destroy_() {
|
|
8113
8414
|
this.#unload();
|
|
8114
8415
|
this.#stop_listening?.();
|
|
@@ -8123,8 +8424,8 @@ class $37e96a5ebc768cc7$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8123
8424
|
if (!is_spa_) (0, $d589470b68ce5b67$export$689e204eadb33baf)(this); // Make so that clicking on links to the previous page work instantly
|
|
8124
8425
|
}
|
|
8125
8426
|
}
|
|
8126
|
-
/**
|
|
8127
|
-
* Remove hash from URL
|
|
8427
|
+
/**
|
|
8428
|
+
* Remove hash from URL
|
|
8128
8429
|
*/ function $37e96a5ebc768cc7$var$clean_url(url) {
|
|
8129
8430
|
// Would want to have this a static private function on PageReplacer, but that's not supported in MobileSafari yet
|
|
8130
8431
|
// remove hash, all other params *could* trigger a re-request
|