@getlupa/client 1.11.9 → 1.12.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.iife.js +67 -31
- package/dist/lupaSearch.js +67 -31
- package/dist/lupaSearch.mjs +67 -31
- package/dist/lupaSearch.umd.js +67 -31
- package/package.json +2 -2
package/dist/lupaSearch.iife.js
CHANGED
|
@@ -7382,23 +7382,34 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7382
7382
|
};
|
|
7383
7383
|
const useScreenStore = defineStore("screen", () => {
|
|
7384
7384
|
const screenWidth = ref(1e3);
|
|
7385
|
+
const optionsStore = useOptionsStore();
|
|
7386
|
+
const configuredGridSizes = computed(() => {
|
|
7387
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
7388
|
+
return {
|
|
7389
|
+
smMin: (_d = (_c = (_b = (_a = optionsStore.searchResultOptions) == null ? void 0 : _a.grid) == null ? void 0 : _b.sizes) == null ? void 0 : _c.sm) != null ? _d : S_MIN_WIDTH,
|
|
7390
|
+
mdMin: (_h = (_g = (_f = (_e = optionsStore.searchResultOptions) == null ? void 0 : _e.grid) == null ? void 0 : _f.sizes) == null ? void 0 : _g.md) != null ? _h : MD_MIN_WIDTH,
|
|
7391
|
+
lMin: (_l = (_k = (_j = (_i = optionsStore.searchResultOptions) == null ? void 0 : _i.grid) == null ? void 0 : _j.sizes) == null ? void 0 : _k.l) != null ? _l : L_MIN_WIDTH,
|
|
7392
|
+
xlMin: (_p = (_o = (_n = (_m = optionsStore.searchResultOptions) == null ? void 0 : _m.grid) == null ? void 0 : _n.sizes) == null ? void 0 : _o.xl) != null ? _p : XL_MIN_WIDTH
|
|
7393
|
+
};
|
|
7394
|
+
});
|
|
7385
7395
|
const currentScreenWidth = computed(() => {
|
|
7386
7396
|
const width = screenWidth.value;
|
|
7387
|
-
if (width <=
|
|
7397
|
+
if (width <= configuredGridSizes.value.smMin) {
|
|
7388
7398
|
return "xs";
|
|
7389
|
-
} else if (width >
|
|
7399
|
+
} else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
|
|
7390
7400
|
return "sm";
|
|
7391
|
-
} else if (width >
|
|
7401
|
+
} else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
|
|
7392
7402
|
return "md";
|
|
7393
|
-
} else if (width >
|
|
7403
|
+
} else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
|
|
7394
7404
|
return "l";
|
|
7395
7405
|
} else {
|
|
7396
7406
|
return "xl";
|
|
7397
7407
|
}
|
|
7398
7408
|
});
|
|
7399
|
-
const isMobileWidth = computed(
|
|
7400
|
-
|
|
7401
|
-
|
|
7409
|
+
const isMobileWidth = computed(() => {
|
|
7410
|
+
var _a;
|
|
7411
|
+
return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
|
|
7412
|
+
});
|
|
7402
7413
|
const setScreenWidth = ({ width }) => {
|
|
7403
7414
|
screenWidth.value = width;
|
|
7404
7415
|
};
|
|
@@ -9407,6 +9418,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9407
9418
|
const isMobileSidebarVisible = ref(false);
|
|
9408
9419
|
const optionsStore = useOptionsStore();
|
|
9409
9420
|
const paramsStore = useParamsStore();
|
|
9421
|
+
const screenStore = useScreenStore();
|
|
9410
9422
|
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
9411
9423
|
const facets = computed(() => searchResult.value.facets);
|
|
9412
9424
|
const filters = computed(() => searchResult.value.filters);
|
|
@@ -9452,6 +9464,10 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9452
9464
|
var _a;
|
|
9453
9465
|
return Object.keys((_a = filters.value) != null ? _a : {}).length > 0;
|
|
9454
9466
|
});
|
|
9467
|
+
const hideFiltersOnExactMatchForKeys = computed(() => {
|
|
9468
|
+
var _a, _b, _c, _d;
|
|
9469
|
+
return (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.filters) == null ? void 0 : _b.facets) == null ? void 0 : _c.hideFiltersOnExactMatchForKeys) != null ? _d : [];
|
|
9470
|
+
});
|
|
9455
9471
|
const itemRange = computed(() => {
|
|
9456
9472
|
var _a, _b;
|
|
9457
9473
|
const limit = (_a = paramsStore.limit) != null ? _a : 0;
|
|
@@ -9505,20 +9521,13 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9505
9521
|
return { searchResult: newSearchResult };
|
|
9506
9522
|
};
|
|
9507
9523
|
const setColumnCount = ({ width, grid }) => {
|
|
9524
|
+
var _a;
|
|
9508
9525
|
if (!width || !grid) {
|
|
9509
9526
|
return;
|
|
9510
9527
|
}
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
columnCount.value = grid.columns.sm;
|
|
9515
|
-
} else if (width > MD_MIN_WIDTH && width <= L_MIN_WIDTH) {
|
|
9516
|
-
columnCount.value = grid.columns.md;
|
|
9517
|
-
} else if (width > L_MIN_WIDTH && width <= XL_MIN_WIDTH) {
|
|
9518
|
-
columnCount.value = grid.columns.l;
|
|
9519
|
-
} else {
|
|
9520
|
-
columnCount.value = grid.columns.xl;
|
|
9521
|
-
}
|
|
9528
|
+
const { currentScreenWidth } = storeToRefs(screenStore);
|
|
9529
|
+
const screenWidth = (_a = currentScreenWidth.value) != null ? _a : "xl";
|
|
9530
|
+
columnCount.value = grid.columns[screenWidth];
|
|
9522
9531
|
};
|
|
9523
9532
|
const setAddToCartAmount = (newAddToCartAmount) => {
|
|
9524
9533
|
if (!newAddToCartAmount) {
|
|
@@ -9538,6 +9547,15 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9538
9547
|
const clearSearchResult = () => {
|
|
9539
9548
|
searchResult.value = {};
|
|
9540
9549
|
};
|
|
9550
|
+
const filterVisibleFilterValues = (key, items = []) => {
|
|
9551
|
+
var _a;
|
|
9552
|
+
if (!((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.length) || !hideFiltersOnExactMatchForKeys.value.includes(key) || !items.length) {
|
|
9553
|
+
return items;
|
|
9554
|
+
}
|
|
9555
|
+
const searchInput = getNormalizedString(currentQueryText.value);
|
|
9556
|
+
const hasExactMatch = items.some((item) => getNormalizedString(item.title) === searchInput);
|
|
9557
|
+
return hasExactMatch ? items.filter((item) => getNormalizedString(item.title) === searchInput) : items;
|
|
9558
|
+
};
|
|
9541
9559
|
return {
|
|
9542
9560
|
isMobileSidebarVisible,
|
|
9543
9561
|
searchResult,
|
|
@@ -9557,6 +9575,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9557
9575
|
hasAnyFilter,
|
|
9558
9576
|
itemRange,
|
|
9559
9577
|
isPageEmpty,
|
|
9578
|
+
hideFiltersOnExactMatchForKeys,
|
|
9560
9579
|
setSidebarState,
|
|
9561
9580
|
queryFacet,
|
|
9562
9581
|
add: add2,
|
|
@@ -9564,7 +9583,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9564
9583
|
setAddToCartAmount,
|
|
9565
9584
|
setLayout,
|
|
9566
9585
|
setLoading,
|
|
9567
|
-
clearSearchResult
|
|
9586
|
+
clearSearchResult,
|
|
9587
|
+
filterVisibleFilterValues
|
|
9568
9588
|
};
|
|
9569
9589
|
});
|
|
9570
9590
|
const _hoisted_1$12 = { class: "lupa-search-box-add-to-cart-wrapper" };
|
|
@@ -11277,11 +11297,25 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11277
11297
|
const paramsStore = useParamsStore();
|
|
11278
11298
|
const optionStore = useOptionsStore();
|
|
11279
11299
|
const searchResultStore = useSearchResultStore();
|
|
11280
|
-
const {
|
|
11300
|
+
const {
|
|
11301
|
+
filters,
|
|
11302
|
+
displayFilters,
|
|
11303
|
+
currentFilterCount,
|
|
11304
|
+
hideFiltersOnExactMatchForKeys,
|
|
11305
|
+
currentQueryText
|
|
11306
|
+
} = storeToRefs(searchResultStore);
|
|
11281
11307
|
const currentFilters = computed(() => filters.value);
|
|
11308
|
+
const currentDisplayFilters = computed(
|
|
11309
|
+
() => hideFiltersOnExactMatchForKeys.value.length ? displayFilters.value.filter(
|
|
11310
|
+
(f2) => {
|
|
11311
|
+
var _a;
|
|
11312
|
+
return !((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.includes(f2.key)) && getNormalizedString(currentQueryText.value) !== getNormalizedString(f2.label);
|
|
11313
|
+
}
|
|
11314
|
+
) : displayFilters.value
|
|
11315
|
+
);
|
|
11282
11316
|
const hasFilters = computed(() => {
|
|
11283
11317
|
var _a;
|
|
11284
|
-
return ((_a =
|
|
11318
|
+
return ((_a = currentDisplayFilters.value) == null ? void 0 : _a.length) > 0;
|
|
11285
11319
|
});
|
|
11286
11320
|
const handleClearAll = () => {
|
|
11287
11321
|
paramsStore.removeAllFilters();
|
|
@@ -11338,7 +11372,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11338
11372
|
]),
|
|
11339
11373
|
!_ctx.expandable || isOpen.value ? (openBlock(), createElementBlock("div", _hoisted_3$q, [
|
|
11340
11374
|
createBaseVNode("div", _hoisted_4$k, [
|
|
11341
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
11375
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(currentDisplayFilters.value, (filter) => {
|
|
11342
11376
|
return openBlock(), createBlock(_sfc_main$R, {
|
|
11343
11377
|
key: filter.key + "_" + filter.value,
|
|
11344
11378
|
filter,
|
|
@@ -11551,11 +11585,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11551
11585
|
emits: ["select"],
|
|
11552
11586
|
setup(__props, { emit: emit2 }) {
|
|
11553
11587
|
const props = __props;
|
|
11588
|
+
const searchResultStore = useSearchResultStore();
|
|
11554
11589
|
const facet = computed(() => {
|
|
11555
11590
|
var _a;
|
|
11556
11591
|
return (_a = props.facet) != null ? _a : { type: "terms", items: [], key: "" };
|
|
11557
11592
|
});
|
|
11558
|
-
const
|
|
11593
|
+
const currentFiltersValue = computed(() => {
|
|
11559
11594
|
var _a;
|
|
11560
11595
|
return (_a = props.currentFilters) != null ? _a : [];
|
|
11561
11596
|
});
|
|
@@ -11566,22 +11601,23 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11566
11601
|
});
|
|
11567
11602
|
const allValues = computed(() => {
|
|
11568
11603
|
var _a, _b;
|
|
11569
|
-
return (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : [];
|
|
11604
|
+
return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
|
|
11570
11605
|
});
|
|
11571
11606
|
const displayValues = computed(() => {
|
|
11572
11607
|
return filteredValues.value.slice(0, itemLimit.value).map((v) => __spreadProps2(__spreadValues2({}, v), { title: getDisplayValue(v.title) }));
|
|
11573
11608
|
});
|
|
11574
11609
|
const filteredValues = computed(() => {
|
|
11575
|
-
|
|
11610
|
+
var _a, _b;
|
|
11611
|
+
return isFilterable.value ? (_a = allValues.value) == null ? void 0 : _a.filter(
|
|
11576
11612
|
(v) => {
|
|
11577
|
-
var
|
|
11578
|
-
return (
|
|
11613
|
+
var _a2;
|
|
11614
|
+
return (_a2 = getNormalizedString(v.title)) == null ? void 0 : _a2.includes(getNormalizedString(termFilter.value));
|
|
11579
11615
|
}
|
|
11580
|
-
) : allValues.value;
|
|
11616
|
+
) : (_b = allValues.value) != null ? _b : [];
|
|
11581
11617
|
});
|
|
11582
11618
|
const isFilterable = computed(() => {
|
|
11583
|
-
var _a, _b;
|
|
11584
|
-
return allValues.value.length >= ((
|
|
11619
|
+
var _a, _b, _c;
|
|
11620
|
+
return ((_a = allValues.value) == null ? void 0 : _a.length) >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
|
|
11585
11621
|
});
|
|
11586
11622
|
const isRange = computed(() => {
|
|
11587
11623
|
return facet.value.type === "range";
|
|
@@ -11605,7 +11641,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11605
11641
|
};
|
|
11606
11642
|
const isChecked = (item) => {
|
|
11607
11643
|
var _a, _b;
|
|
11608
|
-
let selectedItems = (_a =
|
|
11644
|
+
let selectedItems = (_a = currentFiltersValue.value) != null ? _a : [];
|
|
11609
11645
|
selectedItems = isRange.value && selectedItems ? [rangeFilterToString(selectedItems)] : selectedItems;
|
|
11610
11646
|
return selectedItems == null ? void 0 : selectedItems.includes((_b = item.title) == null ? void 0 : _b.toString());
|
|
11611
11647
|
};
|
package/dist/lupaSearch.js
CHANGED
|
@@ -7382,23 +7382,34 @@ const DEFAULT_OPTIONS_RESULTS$1 = {
|
|
|
7382
7382
|
};
|
|
7383
7383
|
const useScreenStore = defineStore("screen", () => {
|
|
7384
7384
|
const screenWidth = ref(1e3);
|
|
7385
|
+
const optionsStore = useOptionsStore();
|
|
7386
|
+
const configuredGridSizes = computed(() => {
|
|
7387
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
7388
|
+
return {
|
|
7389
|
+
smMin: (_d = (_c = (_b = (_a = optionsStore.searchResultOptions) == null ? void 0 : _a.grid) == null ? void 0 : _b.sizes) == null ? void 0 : _c.sm) != null ? _d : S_MIN_WIDTH,
|
|
7390
|
+
mdMin: (_h = (_g = (_f = (_e = optionsStore.searchResultOptions) == null ? void 0 : _e.grid) == null ? void 0 : _f.sizes) == null ? void 0 : _g.md) != null ? _h : MD_MIN_WIDTH,
|
|
7391
|
+
lMin: (_l = (_k = (_j = (_i = optionsStore.searchResultOptions) == null ? void 0 : _i.grid) == null ? void 0 : _j.sizes) == null ? void 0 : _k.l) != null ? _l : L_MIN_WIDTH,
|
|
7392
|
+
xlMin: (_p = (_o = (_n = (_m = optionsStore.searchResultOptions) == null ? void 0 : _m.grid) == null ? void 0 : _n.sizes) == null ? void 0 : _o.xl) != null ? _p : XL_MIN_WIDTH
|
|
7393
|
+
};
|
|
7394
|
+
});
|
|
7385
7395
|
const currentScreenWidth = computed(() => {
|
|
7386
7396
|
const width = screenWidth.value;
|
|
7387
|
-
if (width <=
|
|
7397
|
+
if (width <= configuredGridSizes.value.smMin) {
|
|
7388
7398
|
return "xs";
|
|
7389
|
-
} else if (width >
|
|
7399
|
+
} else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
|
|
7390
7400
|
return "sm";
|
|
7391
|
-
} else if (width >
|
|
7401
|
+
} else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
|
|
7392
7402
|
return "md";
|
|
7393
|
-
} else if (width >
|
|
7403
|
+
} else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
|
|
7394
7404
|
return "l";
|
|
7395
7405
|
} else {
|
|
7396
7406
|
return "xl";
|
|
7397
7407
|
}
|
|
7398
7408
|
});
|
|
7399
|
-
const isMobileWidth = computed(
|
|
7400
|
-
|
|
7401
|
-
|
|
7409
|
+
const isMobileWidth = computed(() => {
|
|
7410
|
+
var _a;
|
|
7411
|
+
return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
|
|
7412
|
+
});
|
|
7402
7413
|
const setScreenWidth = ({ width }) => {
|
|
7403
7414
|
screenWidth.value = width;
|
|
7404
7415
|
};
|
|
@@ -9407,6 +9418,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9407
9418
|
const isMobileSidebarVisible = ref(false);
|
|
9408
9419
|
const optionsStore = useOptionsStore();
|
|
9409
9420
|
const paramsStore = useParamsStore();
|
|
9421
|
+
const screenStore = useScreenStore();
|
|
9410
9422
|
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
9411
9423
|
const facets = computed(() => searchResult.value.facets);
|
|
9412
9424
|
const filters = computed(() => searchResult.value.filters);
|
|
@@ -9452,6 +9464,10 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9452
9464
|
var _a;
|
|
9453
9465
|
return Object.keys((_a = filters.value) != null ? _a : {}).length > 0;
|
|
9454
9466
|
});
|
|
9467
|
+
const hideFiltersOnExactMatchForKeys = computed(() => {
|
|
9468
|
+
var _a, _b, _c, _d;
|
|
9469
|
+
return (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.filters) == null ? void 0 : _b.facets) == null ? void 0 : _c.hideFiltersOnExactMatchForKeys) != null ? _d : [];
|
|
9470
|
+
});
|
|
9455
9471
|
const itemRange = computed(() => {
|
|
9456
9472
|
var _a, _b;
|
|
9457
9473
|
const limit = (_a = paramsStore.limit) != null ? _a : 0;
|
|
@@ -9505,20 +9521,13 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9505
9521
|
return { searchResult: newSearchResult };
|
|
9506
9522
|
};
|
|
9507
9523
|
const setColumnCount = ({ width, grid }) => {
|
|
9524
|
+
var _a;
|
|
9508
9525
|
if (!width || !grid) {
|
|
9509
9526
|
return;
|
|
9510
9527
|
}
|
|
9511
|
-
|
|
9512
|
-
|
|
9513
|
-
|
|
9514
|
-
columnCount.value = grid.columns.sm;
|
|
9515
|
-
} else if (width > MD_MIN_WIDTH && width <= L_MIN_WIDTH) {
|
|
9516
|
-
columnCount.value = grid.columns.md;
|
|
9517
|
-
} else if (width > L_MIN_WIDTH && width <= XL_MIN_WIDTH) {
|
|
9518
|
-
columnCount.value = grid.columns.l;
|
|
9519
|
-
} else {
|
|
9520
|
-
columnCount.value = grid.columns.xl;
|
|
9521
|
-
}
|
|
9528
|
+
const { currentScreenWidth } = storeToRefs(screenStore);
|
|
9529
|
+
const screenWidth = (_a = currentScreenWidth.value) != null ? _a : "xl";
|
|
9530
|
+
columnCount.value = grid.columns[screenWidth];
|
|
9522
9531
|
};
|
|
9523
9532
|
const setAddToCartAmount = (newAddToCartAmount) => {
|
|
9524
9533
|
if (!newAddToCartAmount) {
|
|
@@ -9538,6 +9547,15 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9538
9547
|
const clearSearchResult = () => {
|
|
9539
9548
|
searchResult.value = {};
|
|
9540
9549
|
};
|
|
9550
|
+
const filterVisibleFilterValues = (key, items = []) => {
|
|
9551
|
+
var _a;
|
|
9552
|
+
if (!((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.length) || !hideFiltersOnExactMatchForKeys.value.includes(key) || !items.length) {
|
|
9553
|
+
return items;
|
|
9554
|
+
}
|
|
9555
|
+
const searchInput = getNormalizedString(currentQueryText.value);
|
|
9556
|
+
const hasExactMatch = items.some((item) => getNormalizedString(item.title) === searchInput);
|
|
9557
|
+
return hasExactMatch ? items.filter((item) => getNormalizedString(item.title) === searchInput) : items;
|
|
9558
|
+
};
|
|
9541
9559
|
return {
|
|
9542
9560
|
isMobileSidebarVisible,
|
|
9543
9561
|
searchResult,
|
|
@@ -9557,6 +9575,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9557
9575
|
hasAnyFilter,
|
|
9558
9576
|
itemRange,
|
|
9559
9577
|
isPageEmpty,
|
|
9578
|
+
hideFiltersOnExactMatchForKeys,
|
|
9560
9579
|
setSidebarState,
|
|
9561
9580
|
queryFacet,
|
|
9562
9581
|
add: add2,
|
|
@@ -9564,7 +9583,8 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9564
9583
|
setAddToCartAmount,
|
|
9565
9584
|
setLayout,
|
|
9566
9585
|
setLoading,
|
|
9567
|
-
clearSearchResult
|
|
9586
|
+
clearSearchResult,
|
|
9587
|
+
filterVisibleFilterValues
|
|
9568
9588
|
};
|
|
9569
9589
|
});
|
|
9570
9590
|
const _hoisted_1$12 = { class: "lupa-search-box-add-to-cart-wrapper" };
|
|
@@ -11277,11 +11297,25 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
11277
11297
|
const paramsStore = useParamsStore();
|
|
11278
11298
|
const optionStore = useOptionsStore();
|
|
11279
11299
|
const searchResultStore = useSearchResultStore();
|
|
11280
|
-
const {
|
|
11300
|
+
const {
|
|
11301
|
+
filters,
|
|
11302
|
+
displayFilters,
|
|
11303
|
+
currentFilterCount,
|
|
11304
|
+
hideFiltersOnExactMatchForKeys,
|
|
11305
|
+
currentQueryText
|
|
11306
|
+
} = storeToRefs(searchResultStore);
|
|
11281
11307
|
const currentFilters = computed(() => filters.value);
|
|
11308
|
+
const currentDisplayFilters = computed(
|
|
11309
|
+
() => hideFiltersOnExactMatchForKeys.value.length ? displayFilters.value.filter(
|
|
11310
|
+
(f2) => {
|
|
11311
|
+
var _a;
|
|
11312
|
+
return !((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.includes(f2.key)) && getNormalizedString(currentQueryText.value) !== getNormalizedString(f2.label);
|
|
11313
|
+
}
|
|
11314
|
+
) : displayFilters.value
|
|
11315
|
+
);
|
|
11282
11316
|
const hasFilters = computed(() => {
|
|
11283
11317
|
var _a;
|
|
11284
|
-
return ((_a =
|
|
11318
|
+
return ((_a = currentDisplayFilters.value) == null ? void 0 : _a.length) > 0;
|
|
11285
11319
|
});
|
|
11286
11320
|
const handleClearAll = () => {
|
|
11287
11321
|
paramsStore.removeAllFilters();
|
|
@@ -11338,7 +11372,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
11338
11372
|
]),
|
|
11339
11373
|
!_ctx.expandable || isOpen.value ? (openBlock(), createElementBlock("div", _hoisted_3$q, [
|
|
11340
11374
|
createBaseVNode("div", _hoisted_4$k, [
|
|
11341
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
11375
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(currentDisplayFilters.value, (filter) => {
|
|
11342
11376
|
return openBlock(), createBlock(_sfc_main$R, {
|
|
11343
11377
|
key: filter.key + "_" + filter.value,
|
|
11344
11378
|
filter,
|
|
@@ -11551,11 +11585,12 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
11551
11585
|
emits: ["select"],
|
|
11552
11586
|
setup(__props, { emit: emit2 }) {
|
|
11553
11587
|
const props = __props;
|
|
11588
|
+
const searchResultStore = useSearchResultStore();
|
|
11554
11589
|
const facet = computed(() => {
|
|
11555
11590
|
var _a;
|
|
11556
11591
|
return (_a = props.facet) != null ? _a : { type: "terms", items: [], key: "" };
|
|
11557
11592
|
});
|
|
11558
|
-
const
|
|
11593
|
+
const currentFiltersValue = computed(() => {
|
|
11559
11594
|
var _a;
|
|
11560
11595
|
return (_a = props.currentFilters) != null ? _a : [];
|
|
11561
11596
|
});
|
|
@@ -11566,22 +11601,23 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
11566
11601
|
});
|
|
11567
11602
|
const allValues = computed(() => {
|
|
11568
11603
|
var _a, _b;
|
|
11569
|
-
return (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : [];
|
|
11604
|
+
return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
|
|
11570
11605
|
});
|
|
11571
11606
|
const displayValues = computed(() => {
|
|
11572
11607
|
return filteredValues.value.slice(0, itemLimit.value).map((v) => __spreadProps2(__spreadValues2({}, v), { title: getDisplayValue(v.title) }));
|
|
11573
11608
|
});
|
|
11574
11609
|
const filteredValues = computed(() => {
|
|
11575
|
-
|
|
11610
|
+
var _a, _b;
|
|
11611
|
+
return isFilterable.value ? (_a = allValues.value) == null ? void 0 : _a.filter(
|
|
11576
11612
|
(v) => {
|
|
11577
|
-
var
|
|
11578
|
-
return (
|
|
11613
|
+
var _a2;
|
|
11614
|
+
return (_a2 = getNormalizedString(v.title)) == null ? void 0 : _a2.includes(getNormalizedString(termFilter.value));
|
|
11579
11615
|
}
|
|
11580
|
-
) : allValues.value;
|
|
11616
|
+
) : (_b = allValues.value) != null ? _b : [];
|
|
11581
11617
|
});
|
|
11582
11618
|
const isFilterable = computed(() => {
|
|
11583
|
-
var _a, _b;
|
|
11584
|
-
return allValues.value.length >= ((
|
|
11619
|
+
var _a, _b, _c;
|
|
11620
|
+
return ((_a = allValues.value) == null ? void 0 : _a.length) >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
|
|
11585
11621
|
});
|
|
11586
11622
|
const isRange = computed(() => {
|
|
11587
11623
|
return facet.value.type === "range";
|
|
@@ -11605,7 +11641,7 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
11605
11641
|
};
|
|
11606
11642
|
const isChecked = (item) => {
|
|
11607
11643
|
var _a, _b;
|
|
11608
|
-
let selectedItems = (_a =
|
|
11644
|
+
let selectedItems = (_a = currentFiltersValue.value) != null ? _a : [];
|
|
11609
11645
|
selectedItems = isRange.value && selectedItems ? [rangeFilterToString(selectedItems)] : selectedItems;
|
|
11610
11646
|
return selectedItems == null ? void 0 : selectedItems.includes((_b = item.title) == null ? void 0 : _b.toString());
|
|
11611
11647
|
};
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -7380,23 +7380,34 @@ const DEFAULT_OPTIONS_RESULTS$1 = {
|
|
|
7380
7380
|
};
|
|
7381
7381
|
const useScreenStore = defineStore("screen", () => {
|
|
7382
7382
|
const screenWidth = ref(1e3);
|
|
7383
|
+
const optionsStore = useOptionsStore();
|
|
7384
|
+
const configuredGridSizes = computed(() => {
|
|
7385
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
7386
|
+
return {
|
|
7387
|
+
smMin: (_d = (_c = (_b = (_a = optionsStore.searchResultOptions) == null ? void 0 : _a.grid) == null ? void 0 : _b.sizes) == null ? void 0 : _c.sm) != null ? _d : S_MIN_WIDTH,
|
|
7388
|
+
mdMin: (_h = (_g = (_f = (_e = optionsStore.searchResultOptions) == null ? void 0 : _e.grid) == null ? void 0 : _f.sizes) == null ? void 0 : _g.md) != null ? _h : MD_MIN_WIDTH,
|
|
7389
|
+
lMin: (_l = (_k = (_j = (_i = optionsStore.searchResultOptions) == null ? void 0 : _i.grid) == null ? void 0 : _j.sizes) == null ? void 0 : _k.l) != null ? _l : L_MIN_WIDTH,
|
|
7390
|
+
xlMin: (_p = (_o = (_n = (_m = optionsStore.searchResultOptions) == null ? void 0 : _m.grid) == null ? void 0 : _n.sizes) == null ? void 0 : _o.xl) != null ? _p : XL_MIN_WIDTH
|
|
7391
|
+
};
|
|
7392
|
+
});
|
|
7383
7393
|
const currentScreenWidth = computed(() => {
|
|
7384
7394
|
const width = screenWidth.value;
|
|
7385
|
-
if (width <=
|
|
7395
|
+
if (width <= configuredGridSizes.value.smMin) {
|
|
7386
7396
|
return "xs";
|
|
7387
|
-
} else if (width >
|
|
7397
|
+
} else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
|
|
7388
7398
|
return "sm";
|
|
7389
|
-
} else if (width >
|
|
7399
|
+
} else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
|
|
7390
7400
|
return "md";
|
|
7391
|
-
} else if (width >
|
|
7401
|
+
} else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
|
|
7392
7402
|
return "l";
|
|
7393
7403
|
} else {
|
|
7394
7404
|
return "xl";
|
|
7395
7405
|
}
|
|
7396
7406
|
});
|
|
7397
|
-
const isMobileWidth = computed(
|
|
7398
|
-
|
|
7399
|
-
|
|
7407
|
+
const isMobileWidth = computed(() => {
|
|
7408
|
+
var _a;
|
|
7409
|
+
return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
|
|
7410
|
+
});
|
|
7400
7411
|
const setScreenWidth = ({ width }) => {
|
|
7401
7412
|
screenWidth.value = width;
|
|
7402
7413
|
};
|
|
@@ -9405,6 +9416,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9405
9416
|
const isMobileSidebarVisible = ref(false);
|
|
9406
9417
|
const optionsStore = useOptionsStore();
|
|
9407
9418
|
const paramsStore = useParamsStore();
|
|
9419
|
+
const screenStore = useScreenStore();
|
|
9408
9420
|
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
9409
9421
|
const facets = computed(() => searchResult.value.facets);
|
|
9410
9422
|
const filters = computed(() => searchResult.value.filters);
|
|
@@ -9450,6 +9462,10 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9450
9462
|
var _a;
|
|
9451
9463
|
return Object.keys((_a = filters.value) != null ? _a : {}).length > 0;
|
|
9452
9464
|
});
|
|
9465
|
+
const hideFiltersOnExactMatchForKeys = computed(() => {
|
|
9466
|
+
var _a, _b, _c, _d;
|
|
9467
|
+
return (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.filters) == null ? void 0 : _b.facets) == null ? void 0 : _c.hideFiltersOnExactMatchForKeys) != null ? _d : [];
|
|
9468
|
+
});
|
|
9453
9469
|
const itemRange = computed(() => {
|
|
9454
9470
|
var _a, _b;
|
|
9455
9471
|
const limit = (_a = paramsStore.limit) != null ? _a : 0;
|
|
@@ -9503,20 +9519,13 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9503
9519
|
return { searchResult: newSearchResult };
|
|
9504
9520
|
};
|
|
9505
9521
|
const setColumnCount = ({ width, grid }) => {
|
|
9522
|
+
var _a;
|
|
9506
9523
|
if (!width || !grid) {
|
|
9507
9524
|
return;
|
|
9508
9525
|
}
|
|
9509
|
-
|
|
9510
|
-
|
|
9511
|
-
|
|
9512
|
-
columnCount.value = grid.columns.sm;
|
|
9513
|
-
} else if (width > MD_MIN_WIDTH && width <= L_MIN_WIDTH) {
|
|
9514
|
-
columnCount.value = grid.columns.md;
|
|
9515
|
-
} else if (width > L_MIN_WIDTH && width <= XL_MIN_WIDTH) {
|
|
9516
|
-
columnCount.value = grid.columns.l;
|
|
9517
|
-
} else {
|
|
9518
|
-
columnCount.value = grid.columns.xl;
|
|
9519
|
-
}
|
|
9526
|
+
const { currentScreenWidth } = storeToRefs(screenStore);
|
|
9527
|
+
const screenWidth = (_a = currentScreenWidth.value) != null ? _a : "xl";
|
|
9528
|
+
columnCount.value = grid.columns[screenWidth];
|
|
9520
9529
|
};
|
|
9521
9530
|
const setAddToCartAmount = (newAddToCartAmount) => {
|
|
9522
9531
|
if (!newAddToCartAmount) {
|
|
@@ -9536,6 +9545,15 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9536
9545
|
const clearSearchResult = () => {
|
|
9537
9546
|
searchResult.value = {};
|
|
9538
9547
|
};
|
|
9548
|
+
const filterVisibleFilterValues = (key, items = []) => {
|
|
9549
|
+
var _a;
|
|
9550
|
+
if (!((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.length) || !hideFiltersOnExactMatchForKeys.value.includes(key) || !items.length) {
|
|
9551
|
+
return items;
|
|
9552
|
+
}
|
|
9553
|
+
const searchInput = getNormalizedString(currentQueryText.value);
|
|
9554
|
+
const hasExactMatch = items.some((item) => getNormalizedString(item.title) === searchInput);
|
|
9555
|
+
return hasExactMatch ? items.filter((item) => getNormalizedString(item.title) === searchInput) : items;
|
|
9556
|
+
};
|
|
9539
9557
|
return {
|
|
9540
9558
|
isMobileSidebarVisible,
|
|
9541
9559
|
searchResult,
|
|
@@ -9555,6 +9573,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9555
9573
|
hasAnyFilter,
|
|
9556
9574
|
itemRange,
|
|
9557
9575
|
isPageEmpty,
|
|
9576
|
+
hideFiltersOnExactMatchForKeys,
|
|
9558
9577
|
setSidebarState,
|
|
9559
9578
|
queryFacet,
|
|
9560
9579
|
add: add2,
|
|
@@ -9562,7 +9581,8 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
9562
9581
|
setAddToCartAmount,
|
|
9563
9582
|
setLayout,
|
|
9564
9583
|
setLoading,
|
|
9565
|
-
clearSearchResult
|
|
9584
|
+
clearSearchResult,
|
|
9585
|
+
filterVisibleFilterValues
|
|
9566
9586
|
};
|
|
9567
9587
|
});
|
|
9568
9588
|
const _hoisted_1$12 = { class: "lupa-search-box-add-to-cart-wrapper" };
|
|
@@ -11275,11 +11295,25 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
11275
11295
|
const paramsStore = useParamsStore();
|
|
11276
11296
|
const optionStore = useOptionsStore();
|
|
11277
11297
|
const searchResultStore = useSearchResultStore();
|
|
11278
|
-
const {
|
|
11298
|
+
const {
|
|
11299
|
+
filters,
|
|
11300
|
+
displayFilters,
|
|
11301
|
+
currentFilterCount,
|
|
11302
|
+
hideFiltersOnExactMatchForKeys,
|
|
11303
|
+
currentQueryText
|
|
11304
|
+
} = storeToRefs(searchResultStore);
|
|
11279
11305
|
const currentFilters = computed(() => filters.value);
|
|
11306
|
+
const currentDisplayFilters = computed(
|
|
11307
|
+
() => hideFiltersOnExactMatchForKeys.value.length ? displayFilters.value.filter(
|
|
11308
|
+
(f2) => {
|
|
11309
|
+
var _a;
|
|
11310
|
+
return !((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.includes(f2.key)) && getNormalizedString(currentQueryText.value) !== getNormalizedString(f2.label);
|
|
11311
|
+
}
|
|
11312
|
+
) : displayFilters.value
|
|
11313
|
+
);
|
|
11280
11314
|
const hasFilters = computed(() => {
|
|
11281
11315
|
var _a;
|
|
11282
|
-
return ((_a =
|
|
11316
|
+
return ((_a = currentDisplayFilters.value) == null ? void 0 : _a.length) > 0;
|
|
11283
11317
|
});
|
|
11284
11318
|
const handleClearAll = () => {
|
|
11285
11319
|
paramsStore.removeAllFilters();
|
|
@@ -11336,7 +11370,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
11336
11370
|
]),
|
|
11337
11371
|
!_ctx.expandable || isOpen.value ? (openBlock(), createElementBlock("div", _hoisted_3$q, [
|
|
11338
11372
|
createBaseVNode("div", _hoisted_4$k, [
|
|
11339
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
11373
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(currentDisplayFilters.value, (filter) => {
|
|
11340
11374
|
return openBlock(), createBlock(_sfc_main$R, {
|
|
11341
11375
|
key: filter.key + "_" + filter.value,
|
|
11342
11376
|
filter,
|
|
@@ -11549,11 +11583,12 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
11549
11583
|
emits: ["select"],
|
|
11550
11584
|
setup(__props, { emit: emit2 }) {
|
|
11551
11585
|
const props = __props;
|
|
11586
|
+
const searchResultStore = useSearchResultStore();
|
|
11552
11587
|
const facet = computed(() => {
|
|
11553
11588
|
var _a;
|
|
11554
11589
|
return (_a = props.facet) != null ? _a : { type: "terms", items: [], key: "" };
|
|
11555
11590
|
});
|
|
11556
|
-
const
|
|
11591
|
+
const currentFiltersValue = computed(() => {
|
|
11557
11592
|
var _a;
|
|
11558
11593
|
return (_a = props.currentFilters) != null ? _a : [];
|
|
11559
11594
|
});
|
|
@@ -11564,22 +11599,23 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
11564
11599
|
});
|
|
11565
11600
|
const allValues = computed(() => {
|
|
11566
11601
|
var _a, _b;
|
|
11567
|
-
return (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : [];
|
|
11602
|
+
return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
|
|
11568
11603
|
});
|
|
11569
11604
|
const displayValues = computed(() => {
|
|
11570
11605
|
return filteredValues.value.slice(0, itemLimit.value).map((v) => __spreadProps2(__spreadValues2({}, v), { title: getDisplayValue(v.title) }));
|
|
11571
11606
|
});
|
|
11572
11607
|
const filteredValues = computed(() => {
|
|
11573
|
-
|
|
11608
|
+
var _a, _b;
|
|
11609
|
+
return isFilterable.value ? (_a = allValues.value) == null ? void 0 : _a.filter(
|
|
11574
11610
|
(v) => {
|
|
11575
|
-
var
|
|
11576
|
-
return (
|
|
11611
|
+
var _a2;
|
|
11612
|
+
return (_a2 = getNormalizedString(v.title)) == null ? void 0 : _a2.includes(getNormalizedString(termFilter.value));
|
|
11577
11613
|
}
|
|
11578
|
-
) : allValues.value;
|
|
11614
|
+
) : (_b = allValues.value) != null ? _b : [];
|
|
11579
11615
|
});
|
|
11580
11616
|
const isFilterable = computed(() => {
|
|
11581
|
-
var _a, _b;
|
|
11582
|
-
return allValues.value.length >= ((
|
|
11617
|
+
var _a, _b, _c;
|
|
11618
|
+
return ((_a = allValues.value) == null ? void 0 : _a.length) >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
|
|
11583
11619
|
});
|
|
11584
11620
|
const isRange = computed(() => {
|
|
11585
11621
|
return facet.value.type === "range";
|
|
@@ -11603,7 +11639,7 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
11603
11639
|
};
|
|
11604
11640
|
const isChecked = (item) => {
|
|
11605
11641
|
var _a, _b;
|
|
11606
|
-
let selectedItems = (_a =
|
|
11642
|
+
let selectedItems = (_a = currentFiltersValue.value) != null ? _a : [];
|
|
11607
11643
|
selectedItems = isRange.value && selectedItems ? [rangeFilterToString(selectedItems)] : selectedItems;
|
|
11608
11644
|
return selectedItems == null ? void 0 : selectedItems.includes((_b = item.title) == null ? void 0 : _b.toString());
|
|
11609
11645
|
};
|
package/dist/lupaSearch.umd.js
CHANGED
|
@@ -7384,23 +7384,34 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7384
7384
|
};
|
|
7385
7385
|
const useScreenStore = defineStore("screen", () => {
|
|
7386
7386
|
const screenWidth = ref(1e3);
|
|
7387
|
+
const optionsStore = useOptionsStore();
|
|
7388
|
+
const configuredGridSizes = computed(() => {
|
|
7389
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
7390
|
+
return {
|
|
7391
|
+
smMin: (_d = (_c = (_b = (_a = optionsStore.searchResultOptions) == null ? void 0 : _a.grid) == null ? void 0 : _b.sizes) == null ? void 0 : _c.sm) != null ? _d : S_MIN_WIDTH,
|
|
7392
|
+
mdMin: (_h = (_g = (_f = (_e = optionsStore.searchResultOptions) == null ? void 0 : _e.grid) == null ? void 0 : _f.sizes) == null ? void 0 : _g.md) != null ? _h : MD_MIN_WIDTH,
|
|
7393
|
+
lMin: (_l = (_k = (_j = (_i = optionsStore.searchResultOptions) == null ? void 0 : _i.grid) == null ? void 0 : _j.sizes) == null ? void 0 : _k.l) != null ? _l : L_MIN_WIDTH,
|
|
7394
|
+
xlMin: (_p = (_o = (_n = (_m = optionsStore.searchResultOptions) == null ? void 0 : _m.grid) == null ? void 0 : _n.sizes) == null ? void 0 : _o.xl) != null ? _p : XL_MIN_WIDTH
|
|
7395
|
+
};
|
|
7396
|
+
});
|
|
7387
7397
|
const currentScreenWidth = computed(() => {
|
|
7388
7398
|
const width = screenWidth.value;
|
|
7389
|
-
if (width <=
|
|
7399
|
+
if (width <= configuredGridSizes.value.smMin) {
|
|
7390
7400
|
return "xs";
|
|
7391
|
-
} else if (width >
|
|
7401
|
+
} else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
|
|
7392
7402
|
return "sm";
|
|
7393
|
-
} else if (width >
|
|
7403
|
+
} else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
|
|
7394
7404
|
return "md";
|
|
7395
|
-
} else if (width >
|
|
7405
|
+
} else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
|
|
7396
7406
|
return "l";
|
|
7397
7407
|
} else {
|
|
7398
7408
|
return "xl";
|
|
7399
7409
|
}
|
|
7400
7410
|
});
|
|
7401
|
-
const isMobileWidth = computed(
|
|
7402
|
-
|
|
7403
|
-
|
|
7411
|
+
const isMobileWidth = computed(() => {
|
|
7412
|
+
var _a;
|
|
7413
|
+
return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
|
|
7414
|
+
});
|
|
7404
7415
|
const setScreenWidth = ({ width }) => {
|
|
7405
7416
|
screenWidth.value = width;
|
|
7406
7417
|
};
|
|
@@ -9409,6 +9420,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9409
9420
|
const isMobileSidebarVisible = ref(false);
|
|
9410
9421
|
const optionsStore = useOptionsStore();
|
|
9411
9422
|
const paramsStore = useParamsStore();
|
|
9423
|
+
const screenStore = useScreenStore();
|
|
9412
9424
|
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
9413
9425
|
const facets = computed(() => searchResult.value.facets);
|
|
9414
9426
|
const filters = computed(() => searchResult.value.filters);
|
|
@@ -9454,6 +9466,10 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9454
9466
|
var _a;
|
|
9455
9467
|
return Object.keys((_a = filters.value) != null ? _a : {}).length > 0;
|
|
9456
9468
|
});
|
|
9469
|
+
const hideFiltersOnExactMatchForKeys = computed(() => {
|
|
9470
|
+
var _a, _b, _c, _d;
|
|
9471
|
+
return (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.filters) == null ? void 0 : _b.facets) == null ? void 0 : _c.hideFiltersOnExactMatchForKeys) != null ? _d : [];
|
|
9472
|
+
});
|
|
9457
9473
|
const itemRange = computed(() => {
|
|
9458
9474
|
var _a, _b;
|
|
9459
9475
|
const limit = (_a = paramsStore.limit) != null ? _a : 0;
|
|
@@ -9507,20 +9523,13 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9507
9523
|
return { searchResult: newSearchResult };
|
|
9508
9524
|
};
|
|
9509
9525
|
const setColumnCount = ({ width, grid }) => {
|
|
9526
|
+
var _a;
|
|
9510
9527
|
if (!width || !grid) {
|
|
9511
9528
|
return;
|
|
9512
9529
|
}
|
|
9513
|
-
|
|
9514
|
-
|
|
9515
|
-
|
|
9516
|
-
columnCount.value = grid.columns.sm;
|
|
9517
|
-
} else if (width > MD_MIN_WIDTH && width <= L_MIN_WIDTH) {
|
|
9518
|
-
columnCount.value = grid.columns.md;
|
|
9519
|
-
} else if (width > L_MIN_WIDTH && width <= XL_MIN_WIDTH) {
|
|
9520
|
-
columnCount.value = grid.columns.l;
|
|
9521
|
-
} else {
|
|
9522
|
-
columnCount.value = grid.columns.xl;
|
|
9523
|
-
}
|
|
9530
|
+
const { currentScreenWidth } = storeToRefs(screenStore);
|
|
9531
|
+
const screenWidth = (_a = currentScreenWidth.value) != null ? _a : "xl";
|
|
9532
|
+
columnCount.value = grid.columns[screenWidth];
|
|
9524
9533
|
};
|
|
9525
9534
|
const setAddToCartAmount = (newAddToCartAmount) => {
|
|
9526
9535
|
if (!newAddToCartAmount) {
|
|
@@ -9540,6 +9549,15 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9540
9549
|
const clearSearchResult = () => {
|
|
9541
9550
|
searchResult.value = {};
|
|
9542
9551
|
};
|
|
9552
|
+
const filterVisibleFilterValues = (key, items = []) => {
|
|
9553
|
+
var _a;
|
|
9554
|
+
if (!((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.length) || !hideFiltersOnExactMatchForKeys.value.includes(key) || !items.length) {
|
|
9555
|
+
return items;
|
|
9556
|
+
}
|
|
9557
|
+
const searchInput = getNormalizedString(currentQueryText.value);
|
|
9558
|
+
const hasExactMatch = items.some((item) => getNormalizedString(item.title) === searchInput);
|
|
9559
|
+
return hasExactMatch ? items.filter((item) => getNormalizedString(item.title) === searchInput) : items;
|
|
9560
|
+
};
|
|
9543
9561
|
return {
|
|
9544
9562
|
isMobileSidebarVisible,
|
|
9545
9563
|
searchResult,
|
|
@@ -9559,6 +9577,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9559
9577
|
hasAnyFilter,
|
|
9560
9578
|
itemRange,
|
|
9561
9579
|
isPageEmpty,
|
|
9580
|
+
hideFiltersOnExactMatchForKeys,
|
|
9562
9581
|
setSidebarState,
|
|
9563
9582
|
queryFacet,
|
|
9564
9583
|
add: add2,
|
|
@@ -9566,7 +9585,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9566
9585
|
setAddToCartAmount,
|
|
9567
9586
|
setLayout,
|
|
9568
9587
|
setLoading,
|
|
9569
|
-
clearSearchResult
|
|
9588
|
+
clearSearchResult,
|
|
9589
|
+
filterVisibleFilterValues
|
|
9570
9590
|
};
|
|
9571
9591
|
});
|
|
9572
9592
|
const _hoisted_1$12 = { class: "lupa-search-box-add-to-cart-wrapper" };
|
|
@@ -11279,11 +11299,25 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11279
11299
|
const paramsStore = useParamsStore();
|
|
11280
11300
|
const optionStore = useOptionsStore();
|
|
11281
11301
|
const searchResultStore = useSearchResultStore();
|
|
11282
|
-
const {
|
|
11302
|
+
const {
|
|
11303
|
+
filters,
|
|
11304
|
+
displayFilters,
|
|
11305
|
+
currentFilterCount,
|
|
11306
|
+
hideFiltersOnExactMatchForKeys,
|
|
11307
|
+
currentQueryText
|
|
11308
|
+
} = storeToRefs(searchResultStore);
|
|
11283
11309
|
const currentFilters = computed(() => filters.value);
|
|
11310
|
+
const currentDisplayFilters = computed(
|
|
11311
|
+
() => hideFiltersOnExactMatchForKeys.value.length ? displayFilters.value.filter(
|
|
11312
|
+
(f2) => {
|
|
11313
|
+
var _a;
|
|
11314
|
+
return !((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.includes(f2.key)) && getNormalizedString(currentQueryText.value) !== getNormalizedString(f2.label);
|
|
11315
|
+
}
|
|
11316
|
+
) : displayFilters.value
|
|
11317
|
+
);
|
|
11284
11318
|
const hasFilters = computed(() => {
|
|
11285
11319
|
var _a;
|
|
11286
|
-
return ((_a =
|
|
11320
|
+
return ((_a = currentDisplayFilters.value) == null ? void 0 : _a.length) > 0;
|
|
11287
11321
|
});
|
|
11288
11322
|
const handleClearAll = () => {
|
|
11289
11323
|
paramsStore.removeAllFilters();
|
|
@@ -11340,7 +11374,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11340
11374
|
]),
|
|
11341
11375
|
!_ctx.expandable || isOpen.value ? (openBlock(), createElementBlock("div", _hoisted_3$q, [
|
|
11342
11376
|
createBaseVNode("div", _hoisted_4$k, [
|
|
11343
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
11377
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(currentDisplayFilters.value, (filter) => {
|
|
11344
11378
|
return openBlock(), createBlock(_sfc_main$R, {
|
|
11345
11379
|
key: filter.key + "_" + filter.value,
|
|
11346
11380
|
filter,
|
|
@@ -11553,11 +11587,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11553
11587
|
emits: ["select"],
|
|
11554
11588
|
setup(__props, { emit: emit2 }) {
|
|
11555
11589
|
const props = __props;
|
|
11590
|
+
const searchResultStore = useSearchResultStore();
|
|
11556
11591
|
const facet = computed(() => {
|
|
11557
11592
|
var _a;
|
|
11558
11593
|
return (_a = props.facet) != null ? _a : { type: "terms", items: [], key: "" };
|
|
11559
11594
|
});
|
|
11560
|
-
const
|
|
11595
|
+
const currentFiltersValue = computed(() => {
|
|
11561
11596
|
var _a;
|
|
11562
11597
|
return (_a = props.currentFilters) != null ? _a : [];
|
|
11563
11598
|
});
|
|
@@ -11568,22 +11603,23 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11568
11603
|
});
|
|
11569
11604
|
const allValues = computed(() => {
|
|
11570
11605
|
var _a, _b;
|
|
11571
|
-
return (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : [];
|
|
11606
|
+
return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
|
|
11572
11607
|
});
|
|
11573
11608
|
const displayValues = computed(() => {
|
|
11574
11609
|
return filteredValues.value.slice(0, itemLimit.value).map((v) => __spreadProps2(__spreadValues2({}, v), { title: getDisplayValue(v.title) }));
|
|
11575
11610
|
});
|
|
11576
11611
|
const filteredValues = computed(() => {
|
|
11577
|
-
|
|
11612
|
+
var _a, _b;
|
|
11613
|
+
return isFilterable.value ? (_a = allValues.value) == null ? void 0 : _a.filter(
|
|
11578
11614
|
(v) => {
|
|
11579
|
-
var
|
|
11580
|
-
return (
|
|
11615
|
+
var _a2;
|
|
11616
|
+
return (_a2 = getNormalizedString(v.title)) == null ? void 0 : _a2.includes(getNormalizedString(termFilter.value));
|
|
11581
11617
|
}
|
|
11582
|
-
) : allValues.value;
|
|
11618
|
+
) : (_b = allValues.value) != null ? _b : [];
|
|
11583
11619
|
});
|
|
11584
11620
|
const isFilterable = computed(() => {
|
|
11585
|
-
var _a, _b;
|
|
11586
|
-
return allValues.value.length >= ((
|
|
11621
|
+
var _a, _b, _c;
|
|
11622
|
+
return ((_a = allValues.value) == null ? void 0 : _a.length) >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
|
|
11587
11623
|
});
|
|
11588
11624
|
const isRange = computed(() => {
|
|
11589
11625
|
return facet.value.type === "range";
|
|
@@ -11607,7 +11643,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
11607
11643
|
};
|
|
11608
11644
|
const isChecked = (item) => {
|
|
11609
11645
|
var _a, _b;
|
|
11610
|
-
let selectedItems = (_a =
|
|
11646
|
+
let selectedItems = (_a = currentFiltersValue.value) != null ? _a : [];
|
|
11611
11647
|
selectedItems = isRange.value && selectedItems ? [rangeFilterToString(selectedItems)] : selectedItems;
|
|
11612
11648
|
return selectedItems == null ? void 0 : selectedItems.includes((_b = item.title) == null ? void 0 : _b.toString());
|
|
11613
11649
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getlupa/client",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
4
|
"main": "dist/lupaSearch.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@getlupa/client-sdk": "^1.3.4",
|
|
23
|
-
"@getlupa/vue": "0.
|
|
23
|
+
"@getlupa/vue": "0.12.0",
|
|
24
24
|
"@rushstack/eslint-patch": "^1.3.2",
|
|
25
25
|
"@tsconfig/node18": "^2.0.1",
|
|
26
26
|
"@types/jsdom": "^21.1.1",
|