@getlupa/vue 0.15.8 → 0.15.10
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 +176 -55
- package/dist/lupaSearch.mjs +177 -56
- package/dist/src/components/search-results/related-queries/RelatedQueryPanel.vue.d.ts +21 -2
- package/dist/src/types/search-results/RelatedQueryOptions.d.ts +7 -0
- package/dist/src/utils/filter.toggle.utils.d.ts +1 -1
- package/dist/src/utils/relatedSource.utils.d.ts +6 -2
- package/package.json +1 -1
package/dist/lupaSearch.js
CHANGED
|
@@ -2844,12 +2844,15 @@ const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
|
|
|
2844
2844
|
value
|
|
2845
2845
|
};
|
|
2846
2846
|
};
|
|
2847
|
-
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
2847
|
+
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
|
|
2848
2848
|
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
2849
2849
|
const newParams = toggleTermParam(currentFilter, facetAction.value);
|
|
2850
2850
|
appendParams({
|
|
2851
2851
|
params: [getFacetParam(facetAction.key, newParams)],
|
|
2852
|
-
paramsToRemove: [
|
|
2852
|
+
paramsToRemove: [
|
|
2853
|
+
...paramsToRemove,
|
|
2854
|
+
...[getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
|
|
2855
|
+
]
|
|
2853
2856
|
});
|
|
2854
2857
|
};
|
|
2855
2858
|
const replaceHierarchyParam = (params = [], param = "") => {
|
|
@@ -19466,26 +19469,104 @@ var RelatedQuerySourceType = /* @__PURE__ */ ((RelatedQuerySourceType2) => {
|
|
|
19466
19469
|
RelatedQuerySourceType2["FACETS"] = "facets";
|
|
19467
19470
|
return RelatedQuerySourceType2;
|
|
19468
19471
|
})(RelatedQuerySourceType || {});
|
|
19469
|
-
const
|
|
19472
|
+
const combineIdenticalValues = (results) => {
|
|
19473
|
+
const result2 = [];
|
|
19474
|
+
const keys = /* @__PURE__ */ new Set();
|
|
19475
|
+
for (const item of results) {
|
|
19476
|
+
const trimmedValue = item.value.trim().toLowerCase();
|
|
19477
|
+
if (!keys.has(trimmedValue)) {
|
|
19478
|
+
keys.add(trimmedValue);
|
|
19479
|
+
result2.push({ key: item.key, value: item.value.trim() });
|
|
19480
|
+
}
|
|
19481
|
+
}
|
|
19482
|
+
return result2;
|
|
19483
|
+
};
|
|
19484
|
+
const processFacetsRelatedSourceSuggestionQuery = (searchText, querySource, options, activeFilters) => __async(exports, null, function* () {
|
|
19485
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
19486
|
+
if ((_a = Object.keys(activeFilters != null ? activeFilters : {})) == null ? void 0 : _a.length) {
|
|
19487
|
+
return [];
|
|
19488
|
+
}
|
|
19489
|
+
const lupaQuery = {
|
|
19490
|
+
searchText,
|
|
19491
|
+
limit: 1,
|
|
19492
|
+
trackTerm: false
|
|
19493
|
+
};
|
|
19494
|
+
try {
|
|
19495
|
+
const result2 = yield LupaSearchSdk.suggestions(querySource.queryKey, lupaQuery, options);
|
|
19496
|
+
if (!result2.success || ((_c = (_b = result2.items) == null ? void 0 : _b[0].suggestion) == null ? void 0 : _c.toLocaleLowerCase()) !== (searchText == null ? void 0 : searchText.toLocaleLowerCase())) {
|
|
19497
|
+
return [];
|
|
19498
|
+
}
|
|
19499
|
+
return (_i = (_h = (_f = (_e = (_d = result2.items) == null ? void 0 : _d[0].facets) == null ? void 0 : _e[querySource.facetKey]) == null ? void 0 : _f.map((item) => ({
|
|
19500
|
+
key: querySource.facetKey,
|
|
19501
|
+
value: item.title
|
|
19502
|
+
}))) == null ? void 0 : _h.slice(0, (_g = querySource.maxCount) != null ? _g : 5)) != null ? _i : [];
|
|
19503
|
+
} catch (error) {
|
|
19504
|
+
return [];
|
|
19505
|
+
}
|
|
19506
|
+
});
|
|
19507
|
+
const processFacetsRelatedSourceDocumentQuery = (searchText, querySource, options, activeFilters) => __async(exports, null, function* () {
|
|
19508
|
+
const lupaQuery = {
|
|
19509
|
+
searchText,
|
|
19510
|
+
limit: 1,
|
|
19511
|
+
filters: activeFilters,
|
|
19512
|
+
trackTerm: false
|
|
19513
|
+
};
|
|
19514
|
+
try {
|
|
19515
|
+
const result2 = yield LupaSearchSdk.query(querySource.queryKey, lupaQuery, options);
|
|
19516
|
+
if (!result2.success) {
|
|
19517
|
+
return [];
|
|
19518
|
+
}
|
|
19519
|
+
return extractFacetsRelatedSourceFromOriginalQuery(
|
|
19520
|
+
{
|
|
19521
|
+
type: RelatedQuerySourceType.FACETS,
|
|
19522
|
+
key: querySource.facetKey,
|
|
19523
|
+
count: querySource.maxCount
|
|
19524
|
+
},
|
|
19525
|
+
result2
|
|
19526
|
+
);
|
|
19527
|
+
} catch (error) {
|
|
19528
|
+
return [];
|
|
19529
|
+
}
|
|
19530
|
+
});
|
|
19531
|
+
const processFacetsRelatedSourceQuery = (searchText, query, options, activeFilters) => __async(exports, null, function* () {
|
|
19532
|
+
switch (query.type) {
|
|
19533
|
+
case "document":
|
|
19534
|
+
return processFacetsRelatedSourceDocumentQuery(searchText, query, options, activeFilters);
|
|
19535
|
+
case "suggestion":
|
|
19536
|
+
return processFacetsRelatedSourceSuggestionQuery(searchText, query, options, activeFilters);
|
|
19537
|
+
}
|
|
19538
|
+
});
|
|
19539
|
+
const extractFacetsRelatedSource = (source, searchResults, options, activeFilters) => __async(exports, null, function* () {
|
|
19540
|
+
var _a, _b;
|
|
19541
|
+
if (!((_a = source.queries) == null ? void 0 : _a.length)) {
|
|
19542
|
+
return extractFacetsRelatedSourceFromOriginalQuery(source, searchResults);
|
|
19543
|
+
}
|
|
19544
|
+
const promises = source.queries.map(
|
|
19545
|
+
(query) => processFacetsRelatedSourceQuery(searchResults.searchText, query, options, activeFilters)
|
|
19546
|
+
);
|
|
19547
|
+
const result2 = (yield Promise.all(promises)).flat();
|
|
19548
|
+
return (_b = combineIdenticalValues(result2)) == null ? void 0 : _b.slice(0, source.count);
|
|
19549
|
+
});
|
|
19550
|
+
const extractFacetsRelatedSourceFromOriginalQuery = (source, searchResults) => __async(exports, null, function* () {
|
|
19470
19551
|
var _a, _b, _c, _d, _e;
|
|
19471
19552
|
const facet = (_a = searchResults.facets) == null ? void 0 : _a.find((facet2) => facet2.key === source.key);
|
|
19472
19553
|
if (!facet) {
|
|
19473
19554
|
return [];
|
|
19474
19555
|
}
|
|
19475
19556
|
if (facet.type === "terms") {
|
|
19476
|
-
return (_c = (_b = facet.items) == null ? void 0 : _b.slice(0, source.count)) == null ? void 0 : _c.map((item) => item.title);
|
|
19557
|
+
return (_c = (_b = facet.items) == null ? void 0 : _b.slice(0, source.count)) == null ? void 0 : _c.map((item) => ({ key: source.key, value: item.title }));
|
|
19477
19558
|
}
|
|
19478
19559
|
if (facet.type === "hierarchy") {
|
|
19479
|
-
return (_e = (_d = facet.items) == null ? void 0 : _d.slice(0, source.count)) == null ? void 0 : _e.map((item) => item.title);
|
|
19560
|
+
return (_e = (_d = facet.items) == null ? void 0 : _d.slice(0, source.count)) == null ? void 0 : _e.map((item) => ({ key: source.key, value: item.title }));
|
|
19480
19561
|
}
|
|
19481
19562
|
return [];
|
|
19482
|
-
};
|
|
19483
|
-
const extractRelatedSource = (source, searchResults) => {
|
|
19563
|
+
});
|
|
19564
|
+
const extractRelatedSource = (source, searchResults, options, activeFilters) => __async(exports, null, function* () {
|
|
19484
19565
|
switch (source.type) {
|
|
19485
19566
|
case RelatedQuerySourceType.FACETS:
|
|
19486
|
-
return extractFacetsRelatedSource(source, searchResults);
|
|
19567
|
+
return extractFacetsRelatedSource(source, searchResults, options, activeFilters);
|
|
19487
19568
|
}
|
|
19488
|
-
};
|
|
19569
|
+
});
|
|
19489
19570
|
const _hoisted_1$h = { class: "lupa-related-query-item" };
|
|
19490
19571
|
const _hoisted_2$e = { class: "lupa-related-query-image" };
|
|
19491
19572
|
const _hoisted_3$a = { class: "lupa-related-query-label" };
|
|
@@ -19498,12 +19579,16 @@ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
|
|
|
19498
19579
|
__name: "RelatedQueryPanel",
|
|
19499
19580
|
props: {
|
|
19500
19581
|
query: {},
|
|
19501
|
-
|
|
19582
|
+
sourceKey: {},
|
|
19583
|
+
options: {},
|
|
19584
|
+
existingItemsFromOtherQueries: {}
|
|
19502
19585
|
},
|
|
19503
|
-
|
|
19586
|
+
emits: ["loaded"],
|
|
19587
|
+
setup(__props, { emit }) {
|
|
19504
19588
|
const props = __props;
|
|
19505
19589
|
const loading = vue.ref(false);
|
|
19506
19590
|
const relatedQueryResult = vue.ref(null);
|
|
19591
|
+
const itemToDisplay = vue.ref(null);
|
|
19507
19592
|
const optionsStore = useOptionsStore();
|
|
19508
19593
|
const searchResultStore = useSearchResultStore();
|
|
19509
19594
|
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
@@ -19524,10 +19609,6 @@ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
|
|
|
19524
19609
|
var _a, _b;
|
|
19525
19610
|
return ((_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.items) == null ? void 0 : _b.length) > 0;
|
|
19526
19611
|
});
|
|
19527
|
-
const firstResultItem = vue.computed(() => {
|
|
19528
|
-
var _a, _b;
|
|
19529
|
-
return (_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.items) == null ? void 0 : _b[0];
|
|
19530
|
-
});
|
|
19531
19612
|
const totalItemCount = vue.computed(() => {
|
|
19532
19613
|
var _a, _b;
|
|
19533
19614
|
return (_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.total) != null ? _b : 0;
|
|
@@ -19537,19 +19618,19 @@ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
|
|
|
19537
19618
|
return ((_a = props.options.source) == null ? void 0 : _a.mode) === "filter" ? (_b = searchResult.value) == null ? void 0 : _b.searchText : (_c = props.query) == null ? void 0 : _c.toLowerCase();
|
|
19538
19619
|
});
|
|
19539
19620
|
const relatedQueryFilters = vue.computed(() => {
|
|
19540
|
-
var _a
|
|
19621
|
+
var _a;
|
|
19541
19622
|
return ((_a = props.options.source) == null ? void 0 : _a.mode) === "filter" ? {
|
|
19542
|
-
[
|
|
19623
|
+
[props.sourceKey]: [props.query]
|
|
19543
19624
|
} : {};
|
|
19544
19625
|
});
|
|
19545
19626
|
const searchForRelatedQuery = () => __async(this, null, function* () {
|
|
19546
|
-
var _a, _b, _c;
|
|
19627
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19547
19628
|
if (!props.query) {
|
|
19548
19629
|
return;
|
|
19549
19630
|
}
|
|
19550
19631
|
const lupaQuery = {
|
|
19551
19632
|
searchText: searchText.value,
|
|
19552
|
-
limit:
|
|
19633
|
+
limit: 3,
|
|
19553
19634
|
filters: relatedQueryFilters.value,
|
|
19554
19635
|
trackTerm: false
|
|
19555
19636
|
};
|
|
@@ -19563,8 +19644,13 @@ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
|
|
|
19563
19644
|
if (result2.success) {
|
|
19564
19645
|
relatedQueryResult.value = result2;
|
|
19565
19646
|
}
|
|
19647
|
+
const firstItem = (_c = (_b = relatedQueryResult.value) == null ? void 0 : _b.items) == null ? void 0 : _c[0];
|
|
19648
|
+
itemToDisplay.value = (_f = (_e = (_d = relatedQueryResult == null ? void 0 : relatedQueryResult.value) == null ? void 0 : _d.items) == null ? void 0 : _e.find(
|
|
19649
|
+
(i) => !props.existingItemsFromOtherQueries[`${i.id}`]
|
|
19650
|
+
)) != null ? _f : firstItem;
|
|
19651
|
+
emit("loaded", itemToDisplay.value);
|
|
19566
19652
|
} catch (error) {
|
|
19567
|
-
(
|
|
19653
|
+
(_h = (_g = searchResultOptions.value) == null ? void 0 : _g.options) == null ? void 0 : _h.onError(error);
|
|
19568
19654
|
} finally {
|
|
19569
19655
|
loading.value = false;
|
|
19570
19656
|
}
|
|
@@ -19582,11 +19668,11 @@ const _sfc_main$j = /* @__PURE__ */ vue.defineComponent({
|
|
|
19582
19668
|
var _a;
|
|
19583
19669
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$h, [
|
|
19584
19670
|
vue.createElementVNode("div", _hoisted_2$e, [
|
|
19585
|
-
|
|
19671
|
+
itemToDisplay.value && image.value ? (vue.openBlock(), vue.createBlock(_sfc_main$1l, {
|
|
19586
19672
|
key: 0,
|
|
19587
19673
|
"wrapper-class": "lupa-related-query-image-wrapper",
|
|
19588
19674
|
"image-class": "lupa-related-query-image",
|
|
19589
|
-
item:
|
|
19675
|
+
item: itemToDisplay.value,
|
|
19590
19676
|
options: image.value
|
|
19591
19677
|
}, null, 8, ["item", "options"])) : vue.createCommentVNode("", true)
|
|
19592
19678
|
]),
|
|
@@ -19618,47 +19704,63 @@ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
|
|
|
19618
19704
|
const paramsStore = useParamsStore();
|
|
19619
19705
|
const optionsStore = useOptionsStore();
|
|
19620
19706
|
const { searchResult } = storeToRefs(searchResultStore);
|
|
19707
|
+
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
19708
|
+
const relatedQueries = vue.ref([]);
|
|
19709
|
+
const allDisplayItems = vue.ref({});
|
|
19710
|
+
const querySourceResultMap = vue.ref({});
|
|
19621
19711
|
const currentSearchText = vue.computed(() => {
|
|
19622
19712
|
var _a, _b;
|
|
19623
19713
|
return (_b = (_a = searchResult.value) == null ? void 0 : _a.searchText) != null ? _b : "";
|
|
19624
19714
|
});
|
|
19625
|
-
const
|
|
19626
|
-
|
|
19627
|
-
|
|
19715
|
+
const currentFilters = vue.computed(() => paramsStore.filters);
|
|
19716
|
+
const querySources = vue.computed(() => {
|
|
19717
|
+
var _a, _b, _c, _d;
|
|
19718
|
+
return (_d = (_c = (_b = (_a = props.options) == null ? void 0 : _a.source) == null ? void 0 : _b.queries) == null ? void 0 : _c.map((q) => q.facetKey)) != null ? _d : [];
|
|
19719
|
+
});
|
|
19720
|
+
const currentFiltersWithoutQuerySources = vue.computed(() => {
|
|
19721
|
+
const filters = {};
|
|
19722
|
+
if (currentFilters.value) {
|
|
19723
|
+
for (const key in currentFilters.value) {
|
|
19724
|
+
if (!querySources.value.includes(key)) {
|
|
19725
|
+
filters[key] = currentFilters.value[key];
|
|
19726
|
+
}
|
|
19727
|
+
}
|
|
19628
19728
|
}
|
|
19629
|
-
|
|
19630
|
-
return queries;
|
|
19729
|
+
return filters;
|
|
19631
19730
|
});
|
|
19731
|
+
vue.watch(searchResult, () => __async(this, null, function* () {
|
|
19732
|
+
allDisplayItems.value = {};
|
|
19733
|
+
querySourceResultMap.value = {};
|
|
19734
|
+
if (!props.options || !searchResult.value) {
|
|
19735
|
+
relatedQueries.value = [];
|
|
19736
|
+
}
|
|
19737
|
+
const queries = yield extractRelatedSource(
|
|
19738
|
+
props.options.source,
|
|
19739
|
+
searchResult.value,
|
|
19740
|
+
searchResultOptions.value.options,
|
|
19741
|
+
currentFiltersWithoutQuerySources.value
|
|
19742
|
+
);
|
|
19743
|
+
relatedQueries.value = queries;
|
|
19744
|
+
}));
|
|
19632
19745
|
const hasEnoughRelatedQueries = vue.computed(() => {
|
|
19633
19746
|
return relatedQueries.value.length > 1;
|
|
19634
19747
|
});
|
|
19635
|
-
const goToResults = ({ searchText }) => {
|
|
19636
|
-
paramsStore.goToResults({ searchText });
|
|
19637
|
-
};
|
|
19638
19748
|
const handleRelatedQueryClick = (query) => {
|
|
19639
19749
|
var _a;
|
|
19640
19750
|
if (((_a = props.options.source) == null ? void 0 : _a.mode) === "filter") {
|
|
19641
19751
|
handleFilter(query);
|
|
19642
19752
|
} else {
|
|
19643
|
-
goToResults({ searchText: query });
|
|
19753
|
+
paramsStore.goToResults({ searchText: query.value });
|
|
19644
19754
|
}
|
|
19645
19755
|
};
|
|
19646
19756
|
const handleFilter = (query) => {
|
|
19647
|
-
var _a
|
|
19648
|
-
const facet = (_b = (_a = searchResult.value) == null ? void 0 : _a.facets) == null ? void 0 : _b.find(
|
|
19649
|
-
(facet2) => {
|
|
19650
|
-
var _a2, _b2;
|
|
19651
|
-
return facet2.key === ((_b2 = (_a2 = props.options) == null ? void 0 : _a2.source) == null ? void 0 : _b2.key);
|
|
19652
|
-
}
|
|
19653
|
-
);
|
|
19654
|
-
if (!facet || facet.type !== "terms") {
|
|
19655
|
-
return [];
|
|
19656
|
-
}
|
|
19757
|
+
var _a;
|
|
19657
19758
|
toggleTermFilter(
|
|
19658
19759
|
paramsStore.appendParams,
|
|
19659
|
-
{ type: "terms", key:
|
|
19760
|
+
{ type: "terms", key: query.key, value: query.value },
|
|
19660
19761
|
optionsStore.getQueryParamName,
|
|
19661
|
-
{}
|
|
19762
|
+
{},
|
|
19763
|
+
(_a = querySources.value) == null ? void 0 : _a.map((q) => `f.${q}`)
|
|
19662
19764
|
);
|
|
19663
19765
|
};
|
|
19664
19766
|
const getSelectedFilterClass = (query) => {
|
|
@@ -19666,9 +19768,13 @@ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
|
|
|
19666
19768
|
if (((_a = props.options.source) == null ? void 0 : _a.mode) !== "filter") {
|
|
19667
19769
|
return "";
|
|
19668
19770
|
}
|
|
19669
|
-
return Array.isArray((_c = (_b = searchResult.value) == null ? void 0 : _b.filters) == null ? void 0 : _c[
|
|
19670
|
-
|
|
19671
|
-
|
|
19771
|
+
return Array.isArray((_c = (_b = searchResult.value) == null ? void 0 : _b.filters) == null ? void 0 : _c[query.key]) && ((_f = (_e = (_d = searchResult.value) == null ? void 0 : _d.filters) == null ? void 0 : _e[query.key]) == null ? void 0 : _f.includes(query.value)) ? "lupa-selected-related-query-filter" : "";
|
|
19772
|
+
};
|
|
19773
|
+
const processLoadedItem = (query, item) => {
|
|
19774
|
+
if (item) {
|
|
19775
|
+
allDisplayItems.value[`${item.id}`] = item;
|
|
19776
|
+
}
|
|
19777
|
+
querySourceResultMap.value[query.value] = Boolean(item);
|
|
19672
19778
|
};
|
|
19673
19779
|
return (_ctx, _cache) => {
|
|
19674
19780
|
var _a, _b, _c, _d;
|
|
@@ -19676,19 +19782,24 @@ const _sfc_main$i = /* @__PURE__ */ vue.defineComponent({
|
|
|
19676
19782
|
((_b = (_a = _ctx.options) == null ? void 0 : _a.labels) == null ? void 0 : _b.title) ? (vue.openBlock(), vue.createElementBlock("h3", _hoisted_2$d, vue.toDisplayString((_d = (_c = _ctx.options) == null ? void 0 : _c.labels) == null ? void 0 : _d.title), 1)) : vue.createCommentVNode("", true),
|
|
19677
19783
|
vue.createElementVNode("ul", null, [
|
|
19678
19784
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(relatedQueries.value, (query) => {
|
|
19679
|
-
return vue.openBlock(), vue.createElementBlock("li", {
|
|
19680
|
-
key: query + currentSearchText.value,
|
|
19785
|
+
return vue.withDirectives((vue.openBlock(), vue.createElementBlock("li", {
|
|
19786
|
+
key: query.value + query.key + currentSearchText.value,
|
|
19681
19787
|
class: vue.normalizeClass(getSelectedFilterClass(query))
|
|
19682
19788
|
}, [
|
|
19683
19789
|
vue.createElementVNode("a", {
|
|
19684
19790
|
onClick: ($event) => handleRelatedQueryClick(query)
|
|
19685
19791
|
}, [
|
|
19686
19792
|
vue.createVNode(_sfc_main$j, {
|
|
19793
|
+
"source-key": query.key,
|
|
19687
19794
|
options: _ctx.options,
|
|
19688
|
-
query
|
|
19689
|
-
|
|
19795
|
+
query: query.value,
|
|
19796
|
+
"existing-items-from-other-queries": allDisplayItems.value,
|
|
19797
|
+
onLoaded: (item) => processLoadedItem(query, item)
|
|
19798
|
+
}, null, 8, ["source-key", "options", "query", "existing-items-from-other-queries", "onLoaded"])
|
|
19690
19799
|
], 8, _hoisted_3$9)
|
|
19691
|
-
], 2)
|
|
19800
|
+
], 2)), [
|
|
19801
|
+
[vue.vShow, querySourceResultMap.value[query.value] !== false]
|
|
19802
|
+
]);
|
|
19692
19803
|
}), 128))
|
|
19693
19804
|
])
|
|
19694
19805
|
])) : vue.createCommentVNode("", true);
|
|
@@ -19996,7 +20107,10 @@ const _hoisted_2$a = {
|
|
|
19996
20107
|
class: "lupa-category-back"
|
|
19997
20108
|
};
|
|
19998
20109
|
const _hoisted_3$6 = ["href"];
|
|
19999
|
-
const _hoisted_4$3 = {
|
|
20110
|
+
const _hoisted_4$3 = {
|
|
20111
|
+
key: 1,
|
|
20112
|
+
class: "lupa-child-category-list"
|
|
20113
|
+
};
|
|
20000
20114
|
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
20001
20115
|
__name: "CategoryTopFilters",
|
|
20002
20116
|
props: {
|
|
@@ -20010,6 +20124,10 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20010
20124
|
var _a, _b;
|
|
20011
20125
|
return Boolean((_b = (_a = props.options.categories) == null ? void 0 : _a.back) == null ? void 0 : _b.title);
|
|
20012
20126
|
});
|
|
20127
|
+
const hasRelatedCategoryChildren = vue.computed(() => {
|
|
20128
|
+
var _a;
|
|
20129
|
+
return ((_a = relatedCategoryChildren.value) == null ? void 0 : _a.length) > 0;
|
|
20130
|
+
});
|
|
20013
20131
|
const backTitle = vue.computed(() => {
|
|
20014
20132
|
var _a, _b;
|
|
20015
20133
|
return (_b = (_a = props.options.categories) == null ? void 0 : _a.back) == null ? void 0 : _b.title;
|
|
@@ -20036,7 +20154,10 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20036
20154
|
};
|
|
20037
20155
|
return (_ctx, _cache) => {
|
|
20038
20156
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
20039
|
-
class: vue.normalizeClass(["lupa-category-top-mobile-filters", {
|
|
20157
|
+
class: vue.normalizeClass(["lupa-category-top-mobile-filters", {
|
|
20158
|
+
"lupa-has-back-button": hasBackButton.value,
|
|
20159
|
+
"has-related-category-children": hasRelatedCategoryChildren.value
|
|
20160
|
+
}])
|
|
20040
20161
|
}, [
|
|
20041
20162
|
vue.createElementVNode("div", _hoisted_1$d, [
|
|
20042
20163
|
hasBackButton.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$a, [
|
|
@@ -20046,7 +20167,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20046
20167
|
onClick: handleNavigationBack
|
|
20047
20168
|
}, vue.toDisplayString(backTitle.value), 9, _hoisted_3$6)
|
|
20048
20169
|
])) : vue.createCommentVNode("", true),
|
|
20049
|
-
vue.
|
|
20170
|
+
hasRelatedCategoryChildren.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$3, [
|
|
20050
20171
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(relatedCategoryChildren), (child) => {
|
|
20051
20172
|
return vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
20052
20173
|
key: getCategoryKey(child),
|
|
@@ -20054,7 +20175,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20054
20175
|
options: categoryOptions.value
|
|
20055
20176
|
}, null, 8, ["item", "options"]);
|
|
20056
20177
|
}), 128))
|
|
20057
|
-
]),
|
|
20178
|
+
])) : vue.createCommentVNode("", true),
|
|
20058
20179
|
vue.createVNode(_sfc_main$B, {
|
|
20059
20180
|
class: "lupa-toolbar-mobile",
|
|
20060
20181
|
"pagination-location": "top",
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -49,7 +49,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
49
49
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
|
-
import { toRaw, isRef, isReactive, toRef, effectScope, ref, markRaw, hasInjectionContext, inject, getCurrentInstance, watch, reactive, nextTick, computed, unref, getCurrentScope, onScopeDispose, toRefs, defineComponent, openBlock, createElementBlock, createElementVNode, normalizeClass, withDirectives, mergeProps, vModelText, createCommentVNode, toDisplayString, onMounted, onBeforeMount, Fragment, renderList, createBlock, onBeforeUnmount, normalizeStyle, Transition, withCtx, toHandlers, withModifiers, resolveDynamicComponent, renderSlot, createSlots, createVNode, createTextVNode, normalizeProps, guardReactiveProps, onUnmounted, resolveComponent, vModelSelect, h as h$1, provide, cloneVNode
|
|
52
|
+
import { toRaw, isRef, isReactive, toRef, effectScope, ref, markRaw, hasInjectionContext, inject, getCurrentInstance, watch, reactive, nextTick, computed, unref, getCurrentScope, onScopeDispose, toRefs, defineComponent, openBlock, createElementBlock, createElementVNode, normalizeClass, withDirectives, mergeProps, vModelText, createCommentVNode, toDisplayString, onMounted, onBeforeMount, Fragment, renderList, createBlock, onBeforeUnmount, normalizeStyle, Transition, withCtx, toHandlers, withModifiers, resolveDynamicComponent, renderSlot, createSlots, createVNode, createTextVNode, normalizeProps, guardReactiveProps, onUnmounted, resolveComponent, vModelSelect, vShow, h as h$1, provide, cloneVNode } from "vue";
|
|
53
53
|
var isVue2 = false;
|
|
54
54
|
function set(target, key, val) {
|
|
55
55
|
if (Array.isArray(target)) {
|
|
@@ -2842,12 +2842,15 @@ const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
|
|
|
2842
2842
|
value
|
|
2843
2843
|
};
|
|
2844
2844
|
};
|
|
2845
|
-
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
2845
|
+
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters, paramsToRemove = []) => {
|
|
2846
2846
|
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
2847
2847
|
const newParams = toggleTermParam(currentFilter, facetAction.value);
|
|
2848
2848
|
appendParams({
|
|
2849
2849
|
params: [getFacetParam(facetAction.key, newParams)],
|
|
2850
|
-
paramsToRemove: [
|
|
2850
|
+
paramsToRemove: [
|
|
2851
|
+
...paramsToRemove,
|
|
2852
|
+
...[getQueryParamName ? getQueryParamName(QUERY_PARAMS.PAGE) : QUERY_PARAMS.PAGE]
|
|
2853
|
+
]
|
|
2851
2854
|
});
|
|
2852
2855
|
};
|
|
2853
2856
|
const replaceHierarchyParam = (params = [], param = "") => {
|
|
@@ -19464,26 +19467,104 @@ var RelatedQuerySourceType = /* @__PURE__ */ ((RelatedQuerySourceType2) => {
|
|
|
19464
19467
|
RelatedQuerySourceType2["FACETS"] = "facets";
|
|
19465
19468
|
return RelatedQuerySourceType2;
|
|
19466
19469
|
})(RelatedQuerySourceType || {});
|
|
19467
|
-
const
|
|
19470
|
+
const combineIdenticalValues = (results) => {
|
|
19471
|
+
const result2 = [];
|
|
19472
|
+
const keys = /* @__PURE__ */ new Set();
|
|
19473
|
+
for (const item of results) {
|
|
19474
|
+
const trimmedValue = item.value.trim().toLowerCase();
|
|
19475
|
+
if (!keys.has(trimmedValue)) {
|
|
19476
|
+
keys.add(trimmedValue);
|
|
19477
|
+
result2.push({ key: item.key, value: item.value.trim() });
|
|
19478
|
+
}
|
|
19479
|
+
}
|
|
19480
|
+
return result2;
|
|
19481
|
+
};
|
|
19482
|
+
const processFacetsRelatedSourceSuggestionQuery = (searchText, querySource, options, activeFilters) => __async(void 0, null, function* () {
|
|
19483
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
19484
|
+
if ((_a = Object.keys(activeFilters != null ? activeFilters : {})) == null ? void 0 : _a.length) {
|
|
19485
|
+
return [];
|
|
19486
|
+
}
|
|
19487
|
+
const lupaQuery = {
|
|
19488
|
+
searchText,
|
|
19489
|
+
limit: 1,
|
|
19490
|
+
trackTerm: false
|
|
19491
|
+
};
|
|
19492
|
+
try {
|
|
19493
|
+
const result2 = yield LupaSearchSdk.suggestions(querySource.queryKey, lupaQuery, options);
|
|
19494
|
+
if (!result2.success || ((_c = (_b = result2.items) == null ? void 0 : _b[0].suggestion) == null ? void 0 : _c.toLocaleLowerCase()) !== (searchText == null ? void 0 : searchText.toLocaleLowerCase())) {
|
|
19495
|
+
return [];
|
|
19496
|
+
}
|
|
19497
|
+
return (_i = (_h = (_f = (_e = (_d = result2.items) == null ? void 0 : _d[0].facets) == null ? void 0 : _e[querySource.facetKey]) == null ? void 0 : _f.map((item) => ({
|
|
19498
|
+
key: querySource.facetKey,
|
|
19499
|
+
value: item.title
|
|
19500
|
+
}))) == null ? void 0 : _h.slice(0, (_g = querySource.maxCount) != null ? _g : 5)) != null ? _i : [];
|
|
19501
|
+
} catch (error) {
|
|
19502
|
+
return [];
|
|
19503
|
+
}
|
|
19504
|
+
});
|
|
19505
|
+
const processFacetsRelatedSourceDocumentQuery = (searchText, querySource, options, activeFilters) => __async(void 0, null, function* () {
|
|
19506
|
+
const lupaQuery = {
|
|
19507
|
+
searchText,
|
|
19508
|
+
limit: 1,
|
|
19509
|
+
filters: activeFilters,
|
|
19510
|
+
trackTerm: false
|
|
19511
|
+
};
|
|
19512
|
+
try {
|
|
19513
|
+
const result2 = yield LupaSearchSdk.query(querySource.queryKey, lupaQuery, options);
|
|
19514
|
+
if (!result2.success) {
|
|
19515
|
+
return [];
|
|
19516
|
+
}
|
|
19517
|
+
return extractFacetsRelatedSourceFromOriginalQuery(
|
|
19518
|
+
{
|
|
19519
|
+
type: RelatedQuerySourceType.FACETS,
|
|
19520
|
+
key: querySource.facetKey,
|
|
19521
|
+
count: querySource.maxCount
|
|
19522
|
+
},
|
|
19523
|
+
result2
|
|
19524
|
+
);
|
|
19525
|
+
} catch (error) {
|
|
19526
|
+
return [];
|
|
19527
|
+
}
|
|
19528
|
+
});
|
|
19529
|
+
const processFacetsRelatedSourceQuery = (searchText, query, options, activeFilters) => __async(void 0, null, function* () {
|
|
19530
|
+
switch (query.type) {
|
|
19531
|
+
case "document":
|
|
19532
|
+
return processFacetsRelatedSourceDocumentQuery(searchText, query, options, activeFilters);
|
|
19533
|
+
case "suggestion":
|
|
19534
|
+
return processFacetsRelatedSourceSuggestionQuery(searchText, query, options, activeFilters);
|
|
19535
|
+
}
|
|
19536
|
+
});
|
|
19537
|
+
const extractFacetsRelatedSource = (source, searchResults, options, activeFilters) => __async(void 0, null, function* () {
|
|
19538
|
+
var _a, _b;
|
|
19539
|
+
if (!((_a = source.queries) == null ? void 0 : _a.length)) {
|
|
19540
|
+
return extractFacetsRelatedSourceFromOriginalQuery(source, searchResults);
|
|
19541
|
+
}
|
|
19542
|
+
const promises = source.queries.map(
|
|
19543
|
+
(query) => processFacetsRelatedSourceQuery(searchResults.searchText, query, options, activeFilters)
|
|
19544
|
+
);
|
|
19545
|
+
const result2 = (yield Promise.all(promises)).flat();
|
|
19546
|
+
return (_b = combineIdenticalValues(result2)) == null ? void 0 : _b.slice(0, source.count);
|
|
19547
|
+
});
|
|
19548
|
+
const extractFacetsRelatedSourceFromOriginalQuery = (source, searchResults) => __async(void 0, null, function* () {
|
|
19468
19549
|
var _a, _b, _c, _d, _e;
|
|
19469
19550
|
const facet = (_a = searchResults.facets) == null ? void 0 : _a.find((facet2) => facet2.key === source.key);
|
|
19470
19551
|
if (!facet) {
|
|
19471
19552
|
return [];
|
|
19472
19553
|
}
|
|
19473
19554
|
if (facet.type === "terms") {
|
|
19474
|
-
return (_c = (_b = facet.items) == null ? void 0 : _b.slice(0, source.count)) == null ? void 0 : _c.map((item) => item.title);
|
|
19555
|
+
return (_c = (_b = facet.items) == null ? void 0 : _b.slice(0, source.count)) == null ? void 0 : _c.map((item) => ({ key: source.key, value: item.title }));
|
|
19475
19556
|
}
|
|
19476
19557
|
if (facet.type === "hierarchy") {
|
|
19477
|
-
return (_e = (_d = facet.items) == null ? void 0 : _d.slice(0, source.count)) == null ? void 0 : _e.map((item) => item.title);
|
|
19558
|
+
return (_e = (_d = facet.items) == null ? void 0 : _d.slice(0, source.count)) == null ? void 0 : _e.map((item) => ({ key: source.key, value: item.title }));
|
|
19478
19559
|
}
|
|
19479
19560
|
return [];
|
|
19480
|
-
};
|
|
19481
|
-
const extractRelatedSource = (source, searchResults) => {
|
|
19561
|
+
});
|
|
19562
|
+
const extractRelatedSource = (source, searchResults, options, activeFilters) => __async(void 0, null, function* () {
|
|
19482
19563
|
switch (source.type) {
|
|
19483
19564
|
case RelatedQuerySourceType.FACETS:
|
|
19484
|
-
return extractFacetsRelatedSource(source, searchResults);
|
|
19565
|
+
return extractFacetsRelatedSource(source, searchResults, options, activeFilters);
|
|
19485
19566
|
}
|
|
19486
|
-
};
|
|
19567
|
+
});
|
|
19487
19568
|
const _hoisted_1$h = { class: "lupa-related-query-item" };
|
|
19488
19569
|
const _hoisted_2$e = { class: "lupa-related-query-image" };
|
|
19489
19570
|
const _hoisted_3$a = { class: "lupa-related-query-label" };
|
|
@@ -19496,12 +19577,16 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19496
19577
|
__name: "RelatedQueryPanel",
|
|
19497
19578
|
props: {
|
|
19498
19579
|
query: {},
|
|
19499
|
-
|
|
19580
|
+
sourceKey: {},
|
|
19581
|
+
options: {},
|
|
19582
|
+
existingItemsFromOtherQueries: {}
|
|
19500
19583
|
},
|
|
19501
|
-
|
|
19584
|
+
emits: ["loaded"],
|
|
19585
|
+
setup(__props, { emit }) {
|
|
19502
19586
|
const props = __props;
|
|
19503
19587
|
const loading = ref(false);
|
|
19504
19588
|
const relatedQueryResult = ref(null);
|
|
19589
|
+
const itemToDisplay = ref(null);
|
|
19505
19590
|
const optionsStore = useOptionsStore();
|
|
19506
19591
|
const searchResultStore = useSearchResultStore();
|
|
19507
19592
|
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
@@ -19522,10 +19607,6 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19522
19607
|
var _a, _b;
|
|
19523
19608
|
return ((_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.items) == null ? void 0 : _b.length) > 0;
|
|
19524
19609
|
});
|
|
19525
|
-
const firstResultItem = computed(() => {
|
|
19526
|
-
var _a, _b;
|
|
19527
|
-
return (_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.items) == null ? void 0 : _b[0];
|
|
19528
|
-
});
|
|
19529
19610
|
const totalItemCount = computed(() => {
|
|
19530
19611
|
var _a, _b;
|
|
19531
19612
|
return (_b = (_a = relatedQueryResult.value) == null ? void 0 : _a.total) != null ? _b : 0;
|
|
@@ -19535,19 +19616,19 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19535
19616
|
return ((_a = props.options.source) == null ? void 0 : _a.mode) === "filter" ? (_b = searchResult.value) == null ? void 0 : _b.searchText : (_c = props.query) == null ? void 0 : _c.toLowerCase();
|
|
19536
19617
|
});
|
|
19537
19618
|
const relatedQueryFilters = computed(() => {
|
|
19538
|
-
var _a
|
|
19619
|
+
var _a;
|
|
19539
19620
|
return ((_a = props.options.source) == null ? void 0 : _a.mode) === "filter" ? {
|
|
19540
|
-
[
|
|
19621
|
+
[props.sourceKey]: [props.query]
|
|
19541
19622
|
} : {};
|
|
19542
19623
|
});
|
|
19543
19624
|
const searchForRelatedQuery = () => __async(this, null, function* () {
|
|
19544
|
-
var _a, _b, _c;
|
|
19625
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
19545
19626
|
if (!props.query) {
|
|
19546
19627
|
return;
|
|
19547
19628
|
}
|
|
19548
19629
|
const lupaQuery = {
|
|
19549
19630
|
searchText: searchText.value,
|
|
19550
|
-
limit:
|
|
19631
|
+
limit: 3,
|
|
19551
19632
|
filters: relatedQueryFilters.value,
|
|
19552
19633
|
trackTerm: false
|
|
19553
19634
|
};
|
|
@@ -19561,8 +19642,13 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19561
19642
|
if (result2.success) {
|
|
19562
19643
|
relatedQueryResult.value = result2;
|
|
19563
19644
|
}
|
|
19645
|
+
const firstItem = (_c = (_b = relatedQueryResult.value) == null ? void 0 : _b.items) == null ? void 0 : _c[0];
|
|
19646
|
+
itemToDisplay.value = (_f = (_e = (_d = relatedQueryResult == null ? void 0 : relatedQueryResult.value) == null ? void 0 : _d.items) == null ? void 0 : _e.find(
|
|
19647
|
+
(i) => !props.existingItemsFromOtherQueries[`${i.id}`]
|
|
19648
|
+
)) != null ? _f : firstItem;
|
|
19649
|
+
emit("loaded", itemToDisplay.value);
|
|
19564
19650
|
} catch (error) {
|
|
19565
|
-
(
|
|
19651
|
+
(_h = (_g = searchResultOptions.value) == null ? void 0 : _g.options) == null ? void 0 : _h.onError(error);
|
|
19566
19652
|
} finally {
|
|
19567
19653
|
loading.value = false;
|
|
19568
19654
|
}
|
|
@@ -19580,11 +19666,11 @@ const _sfc_main$j = /* @__PURE__ */ defineComponent({
|
|
|
19580
19666
|
var _a;
|
|
19581
19667
|
return openBlock(), createElementBlock("div", _hoisted_1$h, [
|
|
19582
19668
|
createElementVNode("div", _hoisted_2$e, [
|
|
19583
|
-
|
|
19669
|
+
itemToDisplay.value && image.value ? (openBlock(), createBlock(_sfc_main$1l, {
|
|
19584
19670
|
key: 0,
|
|
19585
19671
|
"wrapper-class": "lupa-related-query-image-wrapper",
|
|
19586
19672
|
"image-class": "lupa-related-query-image",
|
|
19587
|
-
item:
|
|
19673
|
+
item: itemToDisplay.value,
|
|
19588
19674
|
options: image.value
|
|
19589
19675
|
}, null, 8, ["item", "options"])) : createCommentVNode("", true)
|
|
19590
19676
|
]),
|
|
@@ -19616,47 +19702,63 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
19616
19702
|
const paramsStore = useParamsStore();
|
|
19617
19703
|
const optionsStore = useOptionsStore();
|
|
19618
19704
|
const { searchResult } = storeToRefs(searchResultStore);
|
|
19705
|
+
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
19706
|
+
const relatedQueries = ref([]);
|
|
19707
|
+
const allDisplayItems = ref({});
|
|
19708
|
+
const querySourceResultMap = ref({});
|
|
19619
19709
|
const currentSearchText = computed(() => {
|
|
19620
19710
|
var _a, _b;
|
|
19621
19711
|
return (_b = (_a = searchResult.value) == null ? void 0 : _a.searchText) != null ? _b : "";
|
|
19622
19712
|
});
|
|
19623
|
-
const
|
|
19624
|
-
|
|
19625
|
-
|
|
19713
|
+
const currentFilters = computed(() => paramsStore.filters);
|
|
19714
|
+
const querySources = computed(() => {
|
|
19715
|
+
var _a, _b, _c, _d;
|
|
19716
|
+
return (_d = (_c = (_b = (_a = props.options) == null ? void 0 : _a.source) == null ? void 0 : _b.queries) == null ? void 0 : _c.map((q) => q.facetKey)) != null ? _d : [];
|
|
19717
|
+
});
|
|
19718
|
+
const currentFiltersWithoutQuerySources = computed(() => {
|
|
19719
|
+
const filters = {};
|
|
19720
|
+
if (currentFilters.value) {
|
|
19721
|
+
for (const key in currentFilters.value) {
|
|
19722
|
+
if (!querySources.value.includes(key)) {
|
|
19723
|
+
filters[key] = currentFilters.value[key];
|
|
19724
|
+
}
|
|
19725
|
+
}
|
|
19626
19726
|
}
|
|
19627
|
-
|
|
19628
|
-
return queries;
|
|
19727
|
+
return filters;
|
|
19629
19728
|
});
|
|
19729
|
+
watch(searchResult, () => __async(this, null, function* () {
|
|
19730
|
+
allDisplayItems.value = {};
|
|
19731
|
+
querySourceResultMap.value = {};
|
|
19732
|
+
if (!props.options || !searchResult.value) {
|
|
19733
|
+
relatedQueries.value = [];
|
|
19734
|
+
}
|
|
19735
|
+
const queries = yield extractRelatedSource(
|
|
19736
|
+
props.options.source,
|
|
19737
|
+
searchResult.value,
|
|
19738
|
+
searchResultOptions.value.options,
|
|
19739
|
+
currentFiltersWithoutQuerySources.value
|
|
19740
|
+
);
|
|
19741
|
+
relatedQueries.value = queries;
|
|
19742
|
+
}));
|
|
19630
19743
|
const hasEnoughRelatedQueries = computed(() => {
|
|
19631
19744
|
return relatedQueries.value.length > 1;
|
|
19632
19745
|
});
|
|
19633
|
-
const goToResults = ({ searchText }) => {
|
|
19634
|
-
paramsStore.goToResults({ searchText });
|
|
19635
|
-
};
|
|
19636
19746
|
const handleRelatedQueryClick = (query) => {
|
|
19637
19747
|
var _a;
|
|
19638
19748
|
if (((_a = props.options.source) == null ? void 0 : _a.mode) === "filter") {
|
|
19639
19749
|
handleFilter(query);
|
|
19640
19750
|
} else {
|
|
19641
|
-
goToResults({ searchText: query });
|
|
19751
|
+
paramsStore.goToResults({ searchText: query.value });
|
|
19642
19752
|
}
|
|
19643
19753
|
};
|
|
19644
19754
|
const handleFilter = (query) => {
|
|
19645
|
-
var _a
|
|
19646
|
-
const facet = (_b = (_a = searchResult.value) == null ? void 0 : _a.facets) == null ? void 0 : _b.find(
|
|
19647
|
-
(facet2) => {
|
|
19648
|
-
var _a2, _b2;
|
|
19649
|
-
return facet2.key === ((_b2 = (_a2 = props.options) == null ? void 0 : _a2.source) == null ? void 0 : _b2.key);
|
|
19650
|
-
}
|
|
19651
|
-
);
|
|
19652
|
-
if (!facet || facet.type !== "terms") {
|
|
19653
|
-
return [];
|
|
19654
|
-
}
|
|
19755
|
+
var _a;
|
|
19655
19756
|
toggleTermFilter(
|
|
19656
19757
|
paramsStore.appendParams,
|
|
19657
|
-
{ type: "terms", key:
|
|
19758
|
+
{ type: "terms", key: query.key, value: query.value },
|
|
19658
19759
|
optionsStore.getQueryParamName,
|
|
19659
|
-
{}
|
|
19760
|
+
{},
|
|
19761
|
+
(_a = querySources.value) == null ? void 0 : _a.map((q) => `f.${q}`)
|
|
19660
19762
|
);
|
|
19661
19763
|
};
|
|
19662
19764
|
const getSelectedFilterClass = (query) => {
|
|
@@ -19664,9 +19766,13 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
19664
19766
|
if (((_a = props.options.source) == null ? void 0 : _a.mode) !== "filter") {
|
|
19665
19767
|
return "";
|
|
19666
19768
|
}
|
|
19667
|
-
return Array.isArray((_c = (_b = searchResult.value) == null ? void 0 : _b.filters) == null ? void 0 : _c[
|
|
19668
|
-
|
|
19669
|
-
|
|
19769
|
+
return Array.isArray((_c = (_b = searchResult.value) == null ? void 0 : _b.filters) == null ? void 0 : _c[query.key]) && ((_f = (_e = (_d = searchResult.value) == null ? void 0 : _d.filters) == null ? void 0 : _e[query.key]) == null ? void 0 : _f.includes(query.value)) ? "lupa-selected-related-query-filter" : "";
|
|
19770
|
+
};
|
|
19771
|
+
const processLoadedItem = (query, item) => {
|
|
19772
|
+
if (item) {
|
|
19773
|
+
allDisplayItems.value[`${item.id}`] = item;
|
|
19774
|
+
}
|
|
19775
|
+
querySourceResultMap.value[query.value] = Boolean(item);
|
|
19670
19776
|
};
|
|
19671
19777
|
return (_ctx, _cache) => {
|
|
19672
19778
|
var _a, _b, _c, _d;
|
|
@@ -19674,19 +19780,24 @@ const _sfc_main$i = /* @__PURE__ */ defineComponent({
|
|
|
19674
19780
|
((_b = (_a = _ctx.options) == null ? void 0 : _a.labels) == null ? void 0 : _b.title) ? (openBlock(), createElementBlock("h3", _hoisted_2$d, toDisplayString((_d = (_c = _ctx.options) == null ? void 0 : _c.labels) == null ? void 0 : _d.title), 1)) : createCommentVNode("", true),
|
|
19675
19781
|
createElementVNode("ul", null, [
|
|
19676
19782
|
(openBlock(true), createElementBlock(Fragment, null, renderList(relatedQueries.value, (query) => {
|
|
19677
|
-
return openBlock(), createElementBlock("li", {
|
|
19678
|
-
key: query + currentSearchText.value,
|
|
19783
|
+
return withDirectives((openBlock(), createElementBlock("li", {
|
|
19784
|
+
key: query.value + query.key + currentSearchText.value,
|
|
19679
19785
|
class: normalizeClass(getSelectedFilterClass(query))
|
|
19680
19786
|
}, [
|
|
19681
19787
|
createElementVNode("a", {
|
|
19682
19788
|
onClick: ($event) => handleRelatedQueryClick(query)
|
|
19683
19789
|
}, [
|
|
19684
19790
|
createVNode(_sfc_main$j, {
|
|
19791
|
+
"source-key": query.key,
|
|
19685
19792
|
options: _ctx.options,
|
|
19686
|
-
query
|
|
19687
|
-
|
|
19793
|
+
query: query.value,
|
|
19794
|
+
"existing-items-from-other-queries": allDisplayItems.value,
|
|
19795
|
+
onLoaded: (item) => processLoadedItem(query, item)
|
|
19796
|
+
}, null, 8, ["source-key", "options", "query", "existing-items-from-other-queries", "onLoaded"])
|
|
19688
19797
|
], 8, _hoisted_3$9)
|
|
19689
|
-
], 2)
|
|
19798
|
+
], 2)), [
|
|
19799
|
+
[vShow, querySourceResultMap.value[query.value] !== false]
|
|
19800
|
+
]);
|
|
19690
19801
|
}), 128))
|
|
19691
19802
|
])
|
|
19692
19803
|
])) : createCommentVNode("", true);
|
|
@@ -19994,7 +20105,10 @@ const _hoisted_2$a = {
|
|
|
19994
20105
|
class: "lupa-category-back"
|
|
19995
20106
|
};
|
|
19996
20107
|
const _hoisted_3$6 = ["href"];
|
|
19997
|
-
const _hoisted_4$3 = {
|
|
20108
|
+
const _hoisted_4$3 = {
|
|
20109
|
+
key: 1,
|
|
20110
|
+
class: "lupa-child-category-list"
|
|
20111
|
+
};
|
|
19998
20112
|
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
19999
20113
|
__name: "CategoryTopFilters",
|
|
20000
20114
|
props: {
|
|
@@ -20008,6 +20122,10 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20008
20122
|
var _a, _b;
|
|
20009
20123
|
return Boolean((_b = (_a = props.options.categories) == null ? void 0 : _a.back) == null ? void 0 : _b.title);
|
|
20010
20124
|
});
|
|
20125
|
+
const hasRelatedCategoryChildren = computed(() => {
|
|
20126
|
+
var _a;
|
|
20127
|
+
return ((_a = relatedCategoryChildren.value) == null ? void 0 : _a.length) > 0;
|
|
20128
|
+
});
|
|
20011
20129
|
const backTitle = computed(() => {
|
|
20012
20130
|
var _a, _b;
|
|
20013
20131
|
return (_b = (_a = props.options.categories) == null ? void 0 : _a.back) == null ? void 0 : _b.title;
|
|
@@ -20034,7 +20152,10 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20034
20152
|
};
|
|
20035
20153
|
return (_ctx, _cache) => {
|
|
20036
20154
|
return openBlock(), createElementBlock("div", {
|
|
20037
|
-
class: normalizeClass(["lupa-category-top-mobile-filters", {
|
|
20155
|
+
class: normalizeClass(["lupa-category-top-mobile-filters", {
|
|
20156
|
+
"lupa-has-back-button": hasBackButton.value,
|
|
20157
|
+
"has-related-category-children": hasRelatedCategoryChildren.value
|
|
20158
|
+
}])
|
|
20038
20159
|
}, [
|
|
20039
20160
|
createElementVNode("div", _hoisted_1$d, [
|
|
20040
20161
|
hasBackButton.value ? (openBlock(), createElementBlock("div", _hoisted_2$a, [
|
|
@@ -20044,7 +20165,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20044
20165
|
onClick: handleNavigationBack
|
|
20045
20166
|
}, toDisplayString(backTitle.value), 9, _hoisted_3$6)
|
|
20046
20167
|
])) : createCommentVNode("", true),
|
|
20047
|
-
|
|
20168
|
+
hasRelatedCategoryChildren.value ? (openBlock(), createElementBlock("div", _hoisted_4$3, [
|
|
20048
20169
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(relatedCategoryChildren), (child) => {
|
|
20049
20170
|
return openBlock(), createBlock(_sfc_main$U, {
|
|
20050
20171
|
key: getCategoryKey(child),
|
|
@@ -20052,7 +20173,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20052
20173
|
options: categoryOptions.value
|
|
20053
20174
|
}, null, 8, ["item", "options"]);
|
|
20054
20175
|
}), 128))
|
|
20055
|
-
]),
|
|
20176
|
+
])) : createCommentVNode("", true),
|
|
20056
20177
|
createVNode(_sfc_main$B, {
|
|
20057
20178
|
class: "lupa-toolbar-mobile",
|
|
20058
20179
|
"pagination-location": "top",
|
|
@@ -1,22 +1,41 @@
|
|
|
1
1
|
import type { PropType as __PropType } from 'vue';
|
|
2
2
|
import { RelatedQueryOptions } from '../../../types/search-results/RelatedQueryOptions';
|
|
3
|
+
import { Document } from '@getlupa/client-sdk/Types';
|
|
3
4
|
declare const _sfc_main: import("vue").DefineComponent<{
|
|
4
5
|
query: {
|
|
5
6
|
type: __PropType<string>;
|
|
6
7
|
required: false;
|
|
7
8
|
};
|
|
9
|
+
sourceKey: {
|
|
10
|
+
type: __PropType<string>;
|
|
11
|
+
required: false;
|
|
12
|
+
};
|
|
8
13
|
options: {
|
|
9
14
|
type: __PropType<RelatedQueryOptions>;
|
|
10
15
|
required: false;
|
|
11
16
|
};
|
|
12
|
-
|
|
17
|
+
existingItemsFromOtherQueries: {
|
|
18
|
+
type: __PropType<Record<string, Document>>;
|
|
19
|
+
required: false;
|
|
20
|
+
};
|
|
21
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "loaded"[], "loaded", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
13
22
|
query: {
|
|
14
23
|
type: __PropType<string>;
|
|
15
24
|
required: false;
|
|
16
25
|
};
|
|
26
|
+
sourceKey: {
|
|
27
|
+
type: __PropType<string>;
|
|
28
|
+
required: false;
|
|
29
|
+
};
|
|
17
30
|
options: {
|
|
18
31
|
type: __PropType<RelatedQueryOptions>;
|
|
19
32
|
required: false;
|
|
20
33
|
};
|
|
21
|
-
|
|
34
|
+
existingItemsFromOtherQueries: {
|
|
35
|
+
type: __PropType<Record<string, Document>>;
|
|
36
|
+
required: false;
|
|
37
|
+
};
|
|
38
|
+
}>> & {
|
|
39
|
+
onLoaded?: (...args: any[]) => any;
|
|
40
|
+
}, {}, {}>;
|
|
22
41
|
export default _sfc_main;
|
|
@@ -5,11 +5,18 @@ export declare enum RelatedQuerySourceType {
|
|
|
5
5
|
export type RelatedQuerySourceBase = {
|
|
6
6
|
type: RelatedQuerySourceType;
|
|
7
7
|
};
|
|
8
|
+
export type RelatedQueryFacetsSourceQuery = {
|
|
9
|
+
facetKey: string;
|
|
10
|
+
queryKey: string;
|
|
11
|
+
type: 'document' | 'suggestion';
|
|
12
|
+
maxCount?: number;
|
|
13
|
+
};
|
|
8
14
|
export type RelatedQueryFacetsSource = RelatedQuerySourceBase & {
|
|
9
15
|
type: RelatedQuerySourceType.FACETS;
|
|
10
16
|
key: string;
|
|
11
17
|
count: number;
|
|
12
18
|
mode?: 'query' | 'filter';
|
|
19
|
+
queries?: RelatedQueryFacetsSourceQuery[];
|
|
13
20
|
};
|
|
14
21
|
export type RelatedQuerySource = RelatedQueryFacetsSource;
|
|
15
22
|
export type RelatedQueryOptions = {
|
|
@@ -15,7 +15,7 @@ export declare const getFacetParam: (key: string, value: string[] | string, type
|
|
|
15
15
|
name: string;
|
|
16
16
|
value: string[] | string;
|
|
17
17
|
};
|
|
18
|
-
export declare const toggleTermFilter: (appendParams: AppendParams, facetAction: TermFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup) => void;
|
|
18
|
+
export declare const toggleTermFilter: (appendParams: AppendParams, facetAction: TermFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup, paramsToRemove?: string[]) => void;
|
|
19
19
|
export declare const toggleHierarchyFilter: (appendParams: AppendParams, facetAction: HierarchyFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup, removeAllLevels?: boolean) => void;
|
|
20
20
|
export declare const toggleRangeFilter: (appendParams: AppendParams, facetAction: RangeFacetAction, getQueryParamName?: (param: LupaQueryParamValue) => string, currentFilters?: FilterGroup) => void;
|
|
21
21
|
export declare const toggleTermParam: (params?: string[], param?: string) => string[];
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { SdkOptions } from '../types/General';
|
|
1
2
|
import { RelatedQuerySource } from '../types/search-results/RelatedQueryOptions';
|
|
2
|
-
import type { SearchQueryResult } from '@getlupa/client-sdk/Types';
|
|
3
|
-
export declare const extractRelatedSource: (source: RelatedQuerySource, searchResults: SearchQueryResult) =>
|
|
3
|
+
import type { FilterGroup, SearchQueryResult } from '@getlupa/client-sdk/Types';
|
|
4
|
+
export declare const extractRelatedSource: (source: RelatedQuerySource, searchResults: SearchQueryResult, options: SdkOptions, activeFilters?: FilterGroup) => Promise<{
|
|
5
|
+
key: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}[]>;
|