@getlupa/vue 0.11.9 → 0.12.1
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
CHANGED
|
@@ -2158,23 +2158,34 @@ const DEFAULT_OPTIONS_RESULTS = {
|
|
|
2158
2158
|
};
|
|
2159
2159
|
const useScreenStore = defineStore("screen", () => {
|
|
2160
2160
|
const screenWidth = vue.ref(1e3);
|
|
2161
|
+
const optionsStore = useOptionsStore();
|
|
2162
|
+
const configuredGridSizes = vue.computed(() => {
|
|
2163
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2164
|
+
return {
|
|
2165
|
+
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,
|
|
2166
|
+
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,
|
|
2167
|
+
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,
|
|
2168
|
+
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
|
|
2169
|
+
};
|
|
2170
|
+
});
|
|
2161
2171
|
const currentScreenWidth = vue.computed(() => {
|
|
2162
2172
|
const width = screenWidth.value;
|
|
2163
|
-
if (width <=
|
|
2173
|
+
if (width <= configuredGridSizes.value.smMin) {
|
|
2164
2174
|
return "xs";
|
|
2165
|
-
} else if (width >
|
|
2175
|
+
} else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
|
|
2166
2176
|
return "sm";
|
|
2167
|
-
} else if (width >
|
|
2177
|
+
} else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
|
|
2168
2178
|
return "md";
|
|
2169
|
-
} else if (width >
|
|
2179
|
+
} else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
|
|
2170
2180
|
return "l";
|
|
2171
2181
|
} else {
|
|
2172
2182
|
return "xl";
|
|
2173
2183
|
}
|
|
2174
2184
|
});
|
|
2175
|
-
const isMobileWidth = vue.computed(
|
|
2176
|
-
|
|
2177
|
-
|
|
2185
|
+
const isMobileWidth = vue.computed(() => {
|
|
2186
|
+
var _a;
|
|
2187
|
+
return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
|
|
2188
|
+
});
|
|
2178
2189
|
const setScreenWidth = ({ width }) => {
|
|
2179
2190
|
screenWidth.value = width;
|
|
2180
2191
|
};
|
|
@@ -4183,6 +4194,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4183
4194
|
const isMobileSidebarVisible = vue.ref(false);
|
|
4184
4195
|
const optionsStore = useOptionsStore();
|
|
4185
4196
|
const paramsStore = useParamsStore();
|
|
4197
|
+
const screenStore = useScreenStore();
|
|
4186
4198
|
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
4187
4199
|
const facets = vue.computed(() => searchResult.value.facets);
|
|
4188
4200
|
const filters = vue.computed(() => searchResult.value.filters);
|
|
@@ -4228,6 +4240,10 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4228
4240
|
var _a;
|
|
4229
4241
|
return Object.keys((_a = filters.value) != null ? _a : {}).length > 0;
|
|
4230
4242
|
});
|
|
4243
|
+
const hideFiltersOnExactMatchForKeys = vue.computed(() => {
|
|
4244
|
+
var _a, _b, _c, _d;
|
|
4245
|
+
return (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.filters) == null ? void 0 : _b.facets) == null ? void 0 : _c.hideFiltersOnExactMatchForKeys) != null ? _d : [];
|
|
4246
|
+
});
|
|
4231
4247
|
const itemRange = vue.computed(() => {
|
|
4232
4248
|
var _a, _b;
|
|
4233
4249
|
const limit = (_a = paramsStore.limit) != null ? _a : 0;
|
|
@@ -4281,20 +4297,14 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4281
4297
|
return { searchResult: newSearchResult };
|
|
4282
4298
|
};
|
|
4283
4299
|
const setColumnCount = ({ width, grid }) => {
|
|
4300
|
+
var _a;
|
|
4284
4301
|
if (!width || !grid) {
|
|
4285
4302
|
return;
|
|
4286
4303
|
}
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
} else if (width > MD_MIN_WIDTH && width <= L_MIN_WIDTH) {
|
|
4292
|
-
columnCount.value = grid.columns.md;
|
|
4293
|
-
} else if (width > L_MIN_WIDTH && width <= XL_MIN_WIDTH) {
|
|
4294
|
-
columnCount.value = grid.columns.l;
|
|
4295
|
-
} else {
|
|
4296
|
-
columnCount.value = grid.columns.xl;
|
|
4297
|
-
}
|
|
4304
|
+
screenStore.setScreenWidth({ width });
|
|
4305
|
+
const { currentScreenWidth } = storeToRefs(screenStore);
|
|
4306
|
+
const screenWidth = (_a = currentScreenWidth.value) != null ? _a : "xl";
|
|
4307
|
+
columnCount.value = grid.columns[screenWidth];
|
|
4298
4308
|
};
|
|
4299
4309
|
const setAddToCartAmount = (newAddToCartAmount) => {
|
|
4300
4310
|
if (!newAddToCartAmount) {
|
|
@@ -4314,6 +4324,15 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4314
4324
|
const clearSearchResult = () => {
|
|
4315
4325
|
searchResult.value = {};
|
|
4316
4326
|
};
|
|
4327
|
+
const filterVisibleFilterValues = (key, items = []) => {
|
|
4328
|
+
var _a;
|
|
4329
|
+
if (!((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.length) || !hideFiltersOnExactMatchForKeys.value.includes(key) || !items.length) {
|
|
4330
|
+
return items;
|
|
4331
|
+
}
|
|
4332
|
+
const searchInput = getNormalizedString(currentQueryText.value);
|
|
4333
|
+
const hasExactMatch = items.some((item) => getNormalizedString(item.title) === searchInput);
|
|
4334
|
+
return hasExactMatch ? items.filter((item) => getNormalizedString(item.title) === searchInput) : items;
|
|
4335
|
+
};
|
|
4317
4336
|
return {
|
|
4318
4337
|
isMobileSidebarVisible,
|
|
4319
4338
|
searchResult,
|
|
@@ -4333,6 +4352,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4333
4352
|
hasAnyFilter,
|
|
4334
4353
|
itemRange,
|
|
4335
4354
|
isPageEmpty,
|
|
4355
|
+
hideFiltersOnExactMatchForKeys,
|
|
4336
4356
|
setSidebarState,
|
|
4337
4357
|
queryFacet,
|
|
4338
4358
|
add,
|
|
@@ -4340,7 +4360,8 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4340
4360
|
setAddToCartAmount,
|
|
4341
4361
|
setLayout,
|
|
4342
4362
|
setLoading,
|
|
4343
|
-
clearSearchResult
|
|
4363
|
+
clearSearchResult,
|
|
4364
|
+
filterVisibleFilterValues
|
|
4344
4365
|
};
|
|
4345
4366
|
});
|
|
4346
4367
|
const _hoisted_1$12 = { class: "lupa-search-box-add-to-cart-wrapper" };
|
|
@@ -6069,11 +6090,25 @@ const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
|
|
|
6069
6090
|
const paramsStore = useParamsStore();
|
|
6070
6091
|
const optionStore = useOptionsStore();
|
|
6071
6092
|
const searchResultStore = useSearchResultStore();
|
|
6072
|
-
const {
|
|
6093
|
+
const {
|
|
6094
|
+
filters,
|
|
6095
|
+
displayFilters,
|
|
6096
|
+
currentFilterCount,
|
|
6097
|
+
hideFiltersOnExactMatchForKeys,
|
|
6098
|
+
currentQueryText
|
|
6099
|
+
} = storeToRefs(searchResultStore);
|
|
6073
6100
|
const currentFilters = vue.computed(() => filters.value);
|
|
6101
|
+
const currentDisplayFilters = vue.computed(
|
|
6102
|
+
() => hideFiltersOnExactMatchForKeys.value.length ? displayFilters.value.filter(
|
|
6103
|
+
(f2) => {
|
|
6104
|
+
var _a;
|
|
6105
|
+
return !((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.includes(f2.key)) && getNormalizedString(currentQueryText.value) !== getNormalizedString(f2.label);
|
|
6106
|
+
}
|
|
6107
|
+
) : displayFilters.value
|
|
6108
|
+
);
|
|
6074
6109
|
const hasFilters = vue.computed(() => {
|
|
6075
6110
|
var _a;
|
|
6076
|
-
return ((_a =
|
|
6111
|
+
return ((_a = currentDisplayFilters.value) == null ? void 0 : _a.length) > 0;
|
|
6077
6112
|
});
|
|
6078
6113
|
const handleClearAll = () => {
|
|
6079
6114
|
paramsStore.removeAllFilters();
|
|
@@ -6130,7 +6165,7 @@ const _sfc_main$Q = /* @__PURE__ */ vue.defineComponent({
|
|
|
6130
6165
|
]),
|
|
6131
6166
|
!_ctx.expandable || isOpen.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$q, [
|
|
6132
6167
|
vue.createElementVNode("div", _hoisted_4$k, [
|
|
6133
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(
|
|
6168
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(currentDisplayFilters.value, (filter) => {
|
|
6134
6169
|
return vue.openBlock(), vue.createBlock(_sfc_main$R, {
|
|
6135
6170
|
key: filter.key + "_" + filter.value,
|
|
6136
6171
|
filter,
|
|
@@ -6343,11 +6378,12 @@ const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
|
|
|
6343
6378
|
emits: ["select"],
|
|
6344
6379
|
setup(__props, { emit }) {
|
|
6345
6380
|
const props = __props;
|
|
6381
|
+
const searchResultStore = useSearchResultStore();
|
|
6346
6382
|
const facet = vue.computed(() => {
|
|
6347
6383
|
var _a;
|
|
6348
6384
|
return (_a = props.facet) != null ? _a : { type: "terms", items: [], key: "" };
|
|
6349
6385
|
});
|
|
6350
|
-
const
|
|
6386
|
+
const currentFiltersValue = vue.computed(() => {
|
|
6351
6387
|
var _a;
|
|
6352
6388
|
return (_a = props.currentFilters) != null ? _a : [];
|
|
6353
6389
|
});
|
|
@@ -6358,22 +6394,23 @@ const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
|
|
|
6358
6394
|
});
|
|
6359
6395
|
const allValues = vue.computed(() => {
|
|
6360
6396
|
var _a, _b;
|
|
6361
|
-
return (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : [];
|
|
6397
|
+
return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
|
|
6362
6398
|
});
|
|
6363
6399
|
const displayValues = vue.computed(() => {
|
|
6364
6400
|
return filteredValues.value.slice(0, itemLimit.value).map((v) => __spreadProps(__spreadValues({}, v), { title: getDisplayValue(v.title) }));
|
|
6365
6401
|
});
|
|
6366
6402
|
const filteredValues = vue.computed(() => {
|
|
6367
|
-
|
|
6403
|
+
var _a, _b;
|
|
6404
|
+
return isFilterable.value ? (_a = allValues.value) == null ? void 0 : _a.filter(
|
|
6368
6405
|
(v) => {
|
|
6369
|
-
var
|
|
6370
|
-
return (
|
|
6406
|
+
var _a2;
|
|
6407
|
+
return (_a2 = getNormalizedString(v.title)) == null ? void 0 : _a2.includes(getNormalizedString(termFilter.value));
|
|
6371
6408
|
}
|
|
6372
|
-
) : allValues.value;
|
|
6409
|
+
) : (_b = allValues.value) != null ? _b : [];
|
|
6373
6410
|
});
|
|
6374
6411
|
const isFilterable = vue.computed(() => {
|
|
6375
|
-
var _a, _b;
|
|
6376
|
-
return allValues.value.length >= ((
|
|
6412
|
+
var _a, _b, _c;
|
|
6413
|
+
return ((_a = allValues.value) == null ? void 0 : _a.length) >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
|
|
6377
6414
|
});
|
|
6378
6415
|
const isRange = vue.computed(() => {
|
|
6379
6416
|
return facet.value.type === "range";
|
|
@@ -6397,7 +6434,7 @@ const _sfc_main$N = /* @__PURE__ */ vue.defineComponent({
|
|
|
6397
6434
|
};
|
|
6398
6435
|
const isChecked = (item) => {
|
|
6399
6436
|
var _a, _b;
|
|
6400
|
-
let selectedItems = (_a =
|
|
6437
|
+
let selectedItems = (_a = currentFiltersValue.value) != null ? _a : [];
|
|
6401
6438
|
selectedItems = isRange.value && selectedItems ? [rangeFilterToString(selectedItems)] : selectedItems;
|
|
6402
6439
|
return selectedItems == null ? void 0 : selectedItems.includes((_b = item.title) == null ? void 0 : _b.toString());
|
|
6403
6440
|
};
|
|
@@ -10311,8 +10348,8 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
10311
10348
|
const handleResize = () => {
|
|
10312
10349
|
const doc = document.documentElement;
|
|
10313
10350
|
doc.style.setProperty("--lupa-full-height", `${window.innerHeight}px`);
|
|
10314
|
-
searchResultStore.setColumnCount({ width: window.innerWidth, grid: props.options.grid });
|
|
10315
10351
|
screenStore.setScreenWidth({ width: window.innerWidth });
|
|
10352
|
+
searchResultStore.setColumnCount({ width: window.innerWidth, grid: props.options.grid });
|
|
10316
10353
|
};
|
|
10317
10354
|
const handleUrlChange = (params) => {
|
|
10318
10355
|
var _a;
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -2156,23 +2156,34 @@ const DEFAULT_OPTIONS_RESULTS = {
|
|
|
2156
2156
|
};
|
|
2157
2157
|
const useScreenStore = defineStore("screen", () => {
|
|
2158
2158
|
const screenWidth = ref(1e3);
|
|
2159
|
+
const optionsStore = useOptionsStore();
|
|
2160
|
+
const configuredGridSizes = computed(() => {
|
|
2161
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
|
|
2162
|
+
return {
|
|
2163
|
+
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,
|
|
2164
|
+
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,
|
|
2165
|
+
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,
|
|
2166
|
+
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
|
|
2167
|
+
};
|
|
2168
|
+
});
|
|
2159
2169
|
const currentScreenWidth = computed(() => {
|
|
2160
2170
|
const width = screenWidth.value;
|
|
2161
|
-
if (width <=
|
|
2171
|
+
if (width <= configuredGridSizes.value.smMin) {
|
|
2162
2172
|
return "xs";
|
|
2163
|
-
} else if (width >
|
|
2173
|
+
} else if (width > configuredGridSizes.value.smMin && width <= configuredGridSizes.value.mdMin) {
|
|
2164
2174
|
return "sm";
|
|
2165
|
-
} else if (width >
|
|
2175
|
+
} else if (width > configuredGridSizes.value.mdMin && width <= configuredGridSizes.value.lMin) {
|
|
2166
2176
|
return "md";
|
|
2167
|
-
} else if (width >
|
|
2177
|
+
} else if (width > configuredGridSizes.value.lMin && width <= configuredGridSizes.value.xlMin) {
|
|
2168
2178
|
return "l";
|
|
2169
2179
|
} else {
|
|
2170
2180
|
return "xl";
|
|
2171
2181
|
}
|
|
2172
2182
|
});
|
|
2173
|
-
const isMobileWidth = computed(
|
|
2174
|
-
|
|
2175
|
-
|
|
2183
|
+
const isMobileWidth = computed(() => {
|
|
2184
|
+
var _a;
|
|
2185
|
+
return (_a = ["xs", "sm"]) == null ? void 0 : _a.includes(currentScreenWidth.value);
|
|
2186
|
+
});
|
|
2176
2187
|
const setScreenWidth = ({ width }) => {
|
|
2177
2188
|
screenWidth.value = width;
|
|
2178
2189
|
};
|
|
@@ -4181,6 +4192,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4181
4192
|
const isMobileSidebarVisible = ref(false);
|
|
4182
4193
|
const optionsStore = useOptionsStore();
|
|
4183
4194
|
const paramsStore = useParamsStore();
|
|
4195
|
+
const screenStore = useScreenStore();
|
|
4184
4196
|
const { searchResultOptions } = storeToRefs(optionsStore);
|
|
4185
4197
|
const facets = computed(() => searchResult.value.facets);
|
|
4186
4198
|
const filters = computed(() => searchResult.value.filters);
|
|
@@ -4226,6 +4238,10 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4226
4238
|
var _a;
|
|
4227
4239
|
return Object.keys((_a = filters.value) != null ? _a : {}).length > 0;
|
|
4228
4240
|
});
|
|
4241
|
+
const hideFiltersOnExactMatchForKeys = computed(() => {
|
|
4242
|
+
var _a, _b, _c, _d;
|
|
4243
|
+
return (_d = (_c = (_b = (_a = searchResultOptions.value) == null ? void 0 : _a.filters) == null ? void 0 : _b.facets) == null ? void 0 : _c.hideFiltersOnExactMatchForKeys) != null ? _d : [];
|
|
4244
|
+
});
|
|
4229
4245
|
const itemRange = computed(() => {
|
|
4230
4246
|
var _a, _b;
|
|
4231
4247
|
const limit = (_a = paramsStore.limit) != null ? _a : 0;
|
|
@@ -4279,20 +4295,14 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4279
4295
|
return { searchResult: newSearchResult };
|
|
4280
4296
|
};
|
|
4281
4297
|
const setColumnCount = ({ width, grid }) => {
|
|
4298
|
+
var _a;
|
|
4282
4299
|
if (!width || !grid) {
|
|
4283
4300
|
return;
|
|
4284
4301
|
}
|
|
4285
|
-
|
|
4286
|
-
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
} else if (width > MD_MIN_WIDTH && width <= L_MIN_WIDTH) {
|
|
4290
|
-
columnCount.value = grid.columns.md;
|
|
4291
|
-
} else if (width > L_MIN_WIDTH && width <= XL_MIN_WIDTH) {
|
|
4292
|
-
columnCount.value = grid.columns.l;
|
|
4293
|
-
} else {
|
|
4294
|
-
columnCount.value = grid.columns.xl;
|
|
4295
|
-
}
|
|
4302
|
+
screenStore.setScreenWidth({ width });
|
|
4303
|
+
const { currentScreenWidth } = storeToRefs(screenStore);
|
|
4304
|
+
const screenWidth = (_a = currentScreenWidth.value) != null ? _a : "xl";
|
|
4305
|
+
columnCount.value = grid.columns[screenWidth];
|
|
4296
4306
|
};
|
|
4297
4307
|
const setAddToCartAmount = (newAddToCartAmount) => {
|
|
4298
4308
|
if (!newAddToCartAmount) {
|
|
@@ -4312,6 +4322,15 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4312
4322
|
const clearSearchResult = () => {
|
|
4313
4323
|
searchResult.value = {};
|
|
4314
4324
|
};
|
|
4325
|
+
const filterVisibleFilterValues = (key, items = []) => {
|
|
4326
|
+
var _a;
|
|
4327
|
+
if (!((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.length) || !hideFiltersOnExactMatchForKeys.value.includes(key) || !items.length) {
|
|
4328
|
+
return items;
|
|
4329
|
+
}
|
|
4330
|
+
const searchInput = getNormalizedString(currentQueryText.value);
|
|
4331
|
+
const hasExactMatch = items.some((item) => getNormalizedString(item.title) === searchInput);
|
|
4332
|
+
return hasExactMatch ? items.filter((item) => getNormalizedString(item.title) === searchInput) : items;
|
|
4333
|
+
};
|
|
4315
4334
|
return {
|
|
4316
4335
|
isMobileSidebarVisible,
|
|
4317
4336
|
searchResult,
|
|
@@ -4331,6 +4350,7 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4331
4350
|
hasAnyFilter,
|
|
4332
4351
|
itemRange,
|
|
4333
4352
|
isPageEmpty,
|
|
4353
|
+
hideFiltersOnExactMatchForKeys,
|
|
4334
4354
|
setSidebarState,
|
|
4335
4355
|
queryFacet,
|
|
4336
4356
|
add,
|
|
@@ -4338,7 +4358,8 @@ const useSearchResultStore = defineStore("searchResult", () => {
|
|
|
4338
4358
|
setAddToCartAmount,
|
|
4339
4359
|
setLayout,
|
|
4340
4360
|
setLoading,
|
|
4341
|
-
clearSearchResult
|
|
4361
|
+
clearSearchResult,
|
|
4362
|
+
filterVisibleFilterValues
|
|
4342
4363
|
};
|
|
4343
4364
|
});
|
|
4344
4365
|
const _hoisted_1$12 = { class: "lupa-search-box-add-to-cart-wrapper" };
|
|
@@ -6067,11 +6088,25 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
6067
6088
|
const paramsStore = useParamsStore();
|
|
6068
6089
|
const optionStore = useOptionsStore();
|
|
6069
6090
|
const searchResultStore = useSearchResultStore();
|
|
6070
|
-
const {
|
|
6091
|
+
const {
|
|
6092
|
+
filters,
|
|
6093
|
+
displayFilters,
|
|
6094
|
+
currentFilterCount,
|
|
6095
|
+
hideFiltersOnExactMatchForKeys,
|
|
6096
|
+
currentQueryText
|
|
6097
|
+
} = storeToRefs(searchResultStore);
|
|
6071
6098
|
const currentFilters = computed(() => filters.value);
|
|
6099
|
+
const currentDisplayFilters = computed(
|
|
6100
|
+
() => hideFiltersOnExactMatchForKeys.value.length ? displayFilters.value.filter(
|
|
6101
|
+
(f2) => {
|
|
6102
|
+
var _a;
|
|
6103
|
+
return !((_a = hideFiltersOnExactMatchForKeys.value) == null ? void 0 : _a.includes(f2.key)) && getNormalizedString(currentQueryText.value) !== getNormalizedString(f2.label);
|
|
6104
|
+
}
|
|
6105
|
+
) : displayFilters.value
|
|
6106
|
+
);
|
|
6072
6107
|
const hasFilters = computed(() => {
|
|
6073
6108
|
var _a;
|
|
6074
|
-
return ((_a =
|
|
6109
|
+
return ((_a = currentDisplayFilters.value) == null ? void 0 : _a.length) > 0;
|
|
6075
6110
|
});
|
|
6076
6111
|
const handleClearAll = () => {
|
|
6077
6112
|
paramsStore.removeAllFilters();
|
|
@@ -6128,7 +6163,7 @@ const _sfc_main$Q = /* @__PURE__ */ defineComponent({
|
|
|
6128
6163
|
]),
|
|
6129
6164
|
!_ctx.expandable || isOpen.value ? (openBlock(), createElementBlock("div", _hoisted_3$q, [
|
|
6130
6165
|
createElementVNode("div", _hoisted_4$k, [
|
|
6131
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(
|
|
6166
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(currentDisplayFilters.value, (filter) => {
|
|
6132
6167
|
return openBlock(), createBlock(_sfc_main$R, {
|
|
6133
6168
|
key: filter.key + "_" + filter.value,
|
|
6134
6169
|
filter,
|
|
@@ -6341,11 +6376,12 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
6341
6376
|
emits: ["select"],
|
|
6342
6377
|
setup(__props, { emit }) {
|
|
6343
6378
|
const props = __props;
|
|
6379
|
+
const searchResultStore = useSearchResultStore();
|
|
6344
6380
|
const facet = computed(() => {
|
|
6345
6381
|
var _a;
|
|
6346
6382
|
return (_a = props.facet) != null ? _a : { type: "terms", items: [], key: "" };
|
|
6347
6383
|
});
|
|
6348
|
-
const
|
|
6384
|
+
const currentFiltersValue = computed(() => {
|
|
6349
6385
|
var _a;
|
|
6350
6386
|
return (_a = props.currentFilters) != null ? _a : [];
|
|
6351
6387
|
});
|
|
@@ -6356,22 +6392,23 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
6356
6392
|
});
|
|
6357
6393
|
const allValues = computed(() => {
|
|
6358
6394
|
var _a, _b;
|
|
6359
|
-
return (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : [];
|
|
6395
|
+
return searchResultStore.filterVisibleFilterValues(facet.value.key, (_b = (_a = facet.value) == null ? void 0 : _a.items) != null ? _b : []);
|
|
6360
6396
|
});
|
|
6361
6397
|
const displayValues = computed(() => {
|
|
6362
6398
|
return filteredValues.value.slice(0, itemLimit.value).map((v) => __spreadProps(__spreadValues({}, v), { title: getDisplayValue(v.title) }));
|
|
6363
6399
|
});
|
|
6364
6400
|
const filteredValues = computed(() => {
|
|
6365
|
-
|
|
6401
|
+
var _a, _b;
|
|
6402
|
+
return isFilterable.value ? (_a = allValues.value) == null ? void 0 : _a.filter(
|
|
6366
6403
|
(v) => {
|
|
6367
|
-
var
|
|
6368
|
-
return (
|
|
6404
|
+
var _a2;
|
|
6405
|
+
return (_a2 = getNormalizedString(v.title)) == null ? void 0 : _a2.includes(getNormalizedString(termFilter.value));
|
|
6369
6406
|
}
|
|
6370
|
-
) : allValues.value;
|
|
6407
|
+
) : (_b = allValues.value) != null ? _b : [];
|
|
6371
6408
|
});
|
|
6372
6409
|
const isFilterable = computed(() => {
|
|
6373
|
-
var _a, _b;
|
|
6374
|
-
return allValues.value.length >= ((
|
|
6410
|
+
var _a, _b, _c;
|
|
6411
|
+
return ((_a = allValues.value) == null ? void 0 : _a.length) >= ((_c = (_b = props.options.filterable) == null ? void 0 : _b.minValues) != null ? _c : MAX_FACET_VALUES);
|
|
6375
6412
|
});
|
|
6376
6413
|
const isRange = computed(() => {
|
|
6377
6414
|
return facet.value.type === "range";
|
|
@@ -6395,7 +6432,7 @@ const _sfc_main$N = /* @__PURE__ */ defineComponent({
|
|
|
6395
6432
|
};
|
|
6396
6433
|
const isChecked = (item) => {
|
|
6397
6434
|
var _a, _b;
|
|
6398
|
-
let selectedItems = (_a =
|
|
6435
|
+
let selectedItems = (_a = currentFiltersValue.value) != null ? _a : [];
|
|
6399
6436
|
selectedItems = isRange.value && selectedItems ? [rangeFilterToString(selectedItems)] : selectedItems;
|
|
6400
6437
|
return selectedItems == null ? void 0 : selectedItems.includes((_b = item.title) == null ? void 0 : _b.toString());
|
|
6401
6438
|
};
|
|
@@ -10309,8 +10346,8 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
10309
10346
|
const handleResize = () => {
|
|
10310
10347
|
const doc = document.documentElement;
|
|
10311
10348
|
doc.style.setProperty("--lupa-full-height", `${window.innerHeight}px`);
|
|
10312
|
-
searchResultStore.setColumnCount({ width: window.innerWidth, grid: props.options.grid });
|
|
10313
10349
|
screenStore.setScreenWidth({ width: window.innerWidth });
|
|
10350
|
+
searchResultStore.setColumnCount({ width: window.innerWidth, grid: props.options.grid });
|
|
10314
10351
|
};
|
|
10315
10352
|
const handleUrlChange = (params) => {
|
|
10316
10353
|
var _a;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Ref } from 'vue';
|
|
2
|
-
import type { SearchQueryResult } from '@getlupa/client-sdk/Types';
|
|
2
|
+
import type { FacetGroupItem, SearchQueryResult } from '@getlupa/client-sdk/Types';
|
|
3
3
|
import { ResultsLayoutEnum, type ResultsLayout } from '../types/search-results/ResultsLayout';
|
|
4
4
|
import type { ProductGrid } from '../types/search-results/SearchResultsOptions';
|
|
5
5
|
export declare const useSearchResultStore: import("pinia").StoreDefinition<"searchResult", import("pinia")._UnwrapAll<Pick<{
|
|
@@ -21,6 +21,7 @@ export declare const useSearchResultStore: import("pinia").StoreDefinition<"sear
|
|
|
21
21
|
hasAnyFilter: import("vue").ComputedRef<boolean>;
|
|
22
22
|
itemRange: import("vue").ComputedRef<number[]>;
|
|
23
23
|
isPageEmpty: import("vue").ComputedRef<boolean>;
|
|
24
|
+
hideFiltersOnExactMatchForKeys: import("vue").ComputedRef<string[]>;
|
|
24
25
|
setSidebarState: ({ visible }: {
|
|
25
26
|
visible: boolean;
|
|
26
27
|
}) => void;
|
|
@@ -43,6 +44,7 @@ export declare const useSearchResultStore: import("pinia").StoreDefinition<"sear
|
|
|
43
44
|
setLayout: (newLayout: ResultsLayout) => void;
|
|
44
45
|
setLoading: (state: boolean) => void;
|
|
45
46
|
clearSearchResult: () => void;
|
|
47
|
+
filterVisibleFilterValues: (key: string, items?: FacetGroupItem[]) => FacetGroupItem[];
|
|
46
48
|
}, "loading" | "searchResult" | "isMobileSidebarVisible" | "columnCount" | "addToCartAmount" | "layout">>, Pick<{
|
|
47
49
|
isMobileSidebarVisible: Ref<boolean>;
|
|
48
50
|
searchResult: Ref<SearchQueryResult>;
|
|
@@ -62,6 +64,7 @@ export declare const useSearchResultStore: import("pinia").StoreDefinition<"sear
|
|
|
62
64
|
hasAnyFilter: import("vue").ComputedRef<boolean>;
|
|
63
65
|
itemRange: import("vue").ComputedRef<number[]>;
|
|
64
66
|
isPageEmpty: import("vue").ComputedRef<boolean>;
|
|
67
|
+
hideFiltersOnExactMatchForKeys: import("vue").ComputedRef<string[]>;
|
|
65
68
|
setSidebarState: ({ visible }: {
|
|
66
69
|
visible: boolean;
|
|
67
70
|
}) => void;
|
|
@@ -84,7 +87,8 @@ export declare const useSearchResultStore: import("pinia").StoreDefinition<"sear
|
|
|
84
87
|
setLayout: (newLayout: ResultsLayout) => void;
|
|
85
88
|
setLoading: (state: boolean) => void;
|
|
86
89
|
clearSearchResult: () => void;
|
|
87
|
-
|
|
90
|
+
filterVisibleFilterValues: (key: string, items?: FacetGroupItem[]) => FacetGroupItem[];
|
|
91
|
+
}, "filters" | "facets" | "hideFiltersOnExactMatchForKeys" | "currentQueryText" | "totalItems" | "hasResults" | "labeledFilters" | "displayFilters" | "currentFilterCount" | "currentFilterKeys" | "hasAnyFilter" | "itemRange" | "isPageEmpty">, Pick<{
|
|
88
92
|
isMobileSidebarVisible: Ref<boolean>;
|
|
89
93
|
searchResult: Ref<SearchQueryResult>;
|
|
90
94
|
columnCount: Ref<number>;
|
|
@@ -103,6 +107,7 @@ export declare const useSearchResultStore: import("pinia").StoreDefinition<"sear
|
|
|
103
107
|
hasAnyFilter: import("vue").ComputedRef<boolean>;
|
|
104
108
|
itemRange: import("vue").ComputedRef<number[]>;
|
|
105
109
|
isPageEmpty: import("vue").ComputedRef<boolean>;
|
|
110
|
+
hideFiltersOnExactMatchForKeys: import("vue").ComputedRef<string[]>;
|
|
106
111
|
setSidebarState: ({ visible }: {
|
|
107
112
|
visible: boolean;
|
|
108
113
|
}) => void;
|
|
@@ -125,4 +130,5 @@ export declare const useSearchResultStore: import("pinia").StoreDefinition<"sear
|
|
|
125
130
|
setLayout: (newLayout: ResultsLayout) => void;
|
|
126
131
|
setLoading: (state: boolean) => void;
|
|
127
132
|
clearSearchResult: () => void;
|
|
128
|
-
|
|
133
|
+
filterVisibleFilterValues: (key: string, items?: FacetGroupItem[]) => FacetGroupItem[];
|
|
134
|
+
}, "add" | "setSidebarState" | "queryFacet" | "setColumnCount" | "setAddToCartAmount" | "setLayout" | "setLoading" | "clearSearchResult" | "filterVisibleFilterValues">>;
|
|
@@ -103,6 +103,12 @@ export type ProductGrid = {
|
|
|
103
103
|
sm: number;
|
|
104
104
|
xs: number;
|
|
105
105
|
};
|
|
106
|
+
sizes?: {
|
|
107
|
+
sm?: number;
|
|
108
|
+
md?: number;
|
|
109
|
+
l?: number;
|
|
110
|
+
xl?: number;
|
|
111
|
+
};
|
|
106
112
|
};
|
|
107
113
|
export type SearchResultsPaginationLabels = {
|
|
108
114
|
pageSize: string;
|
|
@@ -166,6 +172,7 @@ export type ResultFacetOptions = {
|
|
|
166
172
|
facetClear?: string;
|
|
167
173
|
facetFilterButton?: string;
|
|
168
174
|
};
|
|
175
|
+
hideFiltersOnExactMatchForKeys?: string[];
|
|
169
176
|
promotedFacets?: string[];
|
|
170
177
|
filterBehavior?: FilterBehavior;
|
|
171
178
|
filterable?: {
|