@getlupa/vue 0.9.6 → 0.10.0
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/lupaSearch.js +113 -58
- package/dist/lupaSearch.mjs +113 -58
- package/dist/src/constants/queryParams.const.d.ts +2 -6
- package/dist/src/stores/dynamicData.d.ts +4 -1
- package/dist/src/stores/options.d.ts +5 -2
- package/dist/src/stores/screen.d.ts +3 -3
- package/dist/src/types/General.d.ts +2 -0
- package/dist/src/types/search-box/SearchBoxOptions.d.ts +2 -1
- package/dist/src/utils/filter.toggle.utils.d.ts +4 -3
- package/dist/src/utils/link.utils.d.ts +2 -1
- package/dist/src/utils/params.utils.d.ts +3 -2
- package/dist/src/utils/routing.utils.d.ts +2 -1
- package/dist/src/utils/ssr.utils.d.ts +2 -1
- package/package.json +1 -1
package/dist/lupaSearch.js
CHANGED
|
@@ -2248,6 +2248,11 @@ const useOptionsStore = defineStore("options", () => {
|
|
|
2248
2248
|
const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
|
|
2249
2249
|
searchResultInitialFilters.value = initialFilters2;
|
|
2250
2250
|
};
|
|
2251
|
+
const getQueryParamName = (param) => {
|
|
2252
|
+
var _a;
|
|
2253
|
+
const nameMap = searchBoxOptions.value.queryParameterNames;
|
|
2254
|
+
return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
|
|
2255
|
+
};
|
|
2251
2256
|
return {
|
|
2252
2257
|
searchBoxOptions,
|
|
2253
2258
|
searchResultOptions,
|
|
@@ -2262,7 +2267,8 @@ const useOptionsStore = defineStore("options", () => {
|
|
|
2262
2267
|
setSearchBoxOptions,
|
|
2263
2268
|
setTrackingOptions,
|
|
2264
2269
|
setSearchResultOptions,
|
|
2265
|
-
setInitialFilters
|
|
2270
|
+
setInitialFilters,
|
|
2271
|
+
getQueryParamName
|
|
2266
2272
|
};
|
|
2267
2273
|
});
|
|
2268
2274
|
var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
|
|
@@ -2515,9 +2521,14 @@ const parseParam = (key, params) => {
|
|
|
2515
2521
|
return void 0;
|
|
2516
2522
|
}
|
|
2517
2523
|
};
|
|
2518
|
-
const parseRegularKeys = (regularKeys, searchParams) => {
|
|
2524
|
+
const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
|
|
2519
2525
|
const params = /* @__PURE__ */ Object.create({});
|
|
2520
|
-
const keys = reverseKeyValue(
|
|
2526
|
+
const keys = reverseKeyValue({
|
|
2527
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY,
|
|
2528
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.LIMIT) : QUERY_PARAMS.LIMIT,
|
|
2529
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE,
|
|
2530
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.SORT) : QUERY_PARAMS.SORT
|
|
2531
|
+
});
|
|
2521
2532
|
for (const key of regularKeys) {
|
|
2522
2533
|
const rawKey = keys[key] || key;
|
|
2523
2534
|
params[rawKey] = parseParam(key, searchParams);
|
|
@@ -2559,16 +2570,17 @@ const parseFacetKeys = (facetKeys, searchParams) => {
|
|
|
2559
2570
|
}
|
|
2560
2571
|
return params;
|
|
2561
2572
|
};
|
|
2562
|
-
const parseParams = (searchParams) => {
|
|
2573
|
+
const parseParams = (getQueryParamName, searchParams) => {
|
|
2563
2574
|
const params = /* @__PURE__ */ Object.create({});
|
|
2564
2575
|
if (!searchParams)
|
|
2565
2576
|
return params;
|
|
2566
2577
|
const paramKeys = Array.from(searchParams.keys());
|
|
2567
2578
|
const facetKeys = paramKeys.filter((k) => isFacetKey(k));
|
|
2568
2579
|
const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
|
|
2569
|
-
|
|
2580
|
+
const r = __spreadValues(__spreadValues({
|
|
2570
2581
|
[QUERY_PARAMS_PARSED.QUERY]: ""
|
|
2571
|
-
}, parseRegularKeys(regularKeys, searchParams)), parseFacetKeys(facetKeys, searchParams));
|
|
2582
|
+
}, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
|
|
2583
|
+
return r;
|
|
2572
2584
|
};
|
|
2573
2585
|
const appendParam = (url, { name, value }, encode = true) => {
|
|
2574
2586
|
if (Array.isArray(value)) {
|
|
@@ -2589,10 +2601,16 @@ const appendArrayParams = (url, param) => {
|
|
|
2589
2601
|
url.searchParams.delete(param.name);
|
|
2590
2602
|
param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
|
|
2591
2603
|
};
|
|
2592
|
-
const getRemovableParams = (url, paramsToRemove) => {
|
|
2604
|
+
const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
|
|
2593
2605
|
if (paramsToRemove === "all") {
|
|
2606
|
+
const params = {
|
|
2607
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY,
|
|
2608
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.LIMIT) : QUERY_PARAMS.LIMIT,
|
|
2609
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE,
|
|
2610
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.SORT) : QUERY_PARAMS.SORT
|
|
2611
|
+
};
|
|
2594
2612
|
return [
|
|
2595
|
-
...Object.values(
|
|
2613
|
+
...Object.values(params),
|
|
2596
2614
|
...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
|
|
2597
2615
|
];
|
|
2598
2616
|
}
|
|
@@ -2623,12 +2641,12 @@ const generateLink = (linkPattern, document2) => {
|
|
|
2623
2641
|
}
|
|
2624
2642
|
return link;
|
|
2625
2643
|
};
|
|
2626
|
-
const generateResultLink = (link, searchText, facet) => {
|
|
2644
|
+
const generateResultLink = (link, getQueryParamName, searchText, facet) => {
|
|
2627
2645
|
if (!searchText) {
|
|
2628
2646
|
return link;
|
|
2629
2647
|
}
|
|
2630
2648
|
const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
|
|
2631
|
-
const queryParam = `?${QUERY_PARAMS.QUERY}=${encodeParam(searchText)}`;
|
|
2649
|
+
const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY}=${encodeParam(searchText)}`;
|
|
2632
2650
|
return `${link}${queryParam}${facetParam}`;
|
|
2633
2651
|
};
|
|
2634
2652
|
const getRelativePath = (link) => {
|
|
@@ -2657,8 +2675,8 @@ const handleRoutingEvent = (link, event, hasEventRouting = false) => {
|
|
|
2657
2675
|
event == null ? void 0 : event.preventDefault();
|
|
2658
2676
|
emitRoutingEvent(link);
|
|
2659
2677
|
};
|
|
2660
|
-
const redirectToResultsPage = (link, searchText, facet, routingBehavior = "direct-link") => {
|
|
2661
|
-
const url = generateResultLink(link, searchText, facet);
|
|
2678
|
+
const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
|
|
2679
|
+
const url = generateResultLink(link, getQueryParamName, searchText, facet);
|
|
2662
2680
|
if (routingBehavior === "event") {
|
|
2663
2681
|
emitRoutingEvent(url);
|
|
2664
2682
|
} else {
|
|
@@ -2683,15 +2701,15 @@ const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
|
|
|
2683
2701
|
value
|
|
2684
2702
|
};
|
|
2685
2703
|
};
|
|
2686
|
-
const toggleTermFilter = (appendParams, facetAction, currentFilters) => {
|
|
2704
|
+
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
2687
2705
|
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
2688
2706
|
const newParams = toggleTermParam(currentFilter, facetAction.value);
|
|
2689
2707
|
appendParams({
|
|
2690
2708
|
params: [getFacetParam(facetAction.key, newParams)],
|
|
2691
|
-
paramsToRemove: [QUERY_PARAMS.PAGE]
|
|
2709
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
|
|
2692
2710
|
});
|
|
2693
2711
|
};
|
|
2694
|
-
const toggleHierarchyFilter = (appendParams, facetAction, currentFilters, removeAllLevels = false) => {
|
|
2712
|
+
const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
|
|
2695
2713
|
var _a;
|
|
2696
2714
|
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
2697
2715
|
const newParams = toggleHierarchyParam(
|
|
@@ -2701,10 +2719,10 @@ const toggleHierarchyFilter = (appendParams, facetAction, currentFilters, remove
|
|
|
2701
2719
|
);
|
|
2702
2720
|
appendParams({
|
|
2703
2721
|
params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
|
|
2704
|
-
paramsToRemove: [QUERY_PARAMS.PAGE]
|
|
2722
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
|
|
2705
2723
|
});
|
|
2706
2724
|
};
|
|
2707
|
-
const toggleRangeFilter = (appendParams, facetAction, currentFilters) => {
|
|
2725
|
+
const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
2708
2726
|
const currentFilter = rangeFilterToString(
|
|
2709
2727
|
currentFilters == null ? void 0 : currentFilters[facetAction.key],
|
|
2710
2728
|
FACET_RANGE_SEPARATOR
|
|
@@ -2713,7 +2731,7 @@ const toggleRangeFilter = (appendParams, facetAction, currentFilters) => {
|
|
|
2713
2731
|
facetValue = currentFilter === facetValue ? "" : facetValue;
|
|
2714
2732
|
appendParams({
|
|
2715
2733
|
params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
|
|
2716
|
-
paramsToRemove: [QUERY_PARAMS.PAGE],
|
|
2734
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE],
|
|
2717
2735
|
encode: false
|
|
2718
2736
|
});
|
|
2719
2737
|
};
|
|
@@ -2842,7 +2860,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2842
2860
|
const navigate = (url) => {
|
|
2843
2861
|
var _a, _b, _c;
|
|
2844
2862
|
window.history.pushState("", "Append params", url.pathname + url.search);
|
|
2845
|
-
const params2 = parseParams(url.searchParams);
|
|
2863
|
+
const params2 = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
2846
2864
|
(_c = (_b = (_a = optionsStore == null ? void 0 : optionsStore.searchBoxOptions) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onSearchResultsNavigate) == null ? void 0 : _c.call(_b, {
|
|
2847
2865
|
params: params2
|
|
2848
2866
|
});
|
|
@@ -2860,7 +2878,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2860
2878
|
const paramsToRemove = Array.from(url.searchParams.keys()).filter(isFacetKey);
|
|
2861
2879
|
removeParams(url, paramsToRemove);
|
|
2862
2880
|
navigate(url);
|
|
2863
|
-
params.value = parseParams(url.searchParams);
|
|
2881
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
2864
2882
|
searchString.value = url.search;
|
|
2865
2883
|
};
|
|
2866
2884
|
const removeParameters = ({
|
|
@@ -2868,13 +2886,13 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2868
2886
|
save = true
|
|
2869
2887
|
}) => {
|
|
2870
2888
|
const url = getPageUrl();
|
|
2871
|
-
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
2889
|
+
paramsToRemove = getRemovableParams(url, optionsStore.getQueryParamName, paramsToRemove);
|
|
2872
2890
|
removeParams(url, paramsToRemove);
|
|
2873
2891
|
navigate(url);
|
|
2874
2892
|
if (!save) {
|
|
2875
2893
|
return;
|
|
2876
2894
|
}
|
|
2877
|
-
params.value = parseParams(url.searchParams);
|
|
2895
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
2878
2896
|
searchString.value = url.search;
|
|
2879
2897
|
};
|
|
2880
2898
|
const handleNoResultsFlag = ({
|
|
@@ -2916,13 +2934,22 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2916
2934
|
})
|
|
2917
2935
|
] : [];
|
|
2918
2936
|
appendParams({
|
|
2919
|
-
params: [
|
|
2937
|
+
params: [
|
|
2938
|
+
{ name: optionsStore.getQueryParamName(QUERY_PARAMS.QUERY), value: searchText },
|
|
2939
|
+
...facetParam
|
|
2940
|
+
],
|
|
2920
2941
|
paramsToRemove: "all",
|
|
2921
2942
|
searchResultsLink: searchResultsLink.value
|
|
2922
2943
|
});
|
|
2923
2944
|
} else {
|
|
2924
2945
|
const routing = (_a = optionsStore.boxRoutingBehavior) != null ? _a : "direct-link";
|
|
2925
|
-
redirectToResultsPage(
|
|
2946
|
+
redirectToResultsPage(
|
|
2947
|
+
searchResultsLink.value,
|
|
2948
|
+
searchText,
|
|
2949
|
+
optionsStore.getQueryParamName,
|
|
2950
|
+
facet,
|
|
2951
|
+
routing
|
|
2952
|
+
);
|
|
2926
2953
|
}
|
|
2927
2954
|
};
|
|
2928
2955
|
const appendParams = ({
|
|
@@ -2936,14 +2963,14 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2936
2963
|
return { params: params.value };
|
|
2937
2964
|
}
|
|
2938
2965
|
const url = getPageUrl(searchResultsLink2);
|
|
2939
|
-
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
2966
|
+
paramsToRemove = getRemovableParams(url, optionsStore.getQueryParamName, paramsToRemove);
|
|
2940
2967
|
removeParams(url, paramsToRemove);
|
|
2941
2968
|
newParams.forEach((p2) => appendParam(url, p2, encode));
|
|
2942
2969
|
navigate(url);
|
|
2943
2970
|
if (!save) {
|
|
2944
2971
|
return;
|
|
2945
2972
|
}
|
|
2946
|
-
params.value = parseParams(url.searchParams);
|
|
2973
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
2947
2974
|
searchString.value = url.search;
|
|
2948
2975
|
};
|
|
2949
2976
|
const setDefaultLimit = (newDefaultLimit) => {
|
|
@@ -3678,8 +3705,9 @@ const _sfc_main$1e = /* @__PURE__ */ vue.defineComponent({
|
|
|
3678
3705
|
const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
3679
3706
|
const loading = vue.ref(false);
|
|
3680
3707
|
const dynamicDataIdMap = vue.ref({});
|
|
3708
|
+
const loadingIds = vue.ref({});
|
|
3681
3709
|
const optionsStore = useOptionsStore();
|
|
3682
|
-
|
|
3710
|
+
vue.computed(() => Object.keys(dynamicDataIdMap.value));
|
|
3683
3711
|
const searchResultOptions = vue.computed(() => optionsStore.searchResultOptions);
|
|
3684
3712
|
const searchBoxOptions = vue.computed(() => optionsStore.searchBoxOptions);
|
|
3685
3713
|
const dynamicSearchResultData = vue.computed(() => {
|
|
@@ -3719,11 +3747,12 @@ const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
|
3719
3747
|
const similarQueryResultIds = (_e = (_d = (_c = result.similarQueries) == null ? void 0 : _c.map((q) => q.items.map((i) => i.id))) == null ? void 0 : _d.flat()) != null ? _e : [];
|
|
3720
3748
|
let requestedIds = [...resultIds, ...similarQueryResultIds];
|
|
3721
3749
|
if (isCacheEnabled.value) {
|
|
3722
|
-
requestedIds = requestedIds.filter((i) => !
|
|
3750
|
+
requestedIds = requestedIds.filter((i) => !dynamicDataIdMap.value[`${i}`]);
|
|
3723
3751
|
}
|
|
3724
3752
|
if (!requestedIds.length) {
|
|
3725
3753
|
return;
|
|
3726
3754
|
}
|
|
3755
|
+
loadingIds.value = requestedIds.reduce((a, c2) => __spreadProps(__spreadValues({}, a), { [c2]: true }), {});
|
|
3727
3756
|
loading.value = true;
|
|
3728
3757
|
try {
|
|
3729
3758
|
const dynamicData = dynamicSearchResultData.value || dynamicSearchBoxData.value;
|
|
@@ -3733,15 +3762,16 @@ const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
|
3733
3762
|
const dynamicDataResult = (_f = yield dynamicData == null ? void 0 : dynamicData.handler(requestedIds)) != null ? _f : [];
|
|
3734
3763
|
const seed = {};
|
|
3735
3764
|
const dynamicDataIdMapValue = dynamicDataResult.reduce(
|
|
3736
|
-
(a, c2) => __spreadProps(__spreadValues({}, a), { [c2.id]: c2 }),
|
|
3765
|
+
(a, c2) => __spreadProps(__spreadValues({}, a), { [`${c2.id}`]: c2 }),
|
|
3737
3766
|
seed
|
|
3738
3767
|
);
|
|
3739
3768
|
dynamicDataIdMap.value = __spreadValues(__spreadValues({}, dynamicDataIdMap.value), dynamicDataIdMapValue);
|
|
3740
3769
|
} finally {
|
|
3741
3770
|
loading.value = false;
|
|
3771
|
+
loadingIds.value = {};
|
|
3742
3772
|
}
|
|
3743
3773
|
});
|
|
3744
|
-
return { dynamicDataIdMap, loading, enhanceSearchResultsWithDynamicData };
|
|
3774
|
+
return { dynamicDataIdMap, loading, loadingIds, enhanceSearchResultsWithDynamicData };
|
|
3745
3775
|
});
|
|
3746
3776
|
const joinUrlParts = (...parts) => {
|
|
3747
3777
|
var _a, _b, _c;
|
|
@@ -4259,7 +4289,7 @@ const _sfc_main$14 = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadV
|
|
|
4259
4289
|
setup(__props) {
|
|
4260
4290
|
const props = __props;
|
|
4261
4291
|
const dynamicDataStore = useDynamicDataStore();
|
|
4262
|
-
const { loading, dynamicDataIdMap } = storeToRefs(dynamicDataStore);
|
|
4292
|
+
const { loading, loadingIds, dynamicDataIdMap } = storeToRefs(dynamicDataStore);
|
|
4263
4293
|
const elementComponent = vue.computed(() => {
|
|
4264
4294
|
switch (props.element.type) {
|
|
4265
4295
|
case DocumentElementType.IMAGE:
|
|
@@ -4284,9 +4314,6 @@ const _sfc_main$14 = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadV
|
|
|
4284
4314
|
const displayElement = vue.computed(() => {
|
|
4285
4315
|
return props.element.display ? props.element.display(props.item) : true;
|
|
4286
4316
|
});
|
|
4287
|
-
const isLoadingDynamicData = vue.computed(() => {
|
|
4288
|
-
return Boolean(props.element.dynamic && loading.value);
|
|
4289
|
-
});
|
|
4290
4317
|
const enhancedItem = vue.computed(() => {
|
|
4291
4318
|
var _a, _b, _c, _d;
|
|
4292
4319
|
if (!((_a = props.item) == null ? void 0 : _a.id)) {
|
|
@@ -4295,13 +4322,17 @@ const _sfc_main$14 = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadV
|
|
|
4295
4322
|
const enhancementData = (_d = (_c = dynamicDataIdMap.value) == null ? void 0 : _c[(_b = props.item) == null ? void 0 : _b.id]) != null ? _d : {};
|
|
4296
4323
|
return __spreadValues(__spreadValues({}, props.item), enhancementData);
|
|
4297
4324
|
});
|
|
4325
|
+
const isLoadingDynamicData = (id) => {
|
|
4326
|
+
return Boolean(props.element.dynamic && id && loading.value && (loadingIds == null ? void 0 : loadingIds.value[id]));
|
|
4327
|
+
};
|
|
4298
4328
|
return (_ctx, _cache) => {
|
|
4329
|
+
var _a;
|
|
4299
4330
|
return displayElement.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(elementComponent.value), {
|
|
4300
4331
|
key: 0,
|
|
4301
4332
|
item: enhancedItem.value,
|
|
4302
4333
|
options: _ctx.element,
|
|
4303
4334
|
labels: _ctx.labels,
|
|
4304
|
-
class: vue.normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData.
|
|
4335
|
+
class: vue.normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData((_a = _ctx.item) == null ? void 0 : _a.id) }),
|
|
4305
4336
|
inStock: _ctx.isInStock
|
|
4306
4337
|
}, null, 8, ["item", "options", "labels", "class", "inStock"])) : vue.createCommentVNode("", true);
|
|
4307
4338
|
};
|
|
@@ -5312,11 +5343,11 @@ const getSearchParams = (url, params, baseUrl) => {
|
|
|
5312
5343
|
}
|
|
5313
5344
|
return searchParams;
|
|
5314
5345
|
};
|
|
5315
|
-
const getInitialSearchResults = (options, defaultData) => __async(exports, null, function* () {
|
|
5346
|
+
const getInitialSearchResults = (options, getQueryParamName, defaultData) => __async(exports, null, function* () {
|
|
5316
5347
|
var _a, _b, _c;
|
|
5317
5348
|
const searchParams = getSearchParams((_a = options.ssr) == null ? void 0 : _a.url, void 0, (_b = options.ssr) == null ? void 0 : _b.baseUrl);
|
|
5318
5349
|
const publicQuery = createPublicQuery(
|
|
5319
|
-
parseParams(searchParams),
|
|
5350
|
+
parseParams(getQueryParamName, searchParams),
|
|
5320
5351
|
options.sort,
|
|
5321
5352
|
defaultData == null ? void 0 : defaultData.pageSize
|
|
5322
5353
|
);
|
|
@@ -5546,6 +5577,7 @@ const _sfc_main$V = /* @__PURE__ */ vue.defineComponent({
|
|
|
5546
5577
|
setup(__props) {
|
|
5547
5578
|
const isOpen = vue.ref(false);
|
|
5548
5579
|
const paramsStore = useParamsStore();
|
|
5580
|
+
const optionStore = useOptionsStore();
|
|
5549
5581
|
const searchResultStore = useSearchResultStore();
|
|
5550
5582
|
const { filters, displayFilters, currentFilterCount } = storeToRefs(searchResultStore);
|
|
5551
5583
|
const currentFilters = vue.computed(() => filters.value);
|
|
@@ -5563,6 +5595,7 @@ const _sfc_main$V = /* @__PURE__ */ vue.defineComponent({
|
|
|
5563
5595
|
// TODO: Fix any
|
|
5564
5596
|
paramsStore.appendParams,
|
|
5565
5597
|
{ type: "terms", value: filter.value, key: filter.key },
|
|
5598
|
+
optionStore.getQueryParamName,
|
|
5566
5599
|
currentFilters.value
|
|
5567
5600
|
);
|
|
5568
5601
|
break;
|
|
@@ -5570,13 +5603,17 @@ const _sfc_main$V = /* @__PURE__ */ vue.defineComponent({
|
|
|
5570
5603
|
toggleHierarchyFilter(
|
|
5571
5604
|
paramsStore.appendParams,
|
|
5572
5605
|
{ type: "hierarchy", value: filter.value, key: filter.key },
|
|
5606
|
+
optionStore.getQueryParamName,
|
|
5573
5607
|
currentFilters.value,
|
|
5574
5608
|
true
|
|
5575
5609
|
);
|
|
5576
5610
|
break;
|
|
5577
5611
|
case "range":
|
|
5578
5612
|
paramsStore.removeParameters({
|
|
5579
|
-
paramsToRemove: [
|
|
5613
|
+
paramsToRemove: [
|
|
5614
|
+
optionStore.getQueryParamName(QUERY_PARAMS.PAGE),
|
|
5615
|
+
`${FACET_PARAMS_TYPE.RANGE}${filter.key}`
|
|
5616
|
+
]
|
|
5580
5617
|
});
|
|
5581
5618
|
break;
|
|
5582
5619
|
}
|
|
@@ -7578,13 +7615,28 @@ const _sfc_main$M = /* @__PURE__ */ vue.defineComponent({
|
|
|
7578
7615
|
const handleFacetSelect = (facetAction) => {
|
|
7579
7616
|
switch (facetAction.type) {
|
|
7580
7617
|
case "terms":
|
|
7581
|
-
toggleTermFilter(
|
|
7618
|
+
toggleTermFilter(
|
|
7619
|
+
paramStore.appendParams,
|
|
7620
|
+
facetAction,
|
|
7621
|
+
optionsStore.getQueryParamName,
|
|
7622
|
+
filters.value
|
|
7623
|
+
);
|
|
7582
7624
|
break;
|
|
7583
7625
|
case "range":
|
|
7584
|
-
toggleRangeFilter(
|
|
7626
|
+
toggleRangeFilter(
|
|
7627
|
+
paramStore.appendParams,
|
|
7628
|
+
facetAction,
|
|
7629
|
+
optionsStore.getQueryParamName,
|
|
7630
|
+
filters.value
|
|
7631
|
+
);
|
|
7585
7632
|
break;
|
|
7586
7633
|
case "hierarchy":
|
|
7587
|
-
toggleHierarchyFilter(
|
|
7634
|
+
toggleHierarchyFilter(
|
|
7635
|
+
paramStore.appendParams,
|
|
7636
|
+
facetAction,
|
|
7637
|
+
optionsStore.getQueryParamName,
|
|
7638
|
+
filters.value
|
|
7639
|
+
);
|
|
7588
7640
|
break;
|
|
7589
7641
|
}
|
|
7590
7642
|
if (scrollToResultsOptions.value.enabled) {
|
|
@@ -7951,7 +8003,7 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
|
|
|
7951
8003
|
const handlePageChange = (page) => {
|
|
7952
8004
|
if (page > 0) {
|
|
7953
8005
|
paramStore.appendParams({
|
|
7954
|
-
params: [{ name: QUERY_PARAMS.PAGE, value: page.toString() }]
|
|
8006
|
+
params: [{ name: optionsStore.getQueryParamName(QUERY_PARAMS.PAGE), value: page.toString() }]
|
|
7955
8007
|
});
|
|
7956
8008
|
if (scrollToResultsOptions.value.enabled) {
|
|
7957
8009
|
scrollToSearchResults(
|
|
@@ -8021,12 +8073,13 @@ const _sfc_main$E = /* @__PURE__ */ vue.defineComponent({
|
|
|
8021
8073
|
},
|
|
8022
8074
|
setup(__props) {
|
|
8023
8075
|
const paramsStore = useParamsStore();
|
|
8076
|
+
const optionsStore = useOptionsStore();
|
|
8024
8077
|
const select = vue.ref(null);
|
|
8025
8078
|
const handleSelect = (e) => {
|
|
8026
8079
|
const value = e.target.value;
|
|
8027
8080
|
paramsStore.appendParams({
|
|
8028
|
-
params: [{ name: QUERY_PARAMS.LIMIT, value }],
|
|
8029
|
-
paramsToRemove: [QUERY_PARAMS.PAGE]
|
|
8081
|
+
params: [{ name: optionsStore.getQueryParamName(QUERY_PARAMS.LIMIT), value }],
|
|
8082
|
+
paramsToRemove: [optionsStore.getQueryParamName(QUERY_PARAMS.PAGE)]
|
|
8030
8083
|
});
|
|
8031
8084
|
};
|
|
8032
8085
|
return (_ctx, _cache) => {
|
|
@@ -8067,6 +8120,7 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
8067
8120
|
setup(__props) {
|
|
8068
8121
|
const props = __props;
|
|
8069
8122
|
const paramStore = useParamsStore();
|
|
8123
|
+
const optionStore = useOptionsStore();
|
|
8070
8124
|
const { sort } = storeToRefs(paramStore);
|
|
8071
8125
|
const selectedKey = vue.ref("");
|
|
8072
8126
|
const previousKey = vue.ref("");
|
|
@@ -8100,8 +8154,8 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
8100
8154
|
paramStore.setSortSettings({ selectedSortKey: value, previousSortKey: previousKey.value });
|
|
8101
8155
|
(_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value, previousSortKey: previousKey.value });
|
|
8102
8156
|
paramStore.appendParams({
|
|
8103
|
-
params: [{ name: QUERY_PARAMS.SORT, value }],
|
|
8104
|
-
paramsToRemove: [QUERY_PARAMS.PAGE]
|
|
8157
|
+
params: [{ name: optionStore.getQueryParamName(QUERY_PARAMS.SORT), value }],
|
|
8158
|
+
paramsToRemove: [optionStore.getQueryParamName(QUERY_PARAMS.PAGE)]
|
|
8105
8159
|
});
|
|
8106
8160
|
previousKey.value = selectedKey.value;
|
|
8107
8161
|
};
|
|
@@ -8959,7 +9013,7 @@ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
8959
9013
|
setup(__props, { emit }) {
|
|
8960
9014
|
const props = __props;
|
|
8961
9015
|
const dynamicDataStore = useDynamicDataStore();
|
|
8962
|
-
const { dynamicDataIdMap, loading } = storeToRefs(dynamicDataStore);
|
|
9016
|
+
const { dynamicDataIdMap, loadingIds, loading } = storeToRefs(dynamicDataStore);
|
|
8963
9017
|
const elementComponent = vue.computed(() => {
|
|
8964
9018
|
switch (props.element.type) {
|
|
8965
9019
|
case DocumentElementType.IMAGE:
|
|
@@ -8985,9 +9039,6 @@ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
8985
9039
|
}
|
|
8986
9040
|
return "searchResultsProductTitle";
|
|
8987
9041
|
});
|
|
8988
|
-
const isLoadingDynamicData = vue.computed(() => {
|
|
8989
|
-
return Boolean(props.element.dynamic && loading.value);
|
|
8990
|
-
});
|
|
8991
9042
|
const enhancedItem = vue.computed(() => {
|
|
8992
9043
|
var _a, _b, _c, _d;
|
|
8993
9044
|
if (!((_a = props.item) == null ? void 0 : _a.id)) {
|
|
@@ -9002,7 +9053,11 @@ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
9002
9053
|
const handleProductEvent = (item) => {
|
|
9003
9054
|
emit("productEvent", item);
|
|
9004
9055
|
};
|
|
9056
|
+
const isLoadingDynamicData = (id) => {
|
|
9057
|
+
return Boolean(props.element.dynamic && id && loading.value && (loadingIds == null ? void 0 : loadingIds.value[id]));
|
|
9058
|
+
};
|
|
9005
9059
|
return (_ctx, _cache) => {
|
|
9060
|
+
var _a;
|
|
9006
9061
|
return displayElement.value ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(elementComponent.value), {
|
|
9007
9062
|
key: 0,
|
|
9008
9063
|
item: enhancedItem.value,
|
|
@@ -9010,7 +9065,7 @@ const _sfc_main$l = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
9010
9065
|
labels: _ctx.labels,
|
|
9011
9066
|
inStock: _ctx.inStock,
|
|
9012
9067
|
link: _ctx.link,
|
|
9013
|
-
class: vue.normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData.
|
|
9068
|
+
class: vue.normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData((_a = _ctx.item) == null ? void 0 : _a.id) }),
|
|
9014
9069
|
onProductEvent: handleProductEvent
|
|
9015
9070
|
}, null, 40, ["item", "options", "labels", "inStock", "link", "class"])) : vue.createCommentVNode("", true);
|
|
9016
9071
|
};
|
|
@@ -9537,7 +9592,7 @@ const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
|
|
|
9537
9592
|
const props = __props;
|
|
9538
9593
|
const searchResultStore = useSearchResultStore();
|
|
9539
9594
|
const paramStore = useParamsStore();
|
|
9540
|
-
useOptionsStore();
|
|
9595
|
+
const optionStore = useOptionsStore();
|
|
9541
9596
|
const {
|
|
9542
9597
|
hasResults,
|
|
9543
9598
|
currentQueryText,
|
|
@@ -9621,7 +9676,7 @@ const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
|
|
|
9621
9676
|
};
|
|
9622
9677
|
const goToFirstPage = () => {
|
|
9623
9678
|
paramStore.appendParams({
|
|
9624
|
-
params: [{ name: QUERY_PARAMS.PAGE, value: "1" }]
|
|
9679
|
+
params: [{ name: optionStore.getQueryParamName(QUERY_PARAMS.PAGE), value: "1" }]
|
|
9625
9680
|
});
|
|
9626
9681
|
};
|
|
9627
9682
|
return (_ctx, _cache) => {
|
|
@@ -9827,7 +9882,7 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
9827
9882
|
const handlePopState = () => {
|
|
9828
9883
|
var _a;
|
|
9829
9884
|
const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
|
|
9830
|
-
paramStore.add(parseParams(searchParams));
|
|
9885
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, searchParams));
|
|
9831
9886
|
};
|
|
9832
9887
|
vue.onMounted(() => __async(this, null, function* () {
|
|
9833
9888
|
var _a, _b;
|
|
@@ -9927,7 +9982,7 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
9927
9982
|
var _a;
|
|
9928
9983
|
const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url, params);
|
|
9929
9984
|
const publicQuery = createPublicQuery(
|
|
9930
|
-
parseParams(searchParams),
|
|
9985
|
+
parseParams(optionStore.getQueryParamName, searchParams),
|
|
9931
9986
|
props.options.sort,
|
|
9932
9987
|
defaultSearchResultPageSize.value
|
|
9933
9988
|
);
|
|
@@ -9947,10 +10002,10 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
9947
10002
|
}
|
|
9948
10003
|
}
|
|
9949
10004
|
const params = new URLSearchParams(window.location.search);
|
|
9950
|
-
if (!params.has(QUERY_PARAMS.QUERY) && !props.initialData) {
|
|
10005
|
+
if (!params.has(optionStore.getQueryParamName(QUERY_PARAMS.QUERY)) && !props.initialData) {
|
|
9951
10006
|
handleUrlChange(params);
|
|
9952
10007
|
}
|
|
9953
|
-
paramStore.add(parseParams(params));
|
|
10008
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, params));
|
|
9954
10009
|
paramStore.setDefaultLimit(defaultSearchResultPageSize.value);
|
|
9955
10010
|
};
|
|
9956
10011
|
vue.watch(searchString, () => handleParamsChange());
|
|
@@ -9984,7 +10039,7 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
9984
10039
|
);
|
|
9985
10040
|
optionStore.setSearchResultOptions({ options: props.options });
|
|
9986
10041
|
searchResultStore.add(__spreadValues({}, initialData));
|
|
9987
|
-
paramStore.add(parseParams(searchParams), props.options.ssr);
|
|
10042
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, searchParams), props.options.ssr);
|
|
9988
10043
|
paramStore.setDefaultLimit(defaultSearchResultPageSize.value);
|
|
9989
10044
|
handleResults({ queryKey: props.options.queryKey, results: initialData });
|
|
9990
10045
|
}
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -2246,6 +2246,11 @@ const useOptionsStore = defineStore("options", () => {
|
|
|
2246
2246
|
const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
|
|
2247
2247
|
searchResultInitialFilters.value = initialFilters2;
|
|
2248
2248
|
};
|
|
2249
|
+
const getQueryParamName = (param) => {
|
|
2250
|
+
var _a;
|
|
2251
|
+
const nameMap = searchBoxOptions.value.queryParameterNames;
|
|
2252
|
+
return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
|
|
2253
|
+
};
|
|
2249
2254
|
return {
|
|
2250
2255
|
searchBoxOptions,
|
|
2251
2256
|
searchResultOptions,
|
|
@@ -2260,7 +2265,8 @@ const useOptionsStore = defineStore("options", () => {
|
|
|
2260
2265
|
setSearchBoxOptions,
|
|
2261
2266
|
setTrackingOptions,
|
|
2262
2267
|
setSearchResultOptions,
|
|
2263
|
-
setInitialFilters
|
|
2268
|
+
setInitialFilters,
|
|
2269
|
+
getQueryParamName
|
|
2264
2270
|
};
|
|
2265
2271
|
});
|
|
2266
2272
|
var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
|
|
@@ -2513,9 +2519,14 @@ const parseParam = (key, params) => {
|
|
|
2513
2519
|
return void 0;
|
|
2514
2520
|
}
|
|
2515
2521
|
};
|
|
2516
|
-
const parseRegularKeys = (regularKeys, searchParams) => {
|
|
2522
|
+
const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
|
|
2517
2523
|
const params = /* @__PURE__ */ Object.create({});
|
|
2518
|
-
const keys = reverseKeyValue(
|
|
2524
|
+
const keys = reverseKeyValue({
|
|
2525
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY,
|
|
2526
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.LIMIT) : QUERY_PARAMS.LIMIT,
|
|
2527
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE,
|
|
2528
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.SORT) : QUERY_PARAMS.SORT
|
|
2529
|
+
});
|
|
2519
2530
|
for (const key of regularKeys) {
|
|
2520
2531
|
const rawKey = keys[key] || key;
|
|
2521
2532
|
params[rawKey] = parseParam(key, searchParams);
|
|
@@ -2557,16 +2568,17 @@ const parseFacetKeys = (facetKeys, searchParams) => {
|
|
|
2557
2568
|
}
|
|
2558
2569
|
return params;
|
|
2559
2570
|
};
|
|
2560
|
-
const parseParams = (searchParams) => {
|
|
2571
|
+
const parseParams = (getQueryParamName, searchParams) => {
|
|
2561
2572
|
const params = /* @__PURE__ */ Object.create({});
|
|
2562
2573
|
if (!searchParams)
|
|
2563
2574
|
return params;
|
|
2564
2575
|
const paramKeys = Array.from(searchParams.keys());
|
|
2565
2576
|
const facetKeys = paramKeys.filter((k) => isFacetKey(k));
|
|
2566
2577
|
const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
|
|
2567
|
-
|
|
2578
|
+
const r = __spreadValues(__spreadValues({
|
|
2568
2579
|
[QUERY_PARAMS_PARSED.QUERY]: ""
|
|
2569
|
-
}, parseRegularKeys(regularKeys, searchParams)), parseFacetKeys(facetKeys, searchParams));
|
|
2580
|
+
}, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
|
|
2581
|
+
return r;
|
|
2570
2582
|
};
|
|
2571
2583
|
const appendParam = (url, { name, value }, encode = true) => {
|
|
2572
2584
|
if (Array.isArray(value)) {
|
|
@@ -2587,10 +2599,16 @@ const appendArrayParams = (url, param) => {
|
|
|
2587
2599
|
url.searchParams.delete(param.name);
|
|
2588
2600
|
param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
|
|
2589
2601
|
};
|
|
2590
|
-
const getRemovableParams = (url, paramsToRemove) => {
|
|
2602
|
+
const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
|
|
2591
2603
|
if (paramsToRemove === "all") {
|
|
2604
|
+
const params = {
|
|
2605
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY,
|
|
2606
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.LIMIT) : QUERY_PARAMS.LIMIT,
|
|
2607
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE,
|
|
2608
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS.SORT) : QUERY_PARAMS.SORT
|
|
2609
|
+
};
|
|
2592
2610
|
return [
|
|
2593
|
-
...Object.values(
|
|
2611
|
+
...Object.values(params),
|
|
2594
2612
|
...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
|
|
2595
2613
|
];
|
|
2596
2614
|
}
|
|
@@ -2621,12 +2639,12 @@ const generateLink = (linkPattern, document2) => {
|
|
|
2621
2639
|
}
|
|
2622
2640
|
return link;
|
|
2623
2641
|
};
|
|
2624
|
-
const generateResultLink = (link, searchText, facet) => {
|
|
2642
|
+
const generateResultLink = (link, getQueryParamName, searchText, facet) => {
|
|
2625
2643
|
if (!searchText) {
|
|
2626
2644
|
return link;
|
|
2627
2645
|
}
|
|
2628
2646
|
const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
|
|
2629
|
-
const queryParam = `?${QUERY_PARAMS.QUERY}=${encodeParam(searchText)}`;
|
|
2647
|
+
const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS.QUERY) : QUERY_PARAMS.QUERY}=${encodeParam(searchText)}`;
|
|
2630
2648
|
return `${link}${queryParam}${facetParam}`;
|
|
2631
2649
|
};
|
|
2632
2650
|
const getRelativePath = (link) => {
|
|
@@ -2655,8 +2673,8 @@ const handleRoutingEvent = (link, event, hasEventRouting = false) => {
|
|
|
2655
2673
|
event == null ? void 0 : event.preventDefault();
|
|
2656
2674
|
emitRoutingEvent(link);
|
|
2657
2675
|
};
|
|
2658
|
-
const redirectToResultsPage = (link, searchText, facet, routingBehavior = "direct-link") => {
|
|
2659
|
-
const url = generateResultLink(link, searchText, facet);
|
|
2676
|
+
const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
|
|
2677
|
+
const url = generateResultLink(link, getQueryParamName, searchText, facet);
|
|
2660
2678
|
if (routingBehavior === "event") {
|
|
2661
2679
|
emitRoutingEvent(url);
|
|
2662
2680
|
} else {
|
|
@@ -2681,15 +2699,15 @@ const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
|
|
|
2681
2699
|
value
|
|
2682
2700
|
};
|
|
2683
2701
|
};
|
|
2684
|
-
const toggleTermFilter = (appendParams, facetAction, currentFilters) => {
|
|
2702
|
+
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
2685
2703
|
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
2686
2704
|
const newParams = toggleTermParam(currentFilter, facetAction.value);
|
|
2687
2705
|
appendParams({
|
|
2688
2706
|
params: [getFacetParam(facetAction.key, newParams)],
|
|
2689
|
-
paramsToRemove: [QUERY_PARAMS.PAGE]
|
|
2707
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
|
|
2690
2708
|
});
|
|
2691
2709
|
};
|
|
2692
|
-
const toggleHierarchyFilter = (appendParams, facetAction, currentFilters, removeAllLevels = false) => {
|
|
2710
|
+
const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
|
|
2693
2711
|
var _a;
|
|
2694
2712
|
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
2695
2713
|
const newParams = toggleHierarchyParam(
|
|
@@ -2699,10 +2717,10 @@ const toggleHierarchyFilter = (appendParams, facetAction, currentFilters, remove
|
|
|
2699
2717
|
);
|
|
2700
2718
|
appendParams({
|
|
2701
2719
|
params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
|
|
2702
|
-
paramsToRemove: [QUERY_PARAMS.PAGE]
|
|
2720
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
|
|
2703
2721
|
});
|
|
2704
2722
|
};
|
|
2705
|
-
const toggleRangeFilter = (appendParams, facetAction, currentFilters) => {
|
|
2723
|
+
const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
2706
2724
|
const currentFilter = rangeFilterToString(
|
|
2707
2725
|
currentFilters == null ? void 0 : currentFilters[facetAction.key],
|
|
2708
2726
|
FACET_RANGE_SEPARATOR
|
|
@@ -2711,7 +2729,7 @@ const toggleRangeFilter = (appendParams, facetAction, currentFilters) => {
|
|
|
2711
2729
|
facetValue = currentFilter === facetValue ? "" : facetValue;
|
|
2712
2730
|
appendParams({
|
|
2713
2731
|
params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
|
|
2714
|
-
paramsToRemove: [QUERY_PARAMS.PAGE],
|
|
2732
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE],
|
|
2715
2733
|
encode: false
|
|
2716
2734
|
});
|
|
2717
2735
|
};
|
|
@@ -2840,7 +2858,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2840
2858
|
const navigate = (url) => {
|
|
2841
2859
|
var _a, _b, _c;
|
|
2842
2860
|
window.history.pushState("", "Append params", url.pathname + url.search);
|
|
2843
|
-
const params2 = parseParams(url.searchParams);
|
|
2861
|
+
const params2 = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
2844
2862
|
(_c = (_b = (_a = optionsStore == null ? void 0 : optionsStore.searchBoxOptions) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onSearchResultsNavigate) == null ? void 0 : _c.call(_b, {
|
|
2845
2863
|
params: params2
|
|
2846
2864
|
});
|
|
@@ -2858,7 +2876,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2858
2876
|
const paramsToRemove = Array.from(url.searchParams.keys()).filter(isFacetKey);
|
|
2859
2877
|
removeParams(url, paramsToRemove);
|
|
2860
2878
|
navigate(url);
|
|
2861
|
-
params.value = parseParams(url.searchParams);
|
|
2879
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
2862
2880
|
searchString.value = url.search;
|
|
2863
2881
|
};
|
|
2864
2882
|
const removeParameters = ({
|
|
@@ -2866,13 +2884,13 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2866
2884
|
save = true
|
|
2867
2885
|
}) => {
|
|
2868
2886
|
const url = getPageUrl();
|
|
2869
|
-
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
2887
|
+
paramsToRemove = getRemovableParams(url, optionsStore.getQueryParamName, paramsToRemove);
|
|
2870
2888
|
removeParams(url, paramsToRemove);
|
|
2871
2889
|
navigate(url);
|
|
2872
2890
|
if (!save) {
|
|
2873
2891
|
return;
|
|
2874
2892
|
}
|
|
2875
|
-
params.value = parseParams(url.searchParams);
|
|
2893
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
2876
2894
|
searchString.value = url.search;
|
|
2877
2895
|
};
|
|
2878
2896
|
const handleNoResultsFlag = ({
|
|
@@ -2914,13 +2932,22 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2914
2932
|
})
|
|
2915
2933
|
] : [];
|
|
2916
2934
|
appendParams({
|
|
2917
|
-
params: [
|
|
2935
|
+
params: [
|
|
2936
|
+
{ name: optionsStore.getQueryParamName(QUERY_PARAMS.QUERY), value: searchText },
|
|
2937
|
+
...facetParam
|
|
2938
|
+
],
|
|
2918
2939
|
paramsToRemove: "all",
|
|
2919
2940
|
searchResultsLink: searchResultsLink.value
|
|
2920
2941
|
});
|
|
2921
2942
|
} else {
|
|
2922
2943
|
const routing = (_a = optionsStore.boxRoutingBehavior) != null ? _a : "direct-link";
|
|
2923
|
-
redirectToResultsPage(
|
|
2944
|
+
redirectToResultsPage(
|
|
2945
|
+
searchResultsLink.value,
|
|
2946
|
+
searchText,
|
|
2947
|
+
optionsStore.getQueryParamName,
|
|
2948
|
+
facet,
|
|
2949
|
+
routing
|
|
2950
|
+
);
|
|
2924
2951
|
}
|
|
2925
2952
|
};
|
|
2926
2953
|
const appendParams = ({
|
|
@@ -2934,14 +2961,14 @@ const useParamsStore = defineStore("params", () => {
|
|
|
2934
2961
|
return { params: params.value };
|
|
2935
2962
|
}
|
|
2936
2963
|
const url = getPageUrl(searchResultsLink2);
|
|
2937
|
-
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
2964
|
+
paramsToRemove = getRemovableParams(url, optionsStore.getQueryParamName, paramsToRemove);
|
|
2938
2965
|
removeParams(url, paramsToRemove);
|
|
2939
2966
|
newParams.forEach((p2) => appendParam(url, p2, encode));
|
|
2940
2967
|
navigate(url);
|
|
2941
2968
|
if (!save) {
|
|
2942
2969
|
return;
|
|
2943
2970
|
}
|
|
2944
|
-
params.value = parseParams(url.searchParams);
|
|
2971
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
2945
2972
|
searchString.value = url.search;
|
|
2946
2973
|
};
|
|
2947
2974
|
const setDefaultLimit = (newDefaultLimit) => {
|
|
@@ -3676,8 +3703,9 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
|
|
|
3676
3703
|
const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
3677
3704
|
const loading = ref(false);
|
|
3678
3705
|
const dynamicDataIdMap = ref({});
|
|
3706
|
+
const loadingIds = ref({});
|
|
3679
3707
|
const optionsStore = useOptionsStore();
|
|
3680
|
-
|
|
3708
|
+
computed(() => Object.keys(dynamicDataIdMap.value));
|
|
3681
3709
|
const searchResultOptions = computed(() => optionsStore.searchResultOptions);
|
|
3682
3710
|
const searchBoxOptions = computed(() => optionsStore.searchBoxOptions);
|
|
3683
3711
|
const dynamicSearchResultData = computed(() => {
|
|
@@ -3717,11 +3745,12 @@ const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
|
3717
3745
|
const similarQueryResultIds = (_e = (_d = (_c = result.similarQueries) == null ? void 0 : _c.map((q) => q.items.map((i) => i.id))) == null ? void 0 : _d.flat()) != null ? _e : [];
|
|
3718
3746
|
let requestedIds = [...resultIds, ...similarQueryResultIds];
|
|
3719
3747
|
if (isCacheEnabled.value) {
|
|
3720
|
-
requestedIds = requestedIds.filter((i) => !
|
|
3748
|
+
requestedIds = requestedIds.filter((i) => !dynamicDataIdMap.value[`${i}`]);
|
|
3721
3749
|
}
|
|
3722
3750
|
if (!requestedIds.length) {
|
|
3723
3751
|
return;
|
|
3724
3752
|
}
|
|
3753
|
+
loadingIds.value = requestedIds.reduce((a, c2) => __spreadProps(__spreadValues({}, a), { [c2]: true }), {});
|
|
3725
3754
|
loading.value = true;
|
|
3726
3755
|
try {
|
|
3727
3756
|
const dynamicData = dynamicSearchResultData.value || dynamicSearchBoxData.value;
|
|
@@ -3731,15 +3760,16 @@ const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
|
3731
3760
|
const dynamicDataResult = (_f = yield dynamicData == null ? void 0 : dynamicData.handler(requestedIds)) != null ? _f : [];
|
|
3732
3761
|
const seed = {};
|
|
3733
3762
|
const dynamicDataIdMapValue = dynamicDataResult.reduce(
|
|
3734
|
-
(a, c2) => __spreadProps(__spreadValues({}, a), { [c2.id]: c2 }),
|
|
3763
|
+
(a, c2) => __spreadProps(__spreadValues({}, a), { [`${c2.id}`]: c2 }),
|
|
3735
3764
|
seed
|
|
3736
3765
|
);
|
|
3737
3766
|
dynamicDataIdMap.value = __spreadValues(__spreadValues({}, dynamicDataIdMap.value), dynamicDataIdMapValue);
|
|
3738
3767
|
} finally {
|
|
3739
3768
|
loading.value = false;
|
|
3769
|
+
loadingIds.value = {};
|
|
3740
3770
|
}
|
|
3741
3771
|
});
|
|
3742
|
-
return { dynamicDataIdMap, loading, enhanceSearchResultsWithDynamicData };
|
|
3772
|
+
return { dynamicDataIdMap, loading, loadingIds, enhanceSearchResultsWithDynamicData };
|
|
3743
3773
|
});
|
|
3744
3774
|
const joinUrlParts = (...parts) => {
|
|
3745
3775
|
var _a, _b, _c;
|
|
@@ -4257,7 +4287,7 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValue
|
|
|
4257
4287
|
setup(__props) {
|
|
4258
4288
|
const props = __props;
|
|
4259
4289
|
const dynamicDataStore = useDynamicDataStore();
|
|
4260
|
-
const { loading, dynamicDataIdMap } = storeToRefs(dynamicDataStore);
|
|
4290
|
+
const { loading, loadingIds, dynamicDataIdMap } = storeToRefs(dynamicDataStore);
|
|
4261
4291
|
const elementComponent = computed(() => {
|
|
4262
4292
|
switch (props.element.type) {
|
|
4263
4293
|
case DocumentElementType.IMAGE:
|
|
@@ -4282,9 +4312,6 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValue
|
|
|
4282
4312
|
const displayElement = computed(() => {
|
|
4283
4313
|
return props.element.display ? props.element.display(props.item) : true;
|
|
4284
4314
|
});
|
|
4285
|
-
const isLoadingDynamicData = computed(() => {
|
|
4286
|
-
return Boolean(props.element.dynamic && loading.value);
|
|
4287
|
-
});
|
|
4288
4315
|
const enhancedItem = computed(() => {
|
|
4289
4316
|
var _a, _b, _c, _d;
|
|
4290
4317
|
if (!((_a = props.item) == null ? void 0 : _a.id)) {
|
|
@@ -4293,13 +4320,17 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValue
|
|
|
4293
4320
|
const enhancementData = (_d = (_c = dynamicDataIdMap.value) == null ? void 0 : _c[(_b = props.item) == null ? void 0 : _b.id]) != null ? _d : {};
|
|
4294
4321
|
return __spreadValues(__spreadValues({}, props.item), enhancementData);
|
|
4295
4322
|
});
|
|
4323
|
+
const isLoadingDynamicData = (id) => {
|
|
4324
|
+
return Boolean(props.element.dynamic && id && loading.value && (loadingIds == null ? void 0 : loadingIds.value[id]));
|
|
4325
|
+
};
|
|
4296
4326
|
return (_ctx, _cache) => {
|
|
4327
|
+
var _a;
|
|
4297
4328
|
return displayElement.value ? (openBlock(), createBlock(resolveDynamicComponent(elementComponent.value), {
|
|
4298
4329
|
key: 0,
|
|
4299
4330
|
item: enhancedItem.value,
|
|
4300
4331
|
options: _ctx.element,
|
|
4301
4332
|
labels: _ctx.labels,
|
|
4302
|
-
class: normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData.
|
|
4333
|
+
class: normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData((_a = _ctx.item) == null ? void 0 : _a.id) }),
|
|
4303
4334
|
inStock: _ctx.isInStock
|
|
4304
4335
|
}, null, 8, ["item", "options", "labels", "class", "inStock"])) : createCommentVNode("", true);
|
|
4305
4336
|
};
|
|
@@ -5310,11 +5341,11 @@ const getSearchParams = (url, params, baseUrl) => {
|
|
|
5310
5341
|
}
|
|
5311
5342
|
return searchParams;
|
|
5312
5343
|
};
|
|
5313
|
-
const getInitialSearchResults = (options, defaultData) => __async(void 0, null, function* () {
|
|
5344
|
+
const getInitialSearchResults = (options, getQueryParamName, defaultData) => __async(void 0, null, function* () {
|
|
5314
5345
|
var _a, _b, _c;
|
|
5315
5346
|
const searchParams = getSearchParams((_a = options.ssr) == null ? void 0 : _a.url, void 0, (_b = options.ssr) == null ? void 0 : _b.baseUrl);
|
|
5316
5347
|
const publicQuery = createPublicQuery(
|
|
5317
|
-
parseParams(searchParams),
|
|
5348
|
+
parseParams(getQueryParamName, searchParams),
|
|
5318
5349
|
options.sort,
|
|
5319
5350
|
defaultData == null ? void 0 : defaultData.pageSize
|
|
5320
5351
|
);
|
|
@@ -5544,6 +5575,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
|
5544
5575
|
setup(__props) {
|
|
5545
5576
|
const isOpen = ref(false);
|
|
5546
5577
|
const paramsStore = useParamsStore();
|
|
5578
|
+
const optionStore = useOptionsStore();
|
|
5547
5579
|
const searchResultStore = useSearchResultStore();
|
|
5548
5580
|
const { filters, displayFilters, currentFilterCount } = storeToRefs(searchResultStore);
|
|
5549
5581
|
const currentFilters = computed(() => filters.value);
|
|
@@ -5561,6 +5593,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
|
5561
5593
|
// TODO: Fix any
|
|
5562
5594
|
paramsStore.appendParams,
|
|
5563
5595
|
{ type: "terms", value: filter.value, key: filter.key },
|
|
5596
|
+
optionStore.getQueryParamName,
|
|
5564
5597
|
currentFilters.value
|
|
5565
5598
|
);
|
|
5566
5599
|
break;
|
|
@@ -5568,13 +5601,17 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
|
5568
5601
|
toggleHierarchyFilter(
|
|
5569
5602
|
paramsStore.appendParams,
|
|
5570
5603
|
{ type: "hierarchy", value: filter.value, key: filter.key },
|
|
5604
|
+
optionStore.getQueryParamName,
|
|
5571
5605
|
currentFilters.value,
|
|
5572
5606
|
true
|
|
5573
5607
|
);
|
|
5574
5608
|
break;
|
|
5575
5609
|
case "range":
|
|
5576
5610
|
paramsStore.removeParameters({
|
|
5577
|
-
paramsToRemove: [
|
|
5611
|
+
paramsToRemove: [
|
|
5612
|
+
optionStore.getQueryParamName(QUERY_PARAMS.PAGE),
|
|
5613
|
+
`${FACET_PARAMS_TYPE.RANGE}${filter.key}`
|
|
5614
|
+
]
|
|
5578
5615
|
});
|
|
5579
5616
|
break;
|
|
5580
5617
|
}
|
|
@@ -7576,13 +7613,28 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
7576
7613
|
const handleFacetSelect = (facetAction) => {
|
|
7577
7614
|
switch (facetAction.type) {
|
|
7578
7615
|
case "terms":
|
|
7579
|
-
toggleTermFilter(
|
|
7616
|
+
toggleTermFilter(
|
|
7617
|
+
paramStore.appendParams,
|
|
7618
|
+
facetAction,
|
|
7619
|
+
optionsStore.getQueryParamName,
|
|
7620
|
+
filters.value
|
|
7621
|
+
);
|
|
7580
7622
|
break;
|
|
7581
7623
|
case "range":
|
|
7582
|
-
toggleRangeFilter(
|
|
7624
|
+
toggleRangeFilter(
|
|
7625
|
+
paramStore.appendParams,
|
|
7626
|
+
facetAction,
|
|
7627
|
+
optionsStore.getQueryParamName,
|
|
7628
|
+
filters.value
|
|
7629
|
+
);
|
|
7583
7630
|
break;
|
|
7584
7631
|
case "hierarchy":
|
|
7585
|
-
toggleHierarchyFilter(
|
|
7632
|
+
toggleHierarchyFilter(
|
|
7633
|
+
paramStore.appendParams,
|
|
7634
|
+
facetAction,
|
|
7635
|
+
optionsStore.getQueryParamName,
|
|
7636
|
+
filters.value
|
|
7637
|
+
);
|
|
7586
7638
|
break;
|
|
7587
7639
|
}
|
|
7588
7640
|
if (scrollToResultsOptions.value.enabled) {
|
|
@@ -7949,7 +8001,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
7949
8001
|
const handlePageChange = (page) => {
|
|
7950
8002
|
if (page > 0) {
|
|
7951
8003
|
paramStore.appendParams({
|
|
7952
|
-
params: [{ name: QUERY_PARAMS.PAGE, value: page.toString() }]
|
|
8004
|
+
params: [{ name: optionsStore.getQueryParamName(QUERY_PARAMS.PAGE), value: page.toString() }]
|
|
7953
8005
|
});
|
|
7954
8006
|
if (scrollToResultsOptions.value.enabled) {
|
|
7955
8007
|
scrollToSearchResults(
|
|
@@ -8019,12 +8071,13 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
8019
8071
|
},
|
|
8020
8072
|
setup(__props) {
|
|
8021
8073
|
const paramsStore = useParamsStore();
|
|
8074
|
+
const optionsStore = useOptionsStore();
|
|
8022
8075
|
const select = ref(null);
|
|
8023
8076
|
const handleSelect = (e) => {
|
|
8024
8077
|
const value = e.target.value;
|
|
8025
8078
|
paramsStore.appendParams({
|
|
8026
|
-
params: [{ name: QUERY_PARAMS.LIMIT, value }],
|
|
8027
|
-
paramsToRemove: [QUERY_PARAMS.PAGE]
|
|
8079
|
+
params: [{ name: optionsStore.getQueryParamName(QUERY_PARAMS.LIMIT), value }],
|
|
8080
|
+
paramsToRemove: [optionsStore.getQueryParamName(QUERY_PARAMS.PAGE)]
|
|
8028
8081
|
});
|
|
8029
8082
|
};
|
|
8030
8083
|
return (_ctx, _cache) => {
|
|
@@ -8065,6 +8118,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
8065
8118
|
setup(__props) {
|
|
8066
8119
|
const props = __props;
|
|
8067
8120
|
const paramStore = useParamsStore();
|
|
8121
|
+
const optionStore = useOptionsStore();
|
|
8068
8122
|
const { sort } = storeToRefs(paramStore);
|
|
8069
8123
|
const selectedKey = ref("");
|
|
8070
8124
|
const previousKey = ref("");
|
|
@@ -8098,8 +8152,8 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
8098
8152
|
paramStore.setSortSettings({ selectedSortKey: value, previousSortKey: previousKey.value });
|
|
8099
8153
|
(_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value, previousSortKey: previousKey.value });
|
|
8100
8154
|
paramStore.appendParams({
|
|
8101
|
-
params: [{ name: QUERY_PARAMS.SORT, value }],
|
|
8102
|
-
paramsToRemove: [QUERY_PARAMS.PAGE]
|
|
8155
|
+
params: [{ name: optionStore.getQueryParamName(QUERY_PARAMS.SORT), value }],
|
|
8156
|
+
paramsToRemove: [optionStore.getQueryParamName(QUERY_PARAMS.PAGE)]
|
|
8103
8157
|
});
|
|
8104
8158
|
previousKey.value = selectedKey.value;
|
|
8105
8159
|
};
|
|
@@ -8957,7 +9011,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
8957
9011
|
setup(__props, { emit }) {
|
|
8958
9012
|
const props = __props;
|
|
8959
9013
|
const dynamicDataStore = useDynamicDataStore();
|
|
8960
|
-
const { dynamicDataIdMap, loading } = storeToRefs(dynamicDataStore);
|
|
9014
|
+
const { dynamicDataIdMap, loadingIds, loading } = storeToRefs(dynamicDataStore);
|
|
8961
9015
|
const elementComponent = computed(() => {
|
|
8962
9016
|
switch (props.element.type) {
|
|
8963
9017
|
case DocumentElementType.IMAGE:
|
|
@@ -8983,9 +9037,6 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
8983
9037
|
}
|
|
8984
9038
|
return "searchResultsProductTitle";
|
|
8985
9039
|
});
|
|
8986
|
-
const isLoadingDynamicData = computed(() => {
|
|
8987
|
-
return Boolean(props.element.dynamic && loading.value);
|
|
8988
|
-
});
|
|
8989
9040
|
const enhancedItem = computed(() => {
|
|
8990
9041
|
var _a, _b, _c, _d;
|
|
8991
9042
|
if (!((_a = props.item) == null ? void 0 : _a.id)) {
|
|
@@ -9000,7 +9051,11 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
9000
9051
|
const handleProductEvent = (item) => {
|
|
9001
9052
|
emit("productEvent", item);
|
|
9002
9053
|
};
|
|
9054
|
+
const isLoadingDynamicData = (id) => {
|
|
9055
|
+
return Boolean(props.element.dynamic && id && loading.value && (loadingIds == null ? void 0 : loadingIds.value[id]));
|
|
9056
|
+
};
|
|
9003
9057
|
return (_ctx, _cache) => {
|
|
9058
|
+
var _a;
|
|
9004
9059
|
return displayElement.value ? (openBlock(), createBlock(resolveDynamicComponent(elementComponent.value), {
|
|
9005
9060
|
key: 0,
|
|
9006
9061
|
item: enhancedItem.value,
|
|
@@ -9008,7 +9063,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
9008
9063
|
labels: _ctx.labels,
|
|
9009
9064
|
inStock: _ctx.inStock,
|
|
9010
9065
|
link: _ctx.link,
|
|
9011
|
-
class: normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData.
|
|
9066
|
+
class: normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData((_a = _ctx.item) == null ? void 0 : _a.id) }),
|
|
9012
9067
|
onProductEvent: handleProductEvent
|
|
9013
9068
|
}, null, 40, ["item", "options", "labels", "inStock", "link", "class"])) : createCommentVNode("", true);
|
|
9014
9069
|
};
|
|
@@ -9535,7 +9590,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
9535
9590
|
const props = __props;
|
|
9536
9591
|
const searchResultStore = useSearchResultStore();
|
|
9537
9592
|
const paramStore = useParamsStore();
|
|
9538
|
-
useOptionsStore();
|
|
9593
|
+
const optionStore = useOptionsStore();
|
|
9539
9594
|
const {
|
|
9540
9595
|
hasResults,
|
|
9541
9596
|
currentQueryText,
|
|
@@ -9619,7 +9674,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
9619
9674
|
};
|
|
9620
9675
|
const goToFirstPage = () => {
|
|
9621
9676
|
paramStore.appendParams({
|
|
9622
|
-
params: [{ name: QUERY_PARAMS.PAGE, value: "1" }]
|
|
9677
|
+
params: [{ name: optionStore.getQueryParamName(QUERY_PARAMS.PAGE), value: "1" }]
|
|
9623
9678
|
});
|
|
9624
9679
|
};
|
|
9625
9680
|
return (_ctx, _cache) => {
|
|
@@ -9825,7 +9880,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
9825
9880
|
const handlePopState = () => {
|
|
9826
9881
|
var _a;
|
|
9827
9882
|
const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
|
|
9828
|
-
paramStore.add(parseParams(searchParams));
|
|
9883
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, searchParams));
|
|
9829
9884
|
};
|
|
9830
9885
|
onMounted(() => __async(this, null, function* () {
|
|
9831
9886
|
var _a, _b;
|
|
@@ -9925,7 +9980,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
9925
9980
|
var _a;
|
|
9926
9981
|
const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url, params);
|
|
9927
9982
|
const publicQuery = createPublicQuery(
|
|
9928
|
-
parseParams(searchParams),
|
|
9983
|
+
parseParams(optionStore.getQueryParamName, searchParams),
|
|
9929
9984
|
props.options.sort,
|
|
9930
9985
|
defaultSearchResultPageSize.value
|
|
9931
9986
|
);
|
|
@@ -9945,10 +10000,10 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
9945
10000
|
}
|
|
9946
10001
|
}
|
|
9947
10002
|
const params = new URLSearchParams(window.location.search);
|
|
9948
|
-
if (!params.has(QUERY_PARAMS.QUERY) && !props.initialData) {
|
|
10003
|
+
if (!params.has(optionStore.getQueryParamName(QUERY_PARAMS.QUERY)) && !props.initialData) {
|
|
9949
10004
|
handleUrlChange(params);
|
|
9950
10005
|
}
|
|
9951
|
-
paramStore.add(parseParams(params));
|
|
10006
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, params));
|
|
9952
10007
|
paramStore.setDefaultLimit(defaultSearchResultPageSize.value);
|
|
9953
10008
|
};
|
|
9954
10009
|
watch(searchString, () => handleParamsChange());
|
|
@@ -9982,7 +10037,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
9982
10037
|
);
|
|
9983
10038
|
optionStore.setSearchResultOptions({ options: props.options });
|
|
9984
10039
|
searchResultStore.add(__spreadValues({}, initialData));
|
|
9985
|
-
paramStore.add(parseParams(searchParams), props.options.ssr);
|
|
10040
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, searchParams), props.options.ssr);
|
|
9986
10041
|
paramStore.setDefaultLimit(defaultSearchResultPageSize.value);
|
|
9987
10042
|
handleResults({ queryKey: props.options.queryKey, results: initialData });
|
|
9988
10043
|
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
PAGE: string;
|
|
4
|
-
LIMIT: string;
|
|
5
|
-
SORT: string;
|
|
6
|
-
};
|
|
1
|
+
import { LupaQueryParamName, LupaQueryParamValue } from '../types/General';
|
|
2
|
+
export declare const QUERY_PARAMS: Record<LupaQueryParamName, LupaQueryParamValue>;
|
|
7
3
|
export declare const QUERY_PARAMS_PARSED: {
|
|
8
4
|
QUERY: string;
|
|
9
5
|
PAGE: string;
|
|
@@ -3,13 +3,15 @@ import type { SearchQueryResult } from '@getlupa/client-sdk/Types';
|
|
|
3
3
|
export declare const useDynamicDataStore: import("pinia").StoreDefinition<"dynamicData", import("pinia")._UnwrapAll<Pick<{
|
|
4
4
|
dynamicDataIdMap: Ref<Record<string, Document>>;
|
|
5
5
|
loading: Ref<boolean>;
|
|
6
|
+
loadingIds: Ref<Record<string, boolean>>;
|
|
6
7
|
enhanceSearchResultsWithDynamicData: ({ result, mode }: {
|
|
7
8
|
result?: SearchQueryResult;
|
|
8
9
|
mode?: 'searchBox' | 'searchResults';
|
|
9
10
|
}) => Promise<{}>;
|
|
10
|
-
}, "dynamicDataIdMap" | "loading">>, Pick<{
|
|
11
|
+
}, "dynamicDataIdMap" | "loading" | "loadingIds">>, Pick<{
|
|
11
12
|
dynamicDataIdMap: Ref<Record<string, Document>>;
|
|
12
13
|
loading: Ref<boolean>;
|
|
14
|
+
loadingIds: Ref<Record<string, boolean>>;
|
|
13
15
|
enhanceSearchResultsWithDynamicData: ({ result, mode }: {
|
|
14
16
|
result?: SearchQueryResult;
|
|
15
17
|
mode?: 'searchBox' | 'searchResults';
|
|
@@ -17,6 +19,7 @@ export declare const useDynamicDataStore: import("pinia").StoreDefinition<"dynam
|
|
|
17
19
|
}, never>, Pick<{
|
|
18
20
|
dynamicDataIdMap: Ref<Record<string, Document>>;
|
|
19
21
|
loading: Ref<boolean>;
|
|
22
|
+
loadingIds: Ref<Record<string, boolean>>;
|
|
20
23
|
enhanceSearchResultsWithDynamicData: ({ result, mode }: {
|
|
21
24
|
result?: SearchQueryResult;
|
|
22
25
|
mode?: 'searchBox' | 'searchResults';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
2
|
import type { SearchBoxOptions } from '../types/search-box/SearchBoxOptions';
|
|
3
3
|
import type { SearchResultsOptions } from '../types/search-results/SearchResultsOptions';
|
|
4
|
-
import type { TrackingOptions } from '../types/General';
|
|
4
|
+
import type { LupaQueryParamValue, TrackingOptions } from '../types/General';
|
|
5
5
|
import type { FilterGroup } from '@getlupa/client-sdk/Types';
|
|
6
6
|
export declare const useOptionsStore: import("pinia").StoreDefinition<"options", import("pinia")._UnwrapAll<Pick<{
|
|
7
7
|
searchBoxOptions: Ref<SearchBoxOptions>;
|
|
@@ -26,6 +26,7 @@ export declare const useOptionsStore: import("pinia").StoreDefinition<"options",
|
|
|
26
26
|
setInitialFilters: ({ initialFilters }: {
|
|
27
27
|
initialFilters: FilterGroup;
|
|
28
28
|
}) => void;
|
|
29
|
+
getQueryParamName: (param: LupaQueryParamValue) => string;
|
|
29
30
|
}, "searchBoxOptions" | "searchResultOptions" | "trackingOptions">>, Pick<{
|
|
30
31
|
searchBoxOptions: Ref<SearchBoxOptions>;
|
|
31
32
|
searchResultOptions: Ref<SearchResultsOptions>;
|
|
@@ -49,6 +50,7 @@ export declare const useOptionsStore: import("pinia").StoreDefinition<"options",
|
|
|
49
50
|
setInitialFilters: ({ initialFilters }: {
|
|
50
51
|
initialFilters: FilterGroup;
|
|
51
52
|
}) => void;
|
|
53
|
+
getQueryParamName: (param: LupaQueryParamValue) => string;
|
|
52
54
|
}, "initialFilters" | "envOptions" | "classMap" | "boxRoutingBehavior" | "searchResultsRoutingBehavior" | "defaultSearchResultPageSize" | "currentResolutionPageSizes">, Pick<{
|
|
53
55
|
searchBoxOptions: Ref<SearchBoxOptions>;
|
|
54
56
|
searchResultOptions: Ref<SearchResultsOptions>;
|
|
@@ -72,4 +74,5 @@ export declare const useOptionsStore: import("pinia").StoreDefinition<"options",
|
|
|
72
74
|
setInitialFilters: ({ initialFilters }: {
|
|
73
75
|
initialFilters: FilterGroup;
|
|
74
76
|
}) => void;
|
|
75
|
-
|
|
77
|
+
getQueryParamName: (param: LupaQueryParamValue) => string;
|
|
78
|
+
}, "setSearchBoxOptions" | "setTrackingOptions" | "setSearchResultOptions" | "setInitialFilters" | "getQueryParamName">>;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
export declare const useScreenStore: import("pinia").StoreDefinition<"screen", import("pinia")._UnwrapAll<Pick<{
|
|
2
2
|
screenWidth: import("vue").Ref<number>;
|
|
3
|
-
currentScreenWidth: import("vue").ComputedRef<"
|
|
3
|
+
currentScreenWidth: import("vue").ComputedRef<"l" | "xs" | "sm" | "md" | "xl">;
|
|
4
4
|
isMobileWidth: import("vue").ComputedRef<boolean>;
|
|
5
5
|
setScreenWidth: ({ width }: {
|
|
6
6
|
width: number;
|
|
7
7
|
}) => void;
|
|
8
8
|
}, "screenWidth">>, Pick<{
|
|
9
9
|
screenWidth: import("vue").Ref<number>;
|
|
10
|
-
currentScreenWidth: import("vue").ComputedRef<"
|
|
10
|
+
currentScreenWidth: import("vue").ComputedRef<"l" | "xs" | "sm" | "md" | "xl">;
|
|
11
11
|
isMobileWidth: import("vue").ComputedRef<boolean>;
|
|
12
12
|
setScreenWidth: ({ width }: {
|
|
13
13
|
width: number;
|
|
14
14
|
}) => void;
|
|
15
15
|
}, "currentScreenWidth" | "isMobileWidth">, Pick<{
|
|
16
16
|
screenWidth: import("vue").Ref<number>;
|
|
17
|
-
currentScreenWidth: import("vue").ComputedRef<"
|
|
17
|
+
currentScreenWidth: import("vue").ComputedRef<"l" | "xs" | "sm" | "md" | "xl">;
|
|
18
18
|
isMobileWidth: import("vue").ComputedRef<boolean>;
|
|
19
19
|
setScreenWidth: ({ width }: {
|
|
20
20
|
width: number;
|
|
@@ -19,3 +19,5 @@ export type TrackingOptions = {
|
|
|
19
19
|
export type Environment = SdkEnvironment;
|
|
20
20
|
export type SortDirection = 'asc' | 'desc';
|
|
21
21
|
export type ScreenSize = 'xs' | 'sm' | 'md' | 'l' | 'xl';
|
|
22
|
+
export type LupaQueryParamName = 'QUERY' | 'PAGE' | 'LIMIT' | 'SORT';
|
|
23
|
+
export type LupaQueryParamValue = 'q' | 'p' | 'l' | 's';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SearchQueryResult } from '@getlupa/client-sdk/Types';
|
|
2
|
-
import type { SdkOptions } from '../General';
|
|
2
|
+
import type { LupaQueryParamValue, SdkOptions } from '../General';
|
|
3
3
|
import type { RoutingBehavior } from '../search-results/RoutingBehavior';
|
|
4
4
|
import type { DynamicData } from '../search-results/SearchResultsOptions';
|
|
5
5
|
import type { SearchBoxHistory } from './SearchBoxHistory';
|
|
@@ -14,6 +14,7 @@ export type SearchBoxOptions = SearchBoxPanelOptions & {
|
|
|
14
14
|
dynamicData?: DynamicData;
|
|
15
15
|
callbacks?: SearchBoxEventCallbacks;
|
|
16
16
|
redirections?: RedirectionOptions;
|
|
17
|
+
queryParameterNames?: Record<LupaQueryParamValue, string>;
|
|
17
18
|
};
|
|
18
19
|
export type SearchBoxOptionLabels = {
|
|
19
20
|
placeholder: string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { HierarchyFacetAction, RangeFacetAction, TermFacetAction } from '../types/search-results/FacetAction';
|
|
2
2
|
import type { FilterType } from '../types/search-results/Filters';
|
|
3
3
|
import type { FilterGroup } from '@getlupa/client-sdk/Types';
|
|
4
|
+
import { LupaQueryParamValue } from '../types/General';
|
|
4
5
|
type AppendParams = ({ params, paramsToRemove, encode }: {
|
|
5
6
|
params: {
|
|
6
7
|
name: string;
|
|
@@ -14,9 +15,9 @@ export declare const getFacetParam: (key: string, value: string[] | string, type
|
|
|
14
15
|
name: string;
|
|
15
16
|
value: string[] | string;
|
|
16
17
|
};
|
|
17
|
-
export declare const toggleTermFilter: (appendParams: AppendParams, facetAction: TermFacetAction, currentFilters?: FilterGroup) => void;
|
|
18
|
-
export declare const toggleHierarchyFilter: (appendParams: AppendParams, facetAction: HierarchyFacetAction, currentFilters?: FilterGroup, removeAllLevels?: boolean) => void;
|
|
19
|
-
export declare const toggleRangeFilter: (appendParams: AppendParams, facetAction: RangeFacetAction, currentFilters?: FilterGroup) => void;
|
|
18
|
+
export declare const toggleTermFilter: (appendParams: AppendParams, facetAction: TermFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup) => void;
|
|
19
|
+
export declare const toggleHierarchyFilter: (appendParams: AppendParams, facetAction: HierarchyFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup, removeAllLevels?: boolean) => void;
|
|
20
|
+
export declare const toggleRangeFilter: (appendParams: AppendParams, facetAction: RangeFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup) => void;
|
|
20
21
|
export declare const toggleTermParam: (params?: string[], param?: string) => string[];
|
|
21
22
|
export declare const toggleLastPram: (params?: string[], param?: string) => string[];
|
|
22
23
|
export declare const toggleHierarchyParam: (params?: string[], param?: string, removeAllLevels?: boolean) => string[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InputSuggestionFacet } from '../types/search-box/Common';
|
|
2
|
+
import { LupaQueryParamValue } from '../types/General';
|
|
2
3
|
export declare const generateLink: (linkPattern: string, document: Record<string, unknown>) => string;
|
|
3
|
-
export declare const generateResultLink: (link: string, searchText?: string, facet?: InputSuggestionFacet) => string;
|
|
4
|
+
export declare const generateResultLink: (link: string, getQueryParamName?: (param: LupaQueryParamValue) => string, searchText?: string, facet?: InputSuggestionFacet) => string;
|
|
4
5
|
export declare const getPathName: (resultPageLink: string) => string;
|
|
5
6
|
export declare const getRelativePath: (link: string) => string;
|
|
6
7
|
export declare const linksMatch: (link1?: string, link2?: string) => boolean;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { QueryParams } from '../types/search-results/QueryParams';
|
|
2
|
-
|
|
2
|
+
import { LupaQueryParamValue } from '../types/General';
|
|
3
|
+
export declare const parseParams: (getQueryParamName?: (param: LupaQueryParamValue) => string, searchParams?: URLSearchParams) => QueryParams;
|
|
3
4
|
export declare const appendParam: (url: URL, { name, value }: {
|
|
4
5
|
name: string;
|
|
5
6
|
value: string | string[];
|
|
6
7
|
}, encode?: boolean) => void;
|
|
7
|
-
export declare const getRemovableParams: (url: URL, paramsToRemove?: 'all' | string[]) => string[] | undefined;
|
|
8
|
+
export declare const getRemovableParams: (url: URL, getQueryParamName?: (param: LupaQueryParamValue) => string, paramsToRemove?: 'all' | string[]) => string[] | undefined;
|
|
8
9
|
export declare const removeParams: (url: URL, params?: string[]) => void;
|
|
9
10
|
export declare const encodeParam: (param: string) => string;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InputSuggestionFacet } from '../types/search-box/Common';
|
|
2
2
|
import type { RoutingBehavior, SsrOptions } from '..';
|
|
3
|
+
import { LupaQueryParamValue } from '../types/General';
|
|
3
4
|
export declare const emitRoutingEvent: (url: string) => void;
|
|
4
5
|
export declare const handleRoutingEvent: (link: string, event?: Event, hasEventRouting?: boolean) => void;
|
|
5
|
-
export declare const redirectToResultsPage: (link: string, searchText: string, facet?: InputSuggestionFacet, routingBehavior?: RoutingBehavior) => void;
|
|
6
|
+
export declare const redirectToResultsPage: (link: string, searchText: string, getQueryParamName: (param: LupaQueryParamValue) => string, facet?: InputSuggestionFacet, routingBehavior?: RoutingBehavior) => void;
|
|
6
7
|
export declare const getPageUrl: (pathnameOverride?: string, ssr?: SsrOptions) => URL;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { SearchResultsOptions } from '..';
|
|
2
2
|
import { FilterGroup } from '@getlupa/client-sdk/Types';
|
|
3
|
+
import { LupaQueryParamValue } from '../types/General';
|
|
3
4
|
export declare const getSearchParams: (url?: string, params?: URLSearchParams, baseUrl?: string) => URLSearchParams;
|
|
4
|
-
export declare const getInitialSearchResults: (options: SearchResultsOptions, defaultData?: {
|
|
5
|
+
export declare const getInitialSearchResults: (options: SearchResultsOptions, getQueryParamName: (param: LupaQueryParamValue) => string, defaultData?: {
|
|
5
6
|
filters?: FilterGroup;
|
|
6
7
|
pageSize?: number;
|
|
7
8
|
}) => Promise<import("@getlupa/client-sdk/Types").SearchQueryResult | import("@getlupa/client-sdk/Types").SdkError>;
|