@depict-ai/ui 0.0.71 → 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/dist/index.d.ts +19 -19
- package/dist/main.js +725 -412
- package/dist/module.js +727 -413
- package/jest.setup.js +7 -0
- package/package.json +6 -4
- package/dist/typescript_schema/BaseSearchRequest.d.ts +0 -197
- package/dist/typescript_schema/ProductListingQueriesRequest.d.ts +0 -14
- package/dist/typescript_schema/ProductListingQueriesResponse.d.ts +0 -10
- package/dist/typescript_schema/ProductListingRequest.d.ts +0 -221
- package/dist/typescript_schema/ProductListingResponse.d.ts +0 -232
- package/dist/typescript_schema/RecommendResponse.d.ts +0 -15
- package/dist/typescript_schema/SearchRequest.d.ts +0 -213
- package/dist/typescript_schema/SearchResponse.d.ts +0 -192
- package/dist/typescript_schema/SearchSuggestionsRequest.d.ts +0 -18
- package/dist/typescript_schema/SearchSuggestionsResponse.d.ts +0 -182
- package/dist/typescript_schema/TrackV2Request.d.ts +0 -115
package/dist/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);
|
|
@@ -2866,156 +2866,6 @@ var $6865c7388a79e957$export$2e2bcd8739ae039 = {
|
|
|
2866
2866
|
|
|
2867
2867
|
|
|
2868
2868
|
|
|
2869
|
-
function $0bc45cf6753f874a$export$b288c38ae3fddb56({ available_filters_: available_filters_ , local_filter_cache_: [read_local_cache, write_local_cache] , selected_filters_: [read_selected_filters] }) {
|
|
2870
|
-
let last_remote_state;
|
|
2871
|
-
(0, $46MJV$solidjs.createComputed)(()=>{
|
|
2872
|
-
const remote_filters = Object.fromEntries(available_filters_()?.map((filter)=>[
|
|
2873
|
-
JSON.stringify([
|
|
2874
|
-
filter.field,
|
|
2875
|
-
filter.op,
|
|
2876
|
-
filter?.meta?.type
|
|
2877
|
-
]),
|
|
2878
|
-
filter
|
|
2879
|
-
]) || []);
|
|
2880
|
-
const local_filters = Object.fromEntries(read_local_cache().map((filter)=>[
|
|
2881
|
-
JSON.stringify([
|
|
2882
|
-
filter.field,
|
|
2883
|
-
filter.op,
|
|
2884
|
-
filter?.meta?.type
|
|
2885
|
-
]),
|
|
2886
|
-
filter
|
|
2887
|
-
]));
|
|
2888
|
-
const selected_filters = Object.fromEntries(read_selected_filters().map((filter_obj)=>[
|
|
2889
|
-
JSON.stringify([
|
|
2890
|
-
filter_obj.field,
|
|
2891
|
-
filter_obj.op
|
|
2892
|
-
]),
|
|
2893
|
-
filter_obj
|
|
2894
|
-
]));
|
|
2895
|
-
const new_local_filter_state = [];
|
|
2896
|
-
// 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
|
|
2897
|
-
for (const filter_id of [
|
|
2898
|
-
...Object.keys(local_filters).filter((key)=>!(key in remote_filters)),
|
|
2899
|
-
...Object.keys(remote_filters)
|
|
2900
|
-
]){
|
|
2901
|
-
const local_filter = local_filters[filter_id];
|
|
2902
|
-
const remote_filter = remote_filters[filter_id];
|
|
2903
|
-
const filter_id_without_meta_type = JSON.stringify(JSON.parse(filter_id).slice(0, 2));
|
|
2904
|
-
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
|
|
2905
|
-
{
|
|
2906
|
-
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]));
|
|
2907
|
-
} else if (!local_filter) // just take the remote one
|
|
2908
|
-
new_local_filter_state.push(remote_filter);
|
|
2909
|
-
else {
|
|
2910
|
-
// both exist, merge them if needed
|
|
2911
|
-
const remote_meta = remote_filter.meta;
|
|
2912
|
-
const local_meta = local_filter.meta;
|
|
2913
|
-
const this_applied_filter = selected_filters[filter_id_without_meta_type];
|
|
2914
|
-
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
|
|
2915
|
-
new_local_filter_state.push(remote_filter);
|
|
2916
|
-
else {
|
|
2917
|
-
const data_objs_in_remote = Object.fromEntries(remote_meta.values.map((value, index)=>[
|
|
2918
|
-
JSON.stringify(value),
|
|
2919
|
-
{
|
|
2920
|
-
value_: value,
|
|
2921
|
-
count_: remote_meta.counts?.[index],
|
|
2922
|
-
name_: remote_meta.names?.[index]
|
|
2923
|
-
}
|
|
2924
|
-
]));
|
|
2925
|
-
const data_objs_in_local = Object.fromEntries(local_meta.values.map((value, index)=>[
|
|
2926
|
-
JSON.stringify(value),
|
|
2927
|
-
{
|
|
2928
|
-
value_: value,
|
|
2929
|
-
count_: 0,
|
|
2930
|
-
name_: local_meta.names?.[index]
|
|
2931
|
-
}
|
|
2932
|
-
]));
|
|
2933
|
-
const new_data = [
|
|
2934
|
-
...Object.keys(data_objs_in_local).filter((key)=>{
|
|
2935
|
-
// put data entries that are selected and don't exist in new remote state first
|
|
2936
|
-
if (key in data_objs_in_remote) return false;
|
|
2937
|
-
const selected_values = this_applied_filter.data;
|
|
2938
|
-
return selected_values.some((value)=>{
|
|
2939
|
-
const is_equal = JSON.stringify(value) === key;
|
|
2940
|
-
if (is_equal) return true;
|
|
2941
|
-
if (local_meta.type === remote_meta.type && local_meta.type === "checkbox-hierarchical") {
|
|
2942
|
-
// 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.
|
|
2943
|
-
const selected_values = data_objs_in_local[key].value_;
|
|
2944
|
-
const values_length = value?.length;
|
|
2945
|
-
if (values_length > 1 && values_length - 1 === selected_values.length) {
|
|
2946
|
-
let is_parent = true;
|
|
2947
|
-
for(let i = 0; i < selected_values.length; i++)if (selected_values[i] !== value[i]) is_parent = false;
|
|
2948
|
-
return is_parent;
|
|
2949
|
-
}
|
|
2950
|
-
}
|
|
2951
|
-
return false;
|
|
2952
|
-
});
|
|
2953
|
-
}).map((key)=>data_objs_in_local[key]),
|
|
2954
|
-
...Object.values(data_objs_in_remote)
|
|
2955
|
-
];
|
|
2956
|
-
const new_values = new_data.map(({ value_: value_ })=>value_);
|
|
2957
|
-
const result = {
|
|
2958
|
-
...remote_filter,
|
|
2959
|
-
meta: {
|
|
2960
|
-
...remote_filter.meta,
|
|
2961
|
-
values: new_values,
|
|
2962
|
-
names: new_data.map(({ name_: name_ })=>name_),
|
|
2963
|
-
counts: new_data.map(({ count_: count_ })=>count_)
|
|
2964
|
-
}
|
|
2965
|
-
};
|
|
2966
|
-
new_local_filter_state.push(result);
|
|
2967
|
-
}
|
|
2968
|
-
}
|
|
2969
|
-
}
|
|
2970
|
-
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
|
|
2971
|
-
JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) // Sorry……… They're not that big
|
|
2972
|
-
write_local_cache(new_local_filter_state);
|
|
2973
|
-
last_remote_state = available_filters_();
|
|
2974
|
-
});
|
|
2975
|
-
return read_local_cache;
|
|
2976
|
-
}
|
|
2977
|
-
/**
|
|
2978
|
-
* 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.
|
|
2979
|
-
* This sets the counts to 0 (if applicable) and removes non-selected options (if applicable)
|
|
2980
|
-
*/ function $0bc45cf6753f874a$var$modify_only_local_filter(local_filter_object, selected_filter) {
|
|
2981
|
-
const old_meta = local_filter_object.meta;
|
|
2982
|
-
const selected_filter_data = selected_filter.data;
|
|
2983
|
-
const modified_filter_object = {
|
|
2984
|
-
...local_filter_object
|
|
2985
|
-
};
|
|
2986
|
-
if (old_meta) {
|
|
2987
|
-
const new_meta = {
|
|
2988
|
-
...old_meta
|
|
2989
|
-
};
|
|
2990
|
-
modified_filter_object.meta = new_meta;
|
|
2991
|
-
// set counts to 0
|
|
2992
|
-
if ("counts" in new_meta) {
|
|
2993
|
-
const counts = new_meta.counts;
|
|
2994
|
-
if (counts) new_meta.counts = counts.map(()=>0);
|
|
2995
|
-
}
|
|
2996
|
-
if (Array.isArray(selected_filter_data) && "values" in new_meta) {
|
|
2997
|
-
// we have an array of values and want to strip the ones from the available ones that aren't selected
|
|
2998
|
-
const values = new_meta.values;
|
|
2999
|
-
if (Array.isArray(values)) {
|
|
3000
|
-
const jsond_set_values = selected_filter_data.map((data)=>JSON.stringify(data));
|
|
3001
|
-
const indexes_to_remove = new Set();
|
|
3002
|
-
for(let i = 0; i < values.length; i++){
|
|
3003
|
-
const value = values[i];
|
|
3004
|
-
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
|
|
3005
|
-
indexes_to_remove.add(i);
|
|
3006
|
-
}
|
|
3007
|
-
new_meta.values = values.filter((_, index)=>!indexes_to_remove.has(index));
|
|
3008
|
-
if (new_meta.names) new_meta.names = new_meta.names.filter((_, index)=>!indexes_to_remove.has(index));
|
|
3009
|
-
if (new_meta.counts) // remove counts that are too much, they're all zero anyway if they exist
|
|
3010
|
-
new_meta.counts.length -= indexes_to_remove.size;
|
|
3011
|
-
}
|
|
3012
|
-
}
|
|
3013
|
-
}
|
|
3014
|
-
return modified_filter_object;
|
|
3015
|
-
}
|
|
3016
|
-
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
2869
|
|
|
3020
2870
|
|
|
3021
2871
|
|
|
@@ -3157,11 +3007,7 @@ function $1587765bd31f3722$export$3f1a388cc0d8fed7(props) {
|
|
|
3157
3007
|
});
|
|
3158
3008
|
}
|
|
3159
3009
|
function $1587765bd31f3722$var$ActualFilterBody(props) {
|
|
3160
|
-
const modified_available_filters_with_selected_unexisting_ones_injected_from_local_state =
|
|
3161
|
-
available_filters_: props.available_filters_,
|
|
3162
|
-
selected_filters_: props.selected_filters_,
|
|
3163
|
-
local_filter_cache_: props.local_filter_cache_
|
|
3164
|
-
});
|
|
3010
|
+
const [modified_available_filters_with_selected_unexisting_ones_injected_from_local_state] = props.local_filter_cache_;
|
|
3165
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));
|
|
3166
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));
|
|
3167
3013
|
const togglable_filters_grouped_by_collapsible = (0, $46MJV$solidjs.createMemo)(()=>{
|
|
@@ -3362,7 +3208,7 @@ function $1587765bd31f3722$var$ActualFilterBody(props) {
|
|
|
3362
3208
|
|
|
3363
3209
|
|
|
3364
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);
|
|
3365
|
-
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_ }) {
|
|
3366
3212
|
const title_radio_name = (0, $46MJV$depictaiutilishared.make_random_classname)();
|
|
3367
3213
|
const order_radio_name = (0, $46MJV$depictaiutilishared.make_random_classname)();
|
|
3368
3214
|
return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
@@ -3396,14 +3242,14 @@ function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: availa
|
|
|
3396
3242
|
},
|
|
3397
3243
|
children: (item, index)=>{
|
|
3398
3244
|
const is_checked = (0, $46MJV$solidjs.createMemo)(()=>{
|
|
3399
|
-
const sort =
|
|
3245
|
+
const sort = get_current_sorting();
|
|
3400
3246
|
if (!sort) // if no sortings are selected, "select" first sort
|
|
3401
3247
|
return index === 0;
|
|
3402
3248
|
return sort.field === item().field && (sort.order === item().order || item().meta.values?.length > 1);
|
|
3403
3249
|
});
|
|
3404
3250
|
return /* wrapping div for flex gap polyfill scss mixin */ (()=>{
|
|
3405
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;
|
|
3406
|
-
(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())));
|
|
3407
3253
|
(0, $46MJV$solidjsweb.setAttribute)(_el$10, "name", title_radio_name);
|
|
3408
3254
|
(0, $46MJV$solidjsweb.insert)(_el$9, ()=>item().meta.title, null);
|
|
3409
3255
|
(0, $46MJV$solidjsweb.effect)(()=>_el$10.checked = is_checked());
|
|
@@ -3415,27 +3261,25 @@ function $cc8aaf130b1dc1ea$export$1f1775a58da589b5({ available_sortings_: availa
|
|
|
3415
3261
|
})(),
|
|
3416
3262
|
(0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
3417
3263
|
get when () {
|
|
3418
|
-
return
|
|
3264
|
+
return meta_of_currently_selected_sorting_()?.values?.length > 1;
|
|
3419
3265
|
},
|
|
3420
3266
|
get children () {
|
|
3421
3267
|
const _el$2 = $cc8aaf130b1dc1ea$var$_tmpl$2.cloneNode(true);
|
|
3422
3268
|
(0, $46MJV$solidjsweb.insert)(_el$2, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Index), {
|
|
3423
3269
|
get each () {
|
|
3424
|
-
return
|
|
3270
|
+
return meta_of_currently_selected_sorting_()?.values;
|
|
3425
3271
|
},
|
|
3426
3272
|
children: (order_value, index)=>{
|
|
3273
|
+
const is_checked = (0, $46MJV$solidjs.createMemo)(()=>get_current_sorting()?.order === order_value());
|
|
3427
3274
|
return (()=>{
|
|
3428
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;
|
|
3429
|
-
(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 && {
|
|
3430
3277
|
...c,
|
|
3431
3278
|
order: order_value()
|
|
3432
3279
|
})));
|
|
3433
3280
|
(0, $46MJV$solidjsweb.setAttribute)(_el$14, "name", order_radio_name);
|
|
3434
|
-
(0, $46MJV$solidjsweb.insert)(_el$13, ()=>
|
|
3435
|
-
(0, $46MJV$solidjsweb.effect)(()=>_el$14.checked = (
|
|
3436
|
-
const sort = current_sorting_[0]();
|
|
3437
|
-
return sort?.order === order_value();
|
|
3438
|
-
})());
|
|
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());
|
|
3439
3283
|
return _el$12;
|
|
3440
3284
|
})();
|
|
3441
3285
|
}
|
|
@@ -3780,20 +3624,177 @@ function $66ddbcbc40487f95$export$9bf11afa910f536e({ args_for_sorting_: args_for
|
|
|
3780
3624
|
|
|
3781
3625
|
|
|
3782
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
|
+
|
|
3783
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);
|
|
3784
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_ }) {
|
|
3785
3778
|
return (0, $0f2f58dd60b11888$export$b69d0d92862de18b)({
|
|
3786
3779
|
severity_: "error",
|
|
3787
3780
|
message_: "Sorting and filters failed",
|
|
3788
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
|
+
});
|
|
3789
3788
|
const cleanup_promise = new Promise((r)=>(0, $46MJV$solidjs.onCleanup)(r));
|
|
3790
3789
|
const [filters_open, set_filters_open] = search_filters_open_;
|
|
3791
3790
|
const [sorting_open, set_sorting_open] = search_sorting_open_;
|
|
3791
|
+
const [get_current_sorting_] = current_sorting_;
|
|
3792
3792
|
const [is_small, set_is_small] = (0, $46MJV$solidjs.createSignal)(false);
|
|
3793
3793
|
const dismiss_modal_ = (0, $46MJV$depictaiutilishared.catchify)(()=>{
|
|
3794
3794
|
set_filters_open(false);
|
|
3795
3795
|
set_sorting_open(false);
|
|
3796
3796
|
});
|
|
3797
|
+
const meta_of_currently_selected_sorting_ = (0, $46MJV$solidjs.createMemo)(()=>available_sortings_()?.find?.((sorting)=>sorting.field === get_current_sorting_()?.field)?.meta);
|
|
3797
3798
|
const filter_options = {
|
|
3798
3799
|
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
3799
3800
|
local_filter_cache_: local_filter_cache_,
|
|
@@ -3804,7 +3805,8 @@ function $881cb1745bafff7a$export$d7841e452f2e59a8({ current_sorting_: current_s
|
|
|
3804
3805
|
};
|
|
3805
3806
|
const sorting_options = {
|
|
3806
3807
|
current_sorting_: current_sorting_,
|
|
3807
|
-
available_sortings_: available_sortings_
|
|
3808
|
+
available_sortings_: available_sortings_,
|
|
3809
|
+
meta_of_currently_selected_sorting_: meta_of_currently_selected_sorting_
|
|
3808
3810
|
};
|
|
3809
3811
|
const make_open_filters_button = (adhere_to_width = false, is_tabbable = false)=>(0, $46MJV$solidjsweb.createComponent)($881cb1745bafff7a$var$OpenFiltersButton, {
|
|
3810
3812
|
tabindex_: is_tabbable ? 0 : -1,
|
|
@@ -3817,11 +3819,12 @@ function $881cb1745bafff7a$export$d7841e452f2e59a8({ current_sorting_: current_s
|
|
|
3817
3819
|
const make_open_sorting_button = (adhere_to_width = false, is_tabbable = false)=>(0, $46MJV$solidjsweb.createComponent)($881cb1745bafff7a$var$OpenSortingButton, {
|
|
3818
3820
|
tabindex_: is_tabbable ? 0 : -1,
|
|
3819
3821
|
i18n_: i18n_,
|
|
3820
|
-
|
|
3822
|
+
get_current_sorting_: get_current_sorting_,
|
|
3821
3823
|
search_filters_open_: search_filters_open_,
|
|
3822
3824
|
search_sorting_open_: search_sorting_open_,
|
|
3823
3825
|
available_sortings_: available_sortings_,
|
|
3824
|
-
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_
|
|
3825
3828
|
});
|
|
3826
3829
|
let open_modal_;
|
|
3827
3830
|
let close_modal_;
|
|
@@ -3949,7 +3952,7 @@ function $881cb1745bafff7a$var$OpenFiltersButton({ i18n_: i18n_ , search_filters
|
|
|
3949
3952
|
return _el$8;
|
|
3950
3953
|
})();
|
|
3951
3954
|
}
|
|
3952
|
-
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_ }) {
|
|
3953
3956
|
const sorting_closed = (0, $46MJV$solidjs.createMemo)(()=>!search_sorting_open_[0]());
|
|
3954
3957
|
// We assume in embedded_num_products that this is a single HTMLElement so pls change there if you change it here
|
|
3955
3958
|
return (()=>{
|
|
@@ -3965,7 +3968,7 @@ function $881cb1745bafff7a$var$OpenSortingButton({ i18n_: i18n_ , current_sortin
|
|
|
3965
3968
|
(0, $46MJV$solidjsweb.setAttribute)(_el$12, "tabindex", tabindex_);
|
|
3966
3969
|
(0, $46MJV$solidjsweb.insert)(_el$13, (()=>{
|
|
3967
3970
|
const _c$ = (0, $46MJV$solidjsweb.memo)(()=>!!sorting_closed());
|
|
3968
|
-
return ()=>_c$() && (
|
|
3971
|
+
return ()=>_c$() && (meta_of_currently_selected_sorting_()?.title || available_sortings_()?.[0]?.meta?.title) || i18n_.sorting_text_();
|
|
3969
3972
|
})());
|
|
3970
3973
|
(0, $46MJV$solidjsweb.insert)(_el$12, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
3971
3974
|
get when () {
|
|
@@ -3975,7 +3978,7 @@ function $881cb1745bafff7a$var$OpenSortingButton({ i18n_: i18n_ , current_sortin
|
|
|
3975
3978
|
return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.MinusIcon), {});
|
|
3976
3979
|
},
|
|
3977
3980
|
get children () {
|
|
3978
|
-
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), {});
|
|
3979
3982
|
}
|
|
3980
3983
|
}), null);
|
|
3981
3984
|
(0, $46MJV$solidjsweb.effect)((_p$)=>{
|
|
@@ -4156,8 +4159,157 @@ function $fd64465f894d1f29$var$ActualFloatingButtons({ search_filters_open_: [ge
|
|
|
4156
4159
|
|
|
4157
4160
|
|
|
4158
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
|
+
|
|
4159
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);
|
|
4160
|
-
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_ }) {
|
|
4161
4313
|
const placeholder_crumb_data = [
|
|
4162
4314
|
,
|
|
4163
4315
|
,
|
|
@@ -4174,6 +4326,7 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4174
4326
|
return crumb_data();
|
|
4175
4327
|
},
|
|
4176
4328
|
children: (display_accessor, index)=>{
|
|
4329
|
+
const href = (0, $46MJV$solidjs.createMemo)(()=>(0, $c6a04c153e9853a7$export$43cd1e747fecd42e)(display_accessor()?.page_url));
|
|
4177
4330
|
return [
|
|
4178
4331
|
(0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
4179
4332
|
get when () {
|
|
@@ -4187,9 +4340,13 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4187
4340
|
},
|
|
4188
4341
|
get children () {
|
|
4189
4342
|
const _el$2 = $495e9998757c5d32$var$_tmpl$2.cloneNode(true);
|
|
4190
|
-
(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);
|
|
4191
4348
|
(0, $46MJV$solidjsweb.insert)(_el$2, ()=>display_accessor().title);
|
|
4192
|
-
(0, $46MJV$solidjsweb.effect)(()=>(0, $46MJV$solidjsweb.setAttribute)(_el$2, "href",
|
|
4349
|
+
(0, $46MJV$solidjsweb.effect)(()=>(0, $46MJV$solidjsweb.setAttribute)(_el$2, "href", href()));
|
|
4193
4350
|
return _el$2;
|
|
4194
4351
|
}
|
|
4195
4352
|
}),
|
|
@@ -4226,8 +4383,9 @@ function $495e9998757c5d32$export$5646050d516e06bc({ crumb_data_: get_api_crumb_
|
|
|
4226
4383
|
|
|
4227
4384
|
|
|
4228
4385
|
|
|
4386
|
+
|
|
4229
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);
|
|
4230
|
-
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_ }) {
|
|
4231
4389
|
let scrolling_logic_ran_for_query_id = false;
|
|
4232
4390
|
let last_scroll_position;
|
|
4233
4391
|
let scroll_to_element_on_dom_insertion;
|
|
@@ -4350,18 +4508,37 @@ function $cdc2c00c0a7da86e$export$466cdc317043f6cb({ quicklinks_data_: quicklink
|
|
|
4350
4508
|
},
|
|
4351
4509
|
children: (display_accessor, index)=>{
|
|
4352
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()));
|
|
4353
4524
|
return (()=>{
|
|
4354
4525
|
const _el$3 = $cdc2c00c0a7da86e$var$_tmpl$3.cloneNode(true);
|
|
4355
4526
|
(0, $46MJV$solidjsweb.addEventListener)(_el$3, "click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>{
|
|
4356
|
-
|
|
4357
|
-
|
|
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
|
+
});
|
|
4358
4535
|
}), true);
|
|
4359
4536
|
(0, $46MJV$solidjsweb.insert)(_el$3, ()=>display_accessor()?.title || (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.Placeholder), {
|
|
4360
4537
|
height: "1em",
|
|
4361
4538
|
width: "10ch"
|
|
4362
4539
|
}));
|
|
4363
4540
|
(0, $46MJV$solidjsweb.effect)((_p$)=>{
|
|
4364
|
-
const _v$ = !!is_selected(), _v$2 =
|
|
4541
|
+
const _v$ = !!is_selected(), _v$2 = href();
|
|
4365
4542
|
_v$ !== _p$._v$ && _el$3.classList.toggle("selected", _p$._v$ = _v$);
|
|
4366
4543
|
_v$2 !== _p$._v$2 && (0, $46MJV$solidjsweb.setAttribute)(_el$3, "href", _p$._v$2 = _v$2);
|
|
4367
4544
|
return _p$;
|
|
@@ -4388,7 +4565,17 @@ function $cdc2c00c0a7da86e$export$466cdc317043f6cb({ quicklinks_data_: quicklink
|
|
|
4388
4565
|
|
|
4389
4566
|
|
|
4390
4567
|
|
|
4391
|
-
|
|
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
|
|
4392
4579
|
let previous_crumb_data = (0, $46MJV$solidjs.untrack)(crumb_data_);
|
|
4393
4580
|
let query_id_when_we_got_previous_data = (0, $46MJV$solidjs.untrack)(query_id_);
|
|
4394
4581
|
let allow_filter_clearing = true; // set to false when going backwards/forwards
|
|
@@ -4405,7 +4592,41 @@ function $34f90ffb69e23732$export$3fe6942dd2836d9d({ crumb_data_: crumb_data_ ,
|
|
|
4405
4592
|
const went_downwards = previous_length < new_length;
|
|
4406
4593
|
const shorter_array = went_upwards ? new_crumb_data : previous_crumb_data;
|
|
4407
4594
|
const longer_array = went_upwards ? previous_crumb_data : new_crumb_data;
|
|
4408
|
-
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
|
|
4409
4630
|
(0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
|
|
4410
4631
|
user_triggered_: false,
|
|
4411
4632
|
i18n_: i18n_,
|
|
@@ -4414,11 +4635,9 @@ function $34f90ffb69e23732$export$3fe6942dd2836d9d({ crumb_data_: crumb_data_ ,
|
|
|
4414
4635
|
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4415
4636
|
local_filter_cache_: local_filter_cache_
|
|
4416
4637
|
});
|
|
4417
|
-
}
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
if (!allow_filter_clearing) allow_filter_clearing = true;
|
|
4421
|
-
})));
|
|
4638
|
+
});
|
|
4639
|
+
});
|
|
4640
|
+
tracking_function_for_plp_results(plp_results_);
|
|
4422
4641
|
}
|
|
4423
4642
|
|
|
4424
4643
|
|
|
@@ -4537,7 +4756,7 @@ let $29b757e2ae26852c$export$44dad306455dddf;
|
|
|
4537
4756
|
|
|
4538
4757
|
|
|
4539
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);
|
|
4540
|
-
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_ }) {
|
|
4541
4760
|
let results_for;
|
|
4542
4761
|
let only_show_filters_opener_;
|
|
4543
4762
|
let middle_elements_;
|
|
@@ -4711,13 +4930,14 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4711
4930
|
selected_filters_: selected_filters_,
|
|
4712
4931
|
available_filters_: available_filters_
|
|
4713
4932
|
});
|
|
4714
|
-
(0, $
|
|
4933
|
+
(0, $207f7b30db90d048$export$3945d6db2dfd3d12)({
|
|
4715
4934
|
query_id_: query_id_,
|
|
4716
4935
|
crumb_data_: crumb_data_,
|
|
4717
4936
|
i18n_: i18n_,
|
|
4718
4937
|
selected_filters_: selected_filters_,
|
|
4719
4938
|
local_filter_cache_: local_filter_cache_,
|
|
4720
|
-
expanded_hierarchical_filters_: expanded_hierarchical_filters_
|
|
4939
|
+
expanded_hierarchical_filters_: expanded_hierarchical_filters_,
|
|
4940
|
+
plp_results_: plp_results_
|
|
4721
4941
|
});
|
|
4722
4942
|
get_breadcrumb_accessor_?.(crumb_data_);
|
|
4723
4943
|
get_quicklinks_accessor_?.(quicklinks_data_);
|
|
@@ -4730,7 +4950,7 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4730
4950
|
get children () {
|
|
4731
4951
|
return (0, $46MJV$solidjsweb.createComponent)((0, $495e9998757c5d32$export$5646050d516e06bc), {
|
|
4732
4952
|
crumb_data_: crumb_data_,
|
|
4733
|
-
|
|
4953
|
+
router_: router_,
|
|
4734
4954
|
i18n_: i18n_
|
|
4735
4955
|
});
|
|
4736
4956
|
}
|
|
@@ -4741,7 +4961,7 @@ function $671632478f2a7ce7$export$f7d2f673fc2f091d({ depict_api_: depict_api_ ,
|
|
|
4741
4961
|
return (0, $46MJV$solidjsweb.createComponent)((0, $cdc2c00c0a7da86e$export$466cdc317043f6cb), {
|
|
4742
4962
|
quicklinks_data_: quicklinks_data_,
|
|
4743
4963
|
current_query_id_: query_id_,
|
|
4744
|
-
|
|
4964
|
+
router_: router_,
|
|
4745
4965
|
slider_arrow_button_: slider_arrow_button_,
|
|
4746
4966
|
breadcrumb_data_: crumb_data_,
|
|
4747
4967
|
i18n_: i18n_
|
|
@@ -4965,6 +5185,166 @@ function $f27b0b326e0a87e2$export$23fca46f3143581f(component, error_message) {
|
|
|
4965
5185
|
}
|
|
4966
5186
|
|
|
4967
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
|
+
|
|
4968
5348
|
const $068a627cc18f7bb6$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp category"></div>`, 2);
|
|
4969
5349
|
const $068a627cc18f7bb6$var$min_products_to_fetch_ = 20;
|
|
4970
5350
|
const $068a627cc18f7bb6$var$privately_shared_properties = /*@__PURE__*/ new WeakMap();
|
|
@@ -4975,6 +5355,7 @@ const $068a627cc18f7bb6$var$InExternalAreaDiv = ({ children: children })=>(()=>
|
|
|
4975
5355
|
return _el$;
|
|
4976
5356
|
})();
|
|
4977
5357
|
class $068a627cc18f7bb6$export$f34314aa9505732e {
|
|
5358
|
+
#router = new (0, $43940d5ca403c293$export$7e1297a3a19f10d8)("hard_navigation");
|
|
4978
5359
|
#locale_signal = (0, $46MJV$solidjs.createSignal)();
|
|
4979
5360
|
#merchant_signal = (0, $46MJV$solidjs.createSignal)();
|
|
4980
5361
|
#market_signal = (0, $46MJV$solidjs.createSignal)();
|
|
@@ -5005,38 +5386,30 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
|
|
|
5005
5386
|
set market(market) {
|
|
5006
5387
|
this.#market_signal[1](market);
|
|
5007
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
|
+
}
|
|
5008
5396
|
constructor({ api: api , on_navigation: on_navigation , ...props_on_class }){
|
|
5009
5397
|
if ($068a627cc18f7bb6$export$f34314aa9505732e.#has_been_constructed) throw new Error("You can only have one instance of DepictCategory due to state limitations");
|
|
5010
5398
|
$068a627cc18f7bb6$export$f34314aa9505732e.#has_been_constructed = true;
|
|
5011
5399
|
Object.assign(this, props_on_class); // set initial signal values
|
|
5012
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);
|
|
5013
5403
|
const [reset_history_state_, state_] = (0, $0de081f67b6d15b5$export$9862539c89138352)(()=>({
|
|
5014
|
-
category_sorting: undefined,
|
|
5015
5404
|
category_filters_open: false,
|
|
5016
5405
|
category_sorting_open: false,
|
|
5017
5406
|
category_expanded_filters: [],
|
|
5018
|
-
//
|
|
5019
|
-
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
|
|
5020
5408
|
category_local_filter_cache: [],
|
|
5021
5409
|
category_expanded_hierarchical_filters: [],
|
|
5022
5410
|
category_scroll_restoration_data: []
|
|
5023
5411
|
}));
|
|
5024
5412
|
const i18n_ = (0, $623202ae203e9e59$export$f091cbac892643a4)(this.#locale_signal[0]);
|
|
5025
|
-
const on_category_link_click_ = (e, d)=>{
|
|
5026
|
-
if (e.button || e.metaKey || e.ctrlKey) // Not single page navigating because button is not 0 or ctrl/command click
|
|
5027
|
-
return;
|
|
5028
|
-
try {
|
|
5029
|
-
const url_object = new URL(d.page_url);
|
|
5030
|
-
const relative_url = url_object.pathname + url_object.search + url_object.hash;
|
|
5031
|
-
on_navigation(relative_url, e, d);
|
|
5032
|
-
e.preventDefault();
|
|
5033
|
-
} catch (e) {
|
|
5034
|
-
queueMicrotask(()=>{
|
|
5035
|
-
// make sure to throw into the global scope if on_navigation throws
|
|
5036
|
-
throw e;
|
|
5037
|
-
});
|
|
5038
|
-
}
|
|
5039
|
-
};
|
|
5040
5413
|
$068a627cc18f7bb6$var$privately_shared_properties.set(this, {
|
|
5041
5414
|
state_: state_,
|
|
5042
5415
|
breadcrumb_signal_: (0, $46MJV$solidjs.createSignal)(),
|
|
@@ -5044,7 +5417,9 @@ class $068a627cc18f7bb6$export$f34314aa9505732e {
|
|
|
5044
5417
|
i18n_: i18n_,
|
|
5045
5418
|
reset_history_state_: reset_history_state_,
|
|
5046
5419
|
depict_api_: api ?? new (0, $9ce64f69303c371e$export$e015ed2f2950f2e3)(),
|
|
5047
|
-
|
|
5420
|
+
router_: this.#router,
|
|
5421
|
+
selected_filters_: selected_filters_,
|
|
5422
|
+
current_sorting_: current_sorting_,
|
|
5048
5423
|
slider_arrow_button_: (0, $46MJV$depictaiutilishared.GenericSliderArrowButton)({
|
|
5049
5424
|
height_: 12,
|
|
5050
5425
|
width_: 6.46
|
|
@@ -5061,7 +5436,7 @@ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
5061
5436
|
grid_spacing: grid_spacing.horizontal
|
|
5062
5437
|
};
|
|
5063
5438
|
return (0, $f27b0b326e0a87e2$export$23fca46f3143581f)(()=>{
|
|
5064
|
-
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;
|
|
5065
5440
|
(0, $46MJV$solidjs.onCleanup)(reset_history_state_);
|
|
5066
5441
|
return (0, $671632478f2a7ce7$export$f7d2f673fc2f091d)({
|
|
5067
5442
|
tenant_: ()=>depict_category.merchant,
|
|
@@ -5075,7 +5450,7 @@ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
5075
5450
|
category_title_: category_title,
|
|
5076
5451
|
show_breadcrumbs_: show_breadcrumbs,
|
|
5077
5452
|
current_sorting_: current_sorting_,
|
|
5078
|
-
|
|
5453
|
+
router_: router_,
|
|
5079
5454
|
get_breadcrumb_accessor_: (accessor)=>(0, $46MJV$solidjs.createComputed)(()=>breadcrumb_signal_[1](accessor())),
|
|
5080
5455
|
get_quicklinks_accessor_: (accessor)=>(0, $46MJV$solidjs.createComputed)(()=>quicklinks_signal_[1](accessor())),
|
|
5081
5456
|
category_filters_open_: category_filters_open_,
|
|
@@ -5100,25 +5475,25 @@ function $068a627cc18f7bb6$export$e2bf8ce7779e827e({ depict_category: depict_cat
|
|
|
5100
5475
|
}, "Entire CategoryPage failed");
|
|
5101
5476
|
}
|
|
5102
5477
|
function $068a627cc18f7bb6$export$5b7c3ce0ebe51f86({ depict_category: depict_category }) {
|
|
5103
|
-
const { i18n_: i18n_ , breadcrumb_signal_: [crumb_data_] ,
|
|
5478
|
+
const { i18n_: i18n_ , breadcrumb_signal_: [crumb_data_] , router_: router_ } = $068a627cc18f7bb6$var$get_shared_properties(depict_category);
|
|
5104
5479
|
return (0, $46MJV$solidjsweb.createComponent)($068a627cc18f7bb6$var$InExternalAreaDiv, {
|
|
5105
5480
|
get children () {
|
|
5106
5481
|
return (0, $495e9998757c5d32$export$5646050d516e06bc)({
|
|
5107
5482
|
i18n_: i18n_,
|
|
5108
5483
|
crumb_data_: crumb_data_,
|
|
5109
|
-
|
|
5484
|
+
router_: router_
|
|
5110
5485
|
});
|
|
5111
5486
|
}
|
|
5112
5487
|
});
|
|
5113
5488
|
}
|
|
5114
5489
|
function $068a627cc18f7bb6$export$de035477d6fef996({ depict_category: depict_category }) {
|
|
5115
|
-
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);
|
|
5116
5491
|
return (0, $46MJV$solidjsweb.createComponent)($068a627cc18f7bb6$var$InExternalAreaDiv, {
|
|
5117
5492
|
get children () {
|
|
5118
5493
|
return (0, $cdc2c00c0a7da86e$export$466cdc317043f6cb)({
|
|
5119
5494
|
i18n_: i18n_,
|
|
5120
5495
|
quicklinks_data_: quicklinks_data_,
|
|
5121
|
-
|
|
5496
|
+
router_: router_,
|
|
5122
5497
|
current_query_id_: ()=>depict_category.category_id,
|
|
5123
5498
|
slider_arrow_button_: slider_arrow_button_,
|
|
5124
5499
|
breadcrumb_data_: breadcrumb_data_
|
|
@@ -5347,17 +5722,14 @@ function $17c49340edfdbb31$export$ee1733d9a8495996() {
|
|
|
5347
5722
|
|
|
5348
5723
|
|
|
5349
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);
|
|
5350
|
-
function $67892c03cd3dfa66$export$d757d54550ebfb3d({ category_suggestion_: category_suggestion_ ,
|
|
5725
|
+
function $67892c03cd3dfa66$export$d757d54550ebfb3d({ category_suggestion_: category_suggestion_ , router_: router_ }) {
|
|
5351
5726
|
return (()=>{
|
|
5352
5727
|
const _el$ = $67892c03cd3dfa66$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild;
|
|
5353
|
-
(0, $46MJV$solidjsweb.addEventListener)(_el$, "click", (0, $46MJV$depictaiutilishared.catchify)((e)=>{
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
|
|
5357
|
-
|
|
5358
|
-
return on_navigation_(category_suggestion_().page_url);
|
|
5359
|
-
}
|
|
5360
|
-
}), 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);
|
|
5361
5733
|
(0, $46MJV$solidjsweb.insert)(_el$2, ()=>category_suggestion_().title);
|
|
5362
5734
|
(0, $46MJV$solidjsweb.insert)(_el$, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
5363
5735
|
get when () {
|
|
@@ -5435,13 +5807,14 @@ function $2989e355f64e18e1$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5435
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
|
|
5436
5808
|
return;
|
|
5437
5809
|
if (input_element.selectionStart === 0 && input_element.selectionEnd === input_element.value.length) // everything was selected, clear filters on next submit on next input
|
|
5438
|
-
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
|
+
{
|
|
5439
5812
|
once: true
|
|
5440
5813
|
});
|
|
5441
5814
|
}));
|
|
5442
5815
|
(0, $46MJV$solidjsweb.addEventListener)(_el$4, "input", (0, $46MJV$depictaiutilishared.catchify)(()=>{
|
|
5443
5816
|
const { value: value } = input_element;
|
|
5444
|
-
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
|
|
5445
5818
|
search_field_value_[1](value);
|
|
5446
5819
|
}), true);
|
|
5447
5820
|
(0, $46MJV$solidjsweb.addEventListener)(_el$4, "keydown", (0, $46MJV$depictaiutilishared.catchify)((e)=>{
|
|
@@ -5461,7 +5834,7 @@ function $2989e355f64e18e1$export$b94867ecbd698f21({ search_field_value_: search
|
|
|
5461
5834
|
_el$4.classList.toggle("has-adjacent-back-button", !!on_back_);
|
|
5462
5835
|
(0, $46MJV$solidjsweb.addEventListener)(_el$5, "click", (0, $46MJV$depictaiutilishared.catchify)(()=>{
|
|
5463
5836
|
search_field_value_[1]("");
|
|
5464
|
-
clear_filters_();
|
|
5837
|
+
clear_filters_(true);
|
|
5465
5838
|
if (!disabled_) input_element.focus();
|
|
5466
5839
|
}), true);
|
|
5467
5840
|
(0, $46MJV$solidjsweb.insert)(_el$5, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.CrossIcon), {}));
|
|
@@ -5679,27 +6052,27 @@ function $67b60b572b7b7059$export$b3ad617e9036868(modal_body_style, input_field,
|
|
|
5679
6052
|
|
|
5680
6053
|
|
|
5681
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_ }) {
|
|
5682
|
-
const [get_selected_filters
|
|
5683
|
-
|
|
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
|
|
5684
6061
|
const [get_clear_filters_next_submit, set_clear_filters_next_submit] = clear_filters_next_submit_;
|
|
5685
|
-
const clear_filters = ()=>set_clear_filters_next_submit(
|
|
6062
|
+
const clear_filters = (user_triggered)=>set_clear_filters_next_submit(user_triggered ? 2 : 1);
|
|
5686
6063
|
(0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(get_selected_filters, ()=>{
|
|
5687
6064
|
// if the selected filters update, clear the clearing signal
|
|
5688
|
-
set_clear_filters_next_submit(
|
|
6065
|
+
set_clear_filters_next_submit(0);
|
|
5689
6066
|
}, {
|
|
5690
6067
|
defer: true
|
|
5691
6068
|
}));
|
|
5692
6069
|
(0, $46MJV$solidjs.createComputed)((0, $46MJV$solidjs.on)(get_search_query, (0, $46MJV$depictaiutilishared.catchify)(()=>{
|
|
5693
6070
|
// when a query was submitted, clear filters if clear was pressed before
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
// also collapse expanded filters in hierarchical filter tree again
|
|
5698
|
-
expanded_hierarchical_filters_[1]([]);
|
|
5699
|
-
// also clear sorting
|
|
5700
|
-
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);
|
|
5701
6074
|
(0, $92e4e7906daa1ff8$export$8895d39404bd2bb1)({
|
|
5702
|
-
user_triggered_:
|
|
6075
|
+
user_triggered_: clear_value === 2,
|
|
5703
6076
|
selected_filters_: selected_filters_,
|
|
5704
6077
|
i18n_: i18n_,
|
|
5705
6078
|
also_clear_sorting_: true,
|
|
@@ -5744,26 +6117,8 @@ function $ad118c2ba257d9b7$export$84bba84a7b837187(search_query) {
|
|
|
5744
6117
|
|
|
5745
6118
|
|
|
5746
6119
|
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
*/ function $405647fc79da2849$export$26df08e242fe83a3(url_param_name, value, url_transformer) {
|
|
5750
|
-
$405647fc79da2849$var$set_param(false, url_param_name, value, url_transformer);
|
|
5751
|
-
}
|
|
5752
|
-
function $405647fc79da2849$export$7a053411c76081d8(url_param_name, value, url_transformer) {
|
|
5753
|
-
$405647fc79da2849$var$set_param(true, url_param_name, value, url_transformer);
|
|
5754
|
-
}
|
|
5755
|
-
function $405647fc79da2849$var$set_param(replace, url_param_name, value, url_transformer) {
|
|
5756
|
-
const u_o = new URL(location.href);
|
|
5757
|
-
url_transformer?.(u_o);
|
|
5758
|
-
const { searchParams: searchParams } = u_o;
|
|
5759
|
-
if (value !== undefined) searchParams.set(url_param_name, value);
|
|
5760
|
-
else searchParams.delete(url_param_name);
|
|
5761
|
-
history[replace ? "replaceState" : "pushState"](history.state, "", u_o.href);
|
|
5762
|
-
}
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
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_ }) {
|
|
5766
|
-
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();
|
|
5767
6122
|
const previous_query = (0, $46MJV$solidjs.untrack)(read_search_query);
|
|
5768
6123
|
if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
|
|
5769
6124
|
// don't push a history entry / re-search if someone submits a search again
|
|
@@ -5771,9 +6126,16 @@ function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchanged_va
|
|
|
5771
6126
|
on_submit_with_unchanged_value_?.();
|
|
5772
6127
|
return;
|
|
5773
6128
|
}
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
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);
|
|
5777
6139
|
scrollTo(0, 0);
|
|
5778
6140
|
after_submit_?.();
|
|
5779
6141
|
}
|
|
@@ -5782,6 +6144,8 @@ function $1c323edfb89c9dca$export$e16630ecb9644a1c({ on_submit_with_unchanged_va
|
|
|
5782
6144
|
|
|
5783
6145
|
|
|
5784
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
|
|
5785
6149
|
const signals = {};
|
|
5786
6150
|
const entries = Object.entries(params_to_default_value);
|
|
5787
6151
|
for (const [param, default_value] of entries)signals[param] = (0, $46MJV$solidjs.createSignal)(default_value ?? "");
|
|
@@ -6112,47 +6476,26 @@ function $6ea05d3ebaa81958$export$50b90be27d8502d9(el, [get_style_props, set_sty
|
|
|
6112
6476
|
|
|
6113
6477
|
|
|
6114
6478
|
|
|
6115
|
-
function $41151dd3f5de2c98$export$91c3b6774e8be0f5({ param_: param_ , value_: value_ , url_transformer_: url_transformer_
|
|
6116
|
-
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);
|
|
6117
6481
|
const [exit_iterable, exitable_iterable] = (0, $46MJV$depictaiutilishared.make_asyncIterable_exiter)((0, $46MJV$depictaiutilishared.href_change_ipns));
|
|
6118
6482
|
(0, $46MJV$solidjs.onCleanup)(exit_iterable);
|
|
6119
6483
|
(0, $46MJV$depictaiutilishared.catchify)(async ()=>{
|
|
6120
|
-
for await (const href of exitable_iterable)
|
|
6121
|
-
|
|
6122
|
-
const u_o = new URL(href);
|
|
6123
|
-
url_transformer_?.(u_o);
|
|
6124
|
-
u_o.searchParams.set(param_, value_);
|
|
6125
|
-
write_link(u_o.href);
|
|
6126
|
-
}
|
|
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);
|
|
6127
6486
|
})();
|
|
6128
|
-
|
|
6129
|
-
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
|
|
6134
|
-
on_submit_with_unchanged_value_?.();
|
|
6135
|
-
return;
|
|
6136
|
-
}
|
|
6137
|
-
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
|
|
6138
|
-
if (typeof alternative_query_submitter_for_spas_ === "function") alternative_query_submitter_for_spas_(param_, value_, url_transformer_);
|
|
6139
|
-
else {
|
|
6140
|
-
history.pushState(history.state, "", (0, $46MJV$solidjs.untrack)((0, $46MJV$depictaiutilishared.catchify)(()=>read_link())));
|
|
6141
|
-
scrollTo(0, 0);
|
|
6142
|
-
}
|
|
6143
|
-
set_search_field_value_(value_);
|
|
6144
|
-
after_submit_?.();
|
|
6145
|
-
};
|
|
6146
|
-
return {
|
|
6147
|
-
read_link_: read_link,
|
|
6148
|
-
on_click_handler_: on_click_handler_
|
|
6149
|
-
};
|
|
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
|
+
});
|
|
6150
6493
|
}
|
|
6151
6494
|
|
|
6152
6495
|
|
|
6153
6496
|
|
|
6154
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);
|
|
6155
|
-
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_ }) {
|
|
6156
6499
|
const has_entries = (0, $46MJV$solidjs.createMemo)(()=>previous_searches_().length >= 1);
|
|
6157
6500
|
currently_showing_suggestions_[1]((value)=>{
|
|
6158
6501
|
value[0] = (0, $46MJV$solidjs.createMemo)(()=>previous_searches_().map((result)=>({
|
|
@@ -6178,20 +6521,20 @@ function $d9dab2a87a9fc61a$export$a146ac6fa8346a25({ text_: text_ , previous_sea
|
|
|
6178
6521
|
return previous_searches_();
|
|
6179
6522
|
},
|
|
6180
6523
|
children: (item, index)=>{
|
|
6181
|
-
const
|
|
6182
|
-
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
set_search_field_value_: search_field_value_[1],
|
|
6187
|
-
get_search_query_: get_search_query_,
|
|
6188
|
-
after_submit_: after_submit_,
|
|
6189
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
6190
|
-
}));
|
|
6524
|
+
const href = (0, $41151dd3f5de2c98$export$91c3b6774e8be0f5)({
|
|
6525
|
+
param_: search_query_param_name_,
|
|
6526
|
+
value_: item,
|
|
6527
|
+
url_transformer_: url_transformer_
|
|
6528
|
+
});
|
|
6191
6529
|
return (()=>{
|
|
6192
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;
|
|
6193
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.
|
|
6194
|
-
"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);
|
|
6195
6538
|
(0, $46MJV$solidjsweb.addEventListener)(_el$4, "mouseleave", (0, $46MJV$depictaiutilishared.catchify)(()=>write_selected_index_(undefined)));
|
|
6196
6539
|
(0, $46MJV$solidjsweb.addEventListener)(_el$4, "mouseenter", (0, $46MJV$depictaiutilishared.catchify)(()=>write_selected_index_([
|
|
6197
6540
|
0,
|
|
@@ -6216,7 +6559,7 @@ function $d9dab2a87a9fc61a$export$a146ac6fa8346a25({ text_: text_ , previous_sea
|
|
|
6216
6559
|
})), _el$7);
|
|
6217
6560
|
(0, $46MJV$solidjsweb.insert)(_el$7, (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$depictaiutilishared.CrossIcon), {}));
|
|
6218
6561
|
(0, $46MJV$solidjsweb.effect)((_p$)=>{
|
|
6219
|
-
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_();
|
|
6220
6563
|
_v$ !== _p$._v$ && _el$4.classList.toggle("selected", _p$._v$ = _v$);
|
|
6221
6564
|
_v$2 !== _p$._v$2 && (0, $46MJV$solidjsweb.setAttribute)(_el$4, "href", _p$._v$2 = _v$2);
|
|
6222
6565
|
_v$3 !== _p$._v$3 && (0, $46MJV$solidjsweb.setAttribute)(_el$7, "title", _p$._v$3 = _v$3);
|
|
@@ -6315,41 +6658,34 @@ function $5a0afe153acd45d7$export$ba17c5b7e6dda39f({ whole_text_to_display_: who
|
|
|
6315
6658
|
|
|
6316
6659
|
|
|
6317
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);
|
|
6318
|
-
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_ }) {
|
|
6319
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
|
|
6320
6663
|
));
|
|
6321
6664
|
const not_queries_memo = (0, $46MJV$solidjs.createMemo)(()=>suggestion_memo_().filter(({ type: type })=>type !== (0, $81eea900c72d569b$export$3cf9497e790da491)));
|
|
6322
6665
|
const render_entry = (input_obj, autocomplete_data_index, index, is_history = false)=>{
|
|
6323
6666
|
const is_query = (0, $46MJV$solidjs.createMemo)(()=>input_obj().type === (0, $81eea900c72d569b$export$3cf9497e790da491));
|
|
6324
|
-
const
|
|
6667
|
+
const href_with_changed_params_accessor = (0, $46MJV$solidjs.createMemo)(()=>is_query() ? (0, $41151dd3f5de2c98$export$91c3b6774e8be0f5)({
|
|
6325
6668
|
param_: search_page_url_param_name_,
|
|
6326
|
-
value_: input_obj().title,
|
|
6327
|
-
url_transformer_: url_transformer_
|
|
6328
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
6329
|
-
get_search_query_: get_search_query_,
|
|
6330
|
-
set_search_field_value_: search_field_value_[1],
|
|
6331
|
-
after_submit_: after_submit_,
|
|
6332
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
6669
|
+
value_: (0, $46MJV$solidjs.createMemo)(()=>input_obj().title),
|
|
6670
|
+
url_transformer_: url_transformer_
|
|
6333
6671
|
}) : undefined);
|
|
6334
|
-
const
|
|
6335
|
-
(0, $46MJV$solidjs.createComputed)(()=>{
|
|
6336
|
-
const new_href = is_query() ? param_change_obj().read_link_() : input_obj().page_url;
|
|
6337
|
-
// href will first show up in a tick from input_obj() updating, we don't want to assign undefined in the meantime
|
|
6338
|
-
if (new_href) set_href(new_href);
|
|
6339
|
-
});
|
|
6672
|
+
const href = (0, $46MJV$solidjs.createMemo)(()=>is_query() ? href_with_changed_params_accessor()() : input_obj().page_url);
|
|
6340
6673
|
return (()=>{
|
|
6341
6674
|
const _el$ = $aabe56c678fa29ec$var$_tmpl$.cloneNode(true);
|
|
6342
6675
|
(0, $46MJV$solidjsweb.use)((element)=>element.addEventListener("click", (0, $46MJV$depictaiutilishared.catchify)((ev)=>{
|
|
6343
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.
|
|
6344
|
-
if (is_query())
|
|
6345
|
-
else if (navigate_page_to_href_) {
|
|
6346
|
-
// single page navigate to category suggestions if enabled
|
|
6347
|
-
// object should have a href where we want to go
|
|
6677
|
+
if (is_query()) {
|
|
6348
6678
|
if (ev.button || ev.metaKey || ev.ctrlKey) // not button 0 or cmd/ctrl click
|
|
6349
6679
|
return;
|
|
6350
6680
|
ev.preventDefault();
|
|
6351
|
-
|
|
6681
|
+
submit_query_(input_obj().title);
|
|
6682
|
+
return;
|
|
6352
6683
|
}
|
|
6684
|
+
router_.navigate_.go_to_({
|
|
6685
|
+
new_url_: input_obj().page_url,
|
|
6686
|
+
is_replace_: false,
|
|
6687
|
+
event_: ev
|
|
6688
|
+
});
|
|
6353
6689
|
})), _el$);
|
|
6354
6690
|
(0, $46MJV$solidjsweb.addEventListener)(_el$, "mouseleave", (0, $46MJV$depictaiutilishared.catchify)(()=>write_selected_index_(undefined)));
|
|
6355
6691
|
(0, $46MJV$solidjsweb.addEventListener)(_el$, "mouseenter", (0, $46MJV$depictaiutilishared.catchify)(()=>write_selected_index_([
|
|
@@ -6574,6 +6910,7 @@ function $bc74fbd61efdd8a5$export$217899a935ef803b({ selected_index_: [read_sele
|
|
|
6574
6910
|
}
|
|
6575
6911
|
};
|
|
6576
6912
|
// TODO: if selected item stops existing, remove it
|
|
6913
|
+
// Is above actually not done???
|
|
6577
6914
|
$bc74fbd61efdd8a5$var$actual_navigation_working_on_fake_data({
|
|
6578
6915
|
...rest_of_props,
|
|
6579
6916
|
last_suggestion_index_: last_suggestion_index_,
|
|
@@ -6581,7 +6918,7 @@ function $bc74fbd61efdd8a5$export$217899a935ef803b({ selected_index_: [read_sele
|
|
|
6581
6918
|
write_selected_fake_index_: write_selected_fake_index_
|
|
6582
6919
|
});
|
|
6583
6920
|
}
|
|
6584
|
-
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_ }) {
|
|
6585
6922
|
let previous_value;
|
|
6586
6923
|
(0, $46MJV$solidjs.createEffect)(()=>{
|
|
6587
6924
|
const sfv = get_search_field_value();
|
|
@@ -6619,6 +6956,7 @@ function $bc74fbd61efdd8a5$var$actual_navigation_working_on_fake_data({ element_
|
|
|
6619
6956
|
set_search_field_value(title);
|
|
6620
6957
|
override_on_enter_for_this_entry((e)=>{
|
|
6621
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 ;)
|
|
6622
6960
|
const url = new URL(location);
|
|
6623
6961
|
url_transformer_?.(url);
|
|
6624
6962
|
url.searchParams.set(search_query_param_name_, title);
|
|
@@ -6626,11 +6964,11 @@ function $bc74fbd61efdd8a5$var$actual_navigation_working_on_fake_data({ element_
|
|
|
6626
6964
|
});
|
|
6627
6965
|
} else if (selected_entry?.type == "category") override_on_enter_for_this_entry((e)=>{
|
|
6628
6966
|
const { page_url: page_url } = selected_entry;
|
|
6629
|
-
if (!$bc74fbd61efdd8a5$var$open_link_on_cmd_pressed(e, page_url))
|
|
6630
|
-
|
|
6631
|
-
|
|
6632
|
-
|
|
6633
|
-
}
|
|
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
|
+
});
|
|
6634
6972
|
return true;
|
|
6635
6973
|
});
|
|
6636
6974
|
else if (!selected_entry) {
|
|
@@ -6663,7 +7001,7 @@ function $bc74fbd61efdd8a5$var$open_link_on_cmd_pressed(e, href) {
|
|
|
6663
7001
|
|
|
6664
7002
|
|
|
6665
7003
|
const $81eea900c72d569b$export$3cf9497e790da491 = "query";
|
|
6666
|
-
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_ }) {
|
|
6667
7005
|
const [searching_for_value, set_searching_for_value] = (0, $46MJV$solidjs.createSignal)();
|
|
6668
7006
|
const [read_search_field_value] = search_field_value_;
|
|
6669
7007
|
const updating_blocked = (0, $46MJV$solidjs.createSignal)(false);
|
|
@@ -6706,7 +7044,7 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
|
|
|
6706
7044
|
set_override_on_enter_fn_: set_override_on_enter_fn_,
|
|
6707
7045
|
search_query_param_name_: search_page_url_param_name_,
|
|
6708
7046
|
url_transformer_: url_transformer_,
|
|
6709
|
-
|
|
7047
|
+
router_: router_
|
|
6710
7048
|
});
|
|
6711
7049
|
return [
|
|
6712
7050
|
(0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
@@ -6724,14 +7062,10 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
|
|
|
6724
7062
|
get previous_searches_ () {
|
|
6725
7063
|
return (0, $46MJV$solidjs.createMemo)(()=>filtered_previous_searches().slice(0, 5));
|
|
6726
7064
|
},
|
|
6727
|
-
search_field_value_: search_field_value_,
|
|
6728
7065
|
selected_index_: selected_index_,
|
|
6729
7066
|
currently_showing_suggestions_: currently_showing_suggestions_,
|
|
6730
7067
|
url_transformer_: url_transformer_,
|
|
6731
|
-
|
|
6732
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
6733
|
-
after_submit_: after_submit_,
|
|
6734
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
7068
|
+
submit_query_: submit_query_
|
|
6735
7069
|
});
|
|
6736
7070
|
}
|
|
6737
7071
|
}),
|
|
@@ -6749,18 +7083,14 @@ function $81eea900c72d569b$export$2f2b9559550c7bbc({ search_field_value_: search
|
|
|
6749
7083
|
on_previous_searches_page_: show_previous_searches_component,
|
|
6750
7084
|
i18n_: i18n_,
|
|
6751
7085
|
url_transformer_: url_transformer_,
|
|
6752
|
-
search_field_value_: search_field_value_,
|
|
6753
7086
|
searching_for_value_: searching_for_value,
|
|
6754
7087
|
search_page_url_param_name_: search_page_url_param_name_,
|
|
6755
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
6756
7088
|
selected_index_: selected_index_,
|
|
6757
7089
|
suggestion_memo_: read_suggestion_signal,
|
|
6758
7090
|
currently_showing_suggestions_: currently_showing_suggestions_,
|
|
6759
|
-
get_search_query_: get_search_query_,
|
|
6760
7091
|
include_category_suggestions_: include_category_suggestions_,
|
|
6761
|
-
|
|
6762
|
-
|
|
6763
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
7092
|
+
router_: router_,
|
|
7093
|
+
submit_query_: submit_query_
|
|
6764
7094
|
})
|
|
6765
7095
|
];
|
|
6766
7096
|
}
|
|
@@ -6846,7 +7176,7 @@ function $4a976b492943589f$export$f021bdedd3ec901a(props) {
|
|
|
6846
7176
|
|
|
6847
7177
|
|
|
6848
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);
|
|
6849
|
-
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_ }) {
|
|
6850
7180
|
let on_enter_in_search_field_function;
|
|
6851
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.
|
|
6852
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
|
|
@@ -6860,12 +7190,6 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
|
|
|
6860
7190
|
propagate_search_field_value_back?.();
|
|
6861
7191
|
return props_submit_query(...args);
|
|
6862
7192
|
};
|
|
6863
|
-
const after_submit_ = props_after_submit && ((...args)=>{
|
|
6864
|
-
// This will be called by link_to_param_change when clicking on a suggestion
|
|
6865
|
-
// 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
|
|
6866
|
-
propagate_search_field_value_back?.();
|
|
6867
|
-
return props_after_submit(...args);
|
|
6868
|
-
});
|
|
6869
7193
|
const [input_field, set_input_field] = (0, $46MJV$solidjs.createSignal)();
|
|
6870
7194
|
const [get_search_field_value_] = search_field_value_;
|
|
6871
7195
|
const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $46MJV$solidjs.createSignal)();
|
|
@@ -6888,7 +7212,7 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
|
|
|
6888
7212
|
(matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
|
|
6889
7213
|
(matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((()=>{
|
|
6890
7214
|
const _el$ = $121d25ca6af2898f$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
|
|
6891
|
-
_el$2
|
|
7215
|
+
(0, $46MJV$solidjsweb.addEventListener)(_el$2, "click", (0, $46MJV$depictaiutilishared.catchify)(()=>submit_query_()), true);
|
|
6892
7216
|
(0, $46MJV$solidjsweb.insert)(_el$2, (()=>{
|
|
6893
7217
|
const _c$ = (0, $46MJV$solidjsweb.memo)(()=>!!get_search_field_value_());
|
|
6894
7218
|
return ()=>_c$() ? i18n_.modal_view_all_results_()((()=>{
|
|
@@ -6962,13 +7286,11 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
|
|
|
6962
7286
|
selected_index_: selected_index,
|
|
6963
7287
|
currently_showing_suggestions_: currently_showing_suggestions_,
|
|
6964
7288
|
depict_api_: depict_api_,
|
|
6965
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
6966
7289
|
url_transformer_: url_transformer_,
|
|
6967
7290
|
i18n_: i18n_,
|
|
6968
7291
|
include_category_suggestions_: enable_category_suggestions_ ?? true,
|
|
6969
|
-
|
|
6970
|
-
|
|
6971
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_
|
|
7292
|
+
router_: router_,
|
|
7293
|
+
submit_query_: submit_query_
|
|
6972
7294
|
});
|
|
6973
7295
|
}
|
|
6974
7296
|
}), null);
|
|
@@ -7060,7 +7382,7 @@ function $121d25ca6af2898f$var$close_modal_when_navigating_away(close_modal, sea
|
|
|
7060
7382
|
|
|
7061
7383
|
|
|
7062
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);
|
|
7063
|
-
function $ea038dec4ee16624$export$c05a196222ba1302({ suggestions_: suggestions_ , children: children ,
|
|
7385
|
+
function $ea038dec4ee16624$export$c05a196222ba1302({ suggestions_: suggestions_ , children: children , slider_arrow_button_: slider_arrow_button_ }) {
|
|
7064
7386
|
const category_suggestions_ = (0, $46MJV$solidjs.createMemo)(()=>suggestions_()?.suggestions.filter((s)=>s.type === "category"));
|
|
7065
7387
|
return (0, $46MJV$solidjsweb.createComponent)((0, $46MJV$solidjs.Show), {
|
|
7066
7388
|
get when () {
|
|
@@ -7091,7 +7413,7 @@ function $ea038dec4ee16624$export$c05a196222ba1302({ suggestions_: suggestions_
|
|
|
7091
7413
|
get each () {
|
|
7092
7414
|
return category_suggestions_();
|
|
7093
7415
|
},
|
|
7094
|
-
children: (suggestion, index)=>children(suggestion, index
|
|
7416
|
+
children: (suggestion, index)=>children(suggestion, index)
|
|
7095
7417
|
});
|
|
7096
7418
|
}
|
|
7097
7419
|
});
|
|
@@ -7316,7 +7638,6 @@ function $93779a41dce11249$export$a54ec244c8863715(opts) {
|
|
|
7316
7638
|
message_: "Category suggestions failed",
|
|
7317
7639
|
get children () {
|
|
7318
7640
|
return (0, $46MJV$solidjsweb.createComponent)((0, $ea038dec4ee16624$export$c05a196222ba1302), {
|
|
7319
|
-
selected_filters_: selected_filters_,
|
|
7320
7641
|
suggestions_: suggestions,
|
|
7321
7642
|
slider_arrow_button_: slider_arrow_button_,
|
|
7322
7643
|
children: make_category_suggestion_card_
|
|
@@ -7465,6 +7786,8 @@ function $246e3e89a097f014$export$828dcdd425fd3231(aligner) {
|
|
|
7465
7786
|
}
|
|
7466
7787
|
|
|
7467
7788
|
|
|
7789
|
+
|
|
7790
|
+
|
|
7468
7791
|
const $79fbf145b15af988$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp search"></div>`, 2);
|
|
7469
7792
|
/**
|
|
7470
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.
|
|
@@ -7477,36 +7800,18 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7477
7800
|
#market_signal = (0, $46MJV$solidjs.createSignal)();
|
|
7478
7801
|
#modal_open_signal = (0, $46MJV$solidjs.createSignal)(false);
|
|
7479
7802
|
static #has_been_constructed = false;
|
|
7480
|
-
|
|
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
|
|
7481
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 }){
|
|
7482
7806
|
if ($79fbf145b15af988$export$ac6237957a15b3f0.#has_been_constructed) throw new Error("You can only have one instance of DepictSearch");
|
|
7483
7807
|
Object.assign(this, props_on_class);
|
|
7484
|
-
const
|
|
7485
|
-
const u_o = new URL(absolute_href);
|
|
7486
|
-
const relative_href = u_o.pathname + u_o.search + u_o.hash;
|
|
7487
|
-
// make sure that we don't accidentally catchify if the SDK consumer has fucked up
|
|
7488
|
-
try {
|
|
7489
|
-
return raw_on_navigation(relative_href);
|
|
7490
|
-
} catch (e) {
|
|
7491
|
-
queueMicrotask(()=>{
|
|
7492
|
-
throw e;
|
|
7493
|
-
});
|
|
7494
|
-
}
|
|
7495
|
-
});
|
|
7496
|
-
const alternative_query_submitter_for_spas_ = on_navigation && ((search_param_name, new_search_query, url_transformer)=>{
|
|
7497
|
-
const target_url = new URL(location.href);
|
|
7498
|
-
url_transformer?.(target_url);
|
|
7499
|
-
target_url.searchParams.set(search_param_name, new_search_query);
|
|
7500
|
-
on_navigation(target_url.href);
|
|
7501
|
-
});
|
|
7808
|
+
const { current_sorting_: current_sorting_ , selected_filters_: selected_filters_ } = (0, $004640621ca953d0$export$7bcff1eb3eca57d7)(this.#router);
|
|
7502
7809
|
const [reset_history_state_, state_] = (0, $0de081f67b6d15b5$export$9862539c89138352)(()=>({
|
|
7503
7810
|
search_field_value: new URLSearchParams(location.search).get(search_query_url_param_name) ?? "",
|
|
7504
|
-
search_sorting: undefined,
|
|
7505
7811
|
search_filters_open: false,
|
|
7506
7812
|
search_sorting_open: false,
|
|
7507
7813
|
search_expanded_filters: [],
|
|
7508
|
-
//
|
|
7509
|
-
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
|
|
7510
7815
|
search_local_filter_cache: [],
|
|
7511
7816
|
search_expanded_hierarchical_filters: [],
|
|
7512
7817
|
search_showing_recommendation_rows: (0, $9f81b7ced87aabf2$export$1c8c715550dc689d),
|
|
@@ -7522,24 +7827,27 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7522
7827
|
const [, set_search_showing_recommendation_rows] = state_.search_showing_recommendation_rows;
|
|
7523
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
|
|
7524
7829
|
const on_submit_with_unchanged_value_ = ()=>this.modal_open = false;
|
|
7525
|
-
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)({
|
|
7526
7832
|
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
|
|
7527
|
-
|
|
7833
|
+
set_search_field_value_: set_search_field_value_,
|
|
7528
7834
|
search_query_: search_query_signal_,
|
|
7529
7835
|
search_param_name_: search_query_url_param_name,
|
|
7530
7836
|
url_transformer_: url_transformer,
|
|
7531
|
-
|
|
7532
|
-
|
|
7837
|
+
after_submit_: after_submit_,
|
|
7838
|
+
get_new_query: ()=>new_query || (0, $46MJV$solidjs.untrack)(get_search_field_value_),
|
|
7839
|
+
router_: this.#router
|
|
7533
7840
|
});
|
|
7534
7841
|
const i18n_ = (0, $623202ae203e9e59$export$f091cbac892643a4)(this.#locale_signal[0]);
|
|
7535
7842
|
const clear_filters_on_next_submit_ = (0, $8b282f736ce4f3b8$export$e026af0c7b64ea5f)({
|
|
7536
|
-
selected_filters_:
|
|
7843
|
+
selected_filters_: selected_filters_,
|
|
7537
7844
|
search_query_: search_query_signal_,
|
|
7538
|
-
current_sorting_:
|
|
7845
|
+
current_sorting_: current_sorting_,
|
|
7539
7846
|
expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
|
|
7540
7847
|
i18n_: i18n_,
|
|
7541
7848
|
local_filter_cache_: state_.search_local_filter_cache
|
|
7542
7849
|
});
|
|
7850
|
+
if (on_navigation) this.#router.on_navigation_ = on_navigation;
|
|
7543
7851
|
(0, $46MJV$solidjs.createComputed)(()=>{
|
|
7544
7852
|
const [get_search_query_updating_blocked] = search_query_updating_blocked_;
|
|
7545
7853
|
const [get_raw_search_query_signal] = raw_search_query_signal;
|
|
@@ -7550,7 +7858,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7550
7858
|
search_query_url_param_name_: search_query_url_param_name,
|
|
7551
7859
|
reset_history_state_: reset_history_state_,
|
|
7552
7860
|
state_: state_,
|
|
7553
|
-
|
|
7861
|
+
router_: this.#router,
|
|
7554
7862
|
url_transformer_: url_transformer,
|
|
7555
7863
|
depict_api_: depict_api_,
|
|
7556
7864
|
enable_category_suggestions_: enable_category_suggestions,
|
|
@@ -7558,16 +7866,17 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7558
7866
|
configured_submit_query_: configured_submit_query_,
|
|
7559
7867
|
search_query_signal_: search_query_signal_,
|
|
7560
7868
|
i18n_: i18n_,
|
|
7561
|
-
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_
|
|
7562
7872
|
});
|
|
7563
7873
|
(0, $33815c5a406b6cc0$export$5162a71f252e6122)();
|
|
7564
7874
|
(0, $46MJV$depictaiutilishared.catchify)(async ()=>{
|
|
7565
|
-
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
|
|
7566
7876
|
const { open_modal_: open_modal_ , close_modal_: close_modal_ } = await (0, $089c01924e13fae5$export$79b1565500412d9b)((...args)=>{
|
|
7567
7877
|
(0, $46MJV$solidjs.onCleanup)(()=>this.modal_open = false);
|
|
7568
7878
|
return (0, $121d25ca6af2898f$export$1c593cbd6f1e10bc)(...args);
|
|
7569
7879
|
}, {
|
|
7570
|
-
after_submit_: after_submit_,
|
|
7571
7880
|
search_field_value_: state_.search_field_value,
|
|
7572
7881
|
search_query_: search_query_signal_,
|
|
7573
7882
|
search_page_url_param_name_: search_query_url_param_name,
|
|
@@ -7577,15 +7886,13 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7577
7886
|
clear_filters_: clear_filters_on_next_submit_,
|
|
7578
7887
|
market_: this.#market_signal[0],
|
|
7579
7888
|
submit_query_: configured_submit_query_,
|
|
7580
|
-
alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_,
|
|
7581
7889
|
url_transformer_: url_transformer,
|
|
7582
|
-
|
|
7583
|
-
on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
|
|
7890
|
+
router_: this.#router,
|
|
7584
7891
|
instant_results_options_: {
|
|
7585
7892
|
min_products_to_fetch_: $79fbf145b15af988$var$min_products_to_fetch_,
|
|
7586
7893
|
render_instant_card_: render_instant_card,
|
|
7587
7894
|
render_instant_card_placeholder_: (0, $17c49340edfdbb31$export$ee1733d9a8495996),
|
|
7588
|
-
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]()))
|
|
7589
7896
|
},
|
|
7590
7897
|
i18n_: i18n_,
|
|
7591
7898
|
enable_category_suggestions_: enable_category_suggestions,
|
|
@@ -7594,7 +7901,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7594
7901
|
});
|
|
7595
7902
|
// This will add some default behaviour to open_modal_ if no style_props_ are supplied
|
|
7596
7903
|
// The default behaviour is to align the modal with the input field if possible
|
|
7597
|
-
const
|
|
7904
|
+
const modal_opening_effect = ()=>{
|
|
7598
7905
|
const open_signal_value = this.modal_open;
|
|
7599
7906
|
const signal_value_is_options = Array.isArray(open_signal_value);
|
|
7600
7907
|
// Close modal if signal is false
|
|
@@ -7648,11 +7955,17 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
|
|
|
7648
7955
|
style_props_: style_props_
|
|
7649
7956
|
});
|
|
7650
7957
|
};
|
|
7651
|
-
|
|
7652
|
-
else (0, $46MJV$solidjs.createComputed)(computation);
|
|
7958
|
+
(0, $46MJV$solidjs.runWithOwner)(owner, ()=>(0, $46MJV$solidjs.createEffect)(modal_opening_effect));
|
|
7653
7959
|
})();
|
|
7654
7960
|
$79fbf145b15af988$export$ac6237957a15b3f0.#has_been_constructed = true;
|
|
7655
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
|
+
}
|
|
7656
7969
|
get localization() {
|
|
7657
7970
|
// allow reactive access
|
|
7658
7971
|
return this.#locale_signal[0]();
|
|
@@ -7735,18 +8048,18 @@ function $79fbf145b15af988$export$f2dc7e4e4aa11abb({ depict_search: depict_searc
|
|
|
7735
8048
|
});
|
|
7736
8049
|
});
|
|
7737
8050
|
},
|
|
7738
|
-
current_sorting_:
|
|
8051
|
+
current_sorting_: shared_properties.current_sorting_,
|
|
7739
8052
|
search_filters_open_: state_.search_filters_open,
|
|
7740
8053
|
search_sorting_open_: state_.search_sorting_open,
|
|
7741
8054
|
expanded_filters_: state_.search_expanded_filters,
|
|
7742
8055
|
make_category_suggestion_card_: shared_properties.enable_category_suggestions_ ? (category_suggestion_)=>{
|
|
7743
8056
|
return (0, $67892c03cd3dfa66$export$d757d54550ebfb3d)({
|
|
7744
8057
|
category_suggestion_: category_suggestion_,
|
|
7745
|
-
|
|
8058
|
+
router_: shared_properties.router_
|
|
7746
8059
|
});
|
|
7747
8060
|
} : false,
|
|
7748
8061
|
expanded_hierarchical_filters_: state_.search_expanded_hierarchical_filters,
|
|
7749
|
-
selected_filters_:
|
|
8062
|
+
selected_filters_: shared_properties.selected_filters_,
|
|
7750
8063
|
showing_recommendation_rows_: state_.search_showing_recommendation_rows,
|
|
7751
8064
|
scroll_restoration_data_: state_.search_scroll_restoration_data,
|
|
7752
8065
|
include_input_field_: include_input_field,
|
|
@@ -7929,7 +8242,6 @@ function $308e64f91bb9f839$export$d0596b5cae35ad4(open_search) {
|
|
|
7929
8242
|
|
|
7930
8243
|
|
|
7931
8244
|
|
|
7932
|
-
|
|
7933
8245
|
function $d589470b68ce5b67$export$689e204eadb33baf(pr) {
|
|
7934
8246
|
let old_url;
|
|
7935
8247
|
let disconnect_link_observer;
|
|
@@ -8064,7 +8376,8 @@ class $37e96a5ebc768cc7$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8064
8376
|
}, "failed to open page");
|
|
8065
8377
|
#empty_page_bugfix() {
|
|
8066
8378
|
// Called when a "page" is "opened" using PageReplacer
|
|
8067
|
-
const
|
|
8379
|
+
const on_maybe_popstate = (what_happened)=>{
|
|
8380
|
+
if (what_happened !== "popstate") return;
|
|
8068
8381
|
const cleaned_current_url = $37e96a5ebc768cc7$var$clean_url(location.href);
|
|
8069
8382
|
if (!$37e96a5ebc768cc7$export$3ccaa27d81dd8556.#visited_urls.has(cleaned_current_url)) {
|
|
8070
8383
|
/*
|
|
@@ -8092,8 +8405,8 @@ class $37e96a5ebc768cc7$export$3ccaa27d81dd8556 extends EventTarget {
|
|
|
8092
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.
|
|
8093
8406
|
}
|
|
8094
8407
|
};
|
|
8095
|
-
(0, $46MJV$depictaiutilishared.
|
|
8096
|
-
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
|
|
8097
8410
|
}
|
|
8098
8411
|
/**
|
|
8099
8412
|
* Stops listening to URL changes and closes the page (if it is currently open)
|