@getlupa/client 1.9.4 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lupaSearch.iife.js +128 -63
- package/dist/lupaSearch.js +128 -63
- package/dist/lupaSearch.mjs +128 -63
- package/dist/lupaSearch.umd.js +128 -63
- package/dist/style.css +1 -1
- package/package.json +2 -2
package/dist/lupaSearch.mjs
CHANGED
|
@@ -6890,6 +6890,11 @@ const useOptionsStore = defineStore("options", () => {
|
|
|
6890
6890
|
const setInitialFilters = ({ initialFilters: initialFilters2 }) => {
|
|
6891
6891
|
searchResultInitialFilters.value = initialFilters2;
|
|
6892
6892
|
};
|
|
6893
|
+
const getQueryParamName = (param) => {
|
|
6894
|
+
var _a;
|
|
6895
|
+
const nameMap = searchBoxOptions.value.queryParameterNames;
|
|
6896
|
+
return (_a = nameMap == null ? void 0 : nameMap[param]) != null ? _a : param;
|
|
6897
|
+
};
|
|
6893
6898
|
return {
|
|
6894
6899
|
searchBoxOptions,
|
|
6895
6900
|
searchResultOptions,
|
|
@@ -6904,7 +6909,8 @@ const useOptionsStore = defineStore("options", () => {
|
|
|
6904
6909
|
setSearchBoxOptions,
|
|
6905
6910
|
setTrackingOptions,
|
|
6906
6911
|
setSearchResultOptions,
|
|
6907
|
-
setInitialFilters
|
|
6912
|
+
setInitialFilters,
|
|
6913
|
+
getQueryParamName
|
|
6908
6914
|
};
|
|
6909
6915
|
});
|
|
6910
6916
|
var DocumentElementType = /* @__PURE__ */ ((DocumentElementType2) => {
|
|
@@ -7157,9 +7163,14 @@ const parseParam = (key, params) => {
|
|
|
7157
7163
|
return void 0;
|
|
7158
7164
|
}
|
|
7159
7165
|
};
|
|
7160
|
-
const parseRegularKeys = (regularKeys, searchParams) => {
|
|
7166
|
+
const parseRegularKeys = (regularKeys, searchParams, getQueryParamName) => {
|
|
7161
7167
|
const params = /* @__PURE__ */ Object.create({});
|
|
7162
|
-
const keys = reverseKeyValue(
|
|
7168
|
+
const keys = reverseKeyValue({
|
|
7169
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
|
|
7170
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
|
|
7171
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
|
|
7172
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
|
|
7173
|
+
});
|
|
7163
7174
|
for (const key of regularKeys) {
|
|
7164
7175
|
const rawKey = keys[key] || key;
|
|
7165
7176
|
params[rawKey] = parseParam(key, searchParams);
|
|
@@ -7201,16 +7212,17 @@ const parseFacetKeys = (facetKeys, searchParams) => {
|
|
|
7201
7212
|
}
|
|
7202
7213
|
return params;
|
|
7203
7214
|
};
|
|
7204
|
-
const parseParams = (searchParams) => {
|
|
7215
|
+
const parseParams = (getQueryParamName, searchParams) => {
|
|
7205
7216
|
const params = /* @__PURE__ */ Object.create({});
|
|
7206
7217
|
if (!searchParams)
|
|
7207
7218
|
return params;
|
|
7208
7219
|
const paramKeys = Array.from(searchParams.keys());
|
|
7209
7220
|
const facetKeys = paramKeys.filter((k) => isFacetKey(k));
|
|
7210
7221
|
const regularKeys = paramKeys.filter((k) => !isFacetKey(k));
|
|
7211
|
-
|
|
7222
|
+
const r = __spreadValues2(__spreadValues2({
|
|
7212
7223
|
[QUERY_PARAMS_PARSED.QUERY]: ""
|
|
7213
|
-
}, parseRegularKeys(regularKeys, searchParams)), parseFacetKeys(facetKeys, searchParams));
|
|
7224
|
+
}, parseRegularKeys(regularKeys, searchParams, getQueryParamName)), parseFacetKeys(facetKeys, searchParams));
|
|
7225
|
+
return r;
|
|
7214
7226
|
};
|
|
7215
7227
|
const appendParam = (url, { name, value }, encode = true) => {
|
|
7216
7228
|
if (Array.isArray(value)) {
|
|
@@ -7231,10 +7243,16 @@ const appendArrayParams = (url, param) => {
|
|
|
7231
7243
|
url.searchParams.delete(param.name);
|
|
7232
7244
|
param.value.forEach((v) => url.searchParams.append(param.name, encodeParam(v)));
|
|
7233
7245
|
};
|
|
7234
|
-
const getRemovableParams = (url, paramsToRemove) => {
|
|
7246
|
+
const getRemovableParams = (url, getQueryParamName, paramsToRemove) => {
|
|
7235
7247
|
if (paramsToRemove === "all") {
|
|
7248
|
+
const params = {
|
|
7249
|
+
QUERY: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY,
|
|
7250
|
+
LIMIT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.LIMIT) : QUERY_PARAMS$1.LIMIT,
|
|
7251
|
+
PAGE: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE,
|
|
7252
|
+
SORT: getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.SORT) : QUERY_PARAMS$1.SORT
|
|
7253
|
+
};
|
|
7236
7254
|
return [
|
|
7237
|
-
...Object.values(
|
|
7255
|
+
...Object.values(params),
|
|
7238
7256
|
...Array.from(url.searchParams.keys()).filter((k) => isFacetKey(k))
|
|
7239
7257
|
];
|
|
7240
7258
|
}
|
|
@@ -7265,12 +7283,12 @@ const generateLink = (linkPattern, document2) => {
|
|
|
7265
7283
|
}
|
|
7266
7284
|
return link;
|
|
7267
7285
|
};
|
|
7268
|
-
const generateResultLink = (link, searchText, facet) => {
|
|
7286
|
+
const generateResultLink = (link, getQueryParamName, searchText, facet) => {
|
|
7269
7287
|
if (!searchText) {
|
|
7270
7288
|
return link;
|
|
7271
7289
|
}
|
|
7272
7290
|
const facetParam = facet ? `&${FACET_PARAMS_TYPE.TERMS}${encodeParam(facet.key)}=${encodeParam(facet.title)}` : "";
|
|
7273
|
-
const queryParam = `?${QUERY_PARAMS$1.QUERY}=${encodeParam(searchText)}`;
|
|
7291
|
+
const queryParam = `?${getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.QUERY) : QUERY_PARAMS$1.QUERY}=${encodeParam(searchText)}`;
|
|
7274
7292
|
return `${link}${queryParam}${facetParam}`;
|
|
7275
7293
|
};
|
|
7276
7294
|
const getRelativePath = (link) => {
|
|
@@ -7299,8 +7317,8 @@ const handleRoutingEvent = (link, event, hasEventRouting = false) => {
|
|
|
7299
7317
|
event == null ? void 0 : event.preventDefault();
|
|
7300
7318
|
emitRoutingEvent(link);
|
|
7301
7319
|
};
|
|
7302
|
-
const redirectToResultsPage = (link, searchText, facet, routingBehavior = "direct-link") => {
|
|
7303
|
-
const url = generateResultLink(link, searchText, facet);
|
|
7320
|
+
const redirectToResultsPage = (link, searchText, getQueryParamName, facet, routingBehavior = "direct-link") => {
|
|
7321
|
+
const url = generateResultLink(link, getQueryParamName, searchText, facet);
|
|
7304
7322
|
if (routingBehavior === "event") {
|
|
7305
7323
|
emitRoutingEvent(url);
|
|
7306
7324
|
} else {
|
|
@@ -7325,15 +7343,15 @@ const getFacetParam = (key, value, type = FACET_PARAMS_TYPE.TERMS) => {
|
|
|
7325
7343
|
value
|
|
7326
7344
|
};
|
|
7327
7345
|
};
|
|
7328
|
-
const toggleTermFilter = (appendParams, facetAction, currentFilters) => {
|
|
7346
|
+
const toggleTermFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
7329
7347
|
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
7330
7348
|
const newParams = toggleTermParam(currentFilter, facetAction.value);
|
|
7331
7349
|
appendParams({
|
|
7332
7350
|
params: [getFacetParam(facetAction.key, newParams)],
|
|
7333
|
-
paramsToRemove: [QUERY_PARAMS$1.PAGE]
|
|
7351
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
|
|
7334
7352
|
});
|
|
7335
7353
|
};
|
|
7336
|
-
const toggleHierarchyFilter = (appendParams, facetAction, currentFilters, removeAllLevels = false) => {
|
|
7354
|
+
const toggleHierarchyFilter = (appendParams, facetAction, getQueryParamName, currentFilters, removeAllLevels = false) => {
|
|
7337
7355
|
var _a;
|
|
7338
7356
|
const currentFilter = currentFilters == null ? void 0 : currentFilters[facetAction.key];
|
|
7339
7357
|
const newParams = toggleHierarchyParam(
|
|
@@ -7343,10 +7361,10 @@ const toggleHierarchyFilter = (appendParams, facetAction, currentFilters, remove
|
|
|
7343
7361
|
);
|
|
7344
7362
|
appendParams({
|
|
7345
7363
|
params: [getFacetParam(facetAction.key, newParams, FACET_PARAMS_TYPE.HIERARCHY)],
|
|
7346
|
-
paramsToRemove: [QUERY_PARAMS$1.PAGE]
|
|
7364
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE]
|
|
7347
7365
|
});
|
|
7348
7366
|
};
|
|
7349
|
-
const toggleRangeFilter = (appendParams, facetAction, currentFilters) => {
|
|
7367
|
+
const toggleRangeFilter = (appendParams, facetAction, getQueryParamName, currentFilters) => {
|
|
7350
7368
|
const currentFilter = rangeFilterToString(
|
|
7351
7369
|
currentFilters == null ? void 0 : currentFilters[facetAction.key],
|
|
7352
7370
|
FACET_RANGE_SEPARATOR
|
|
@@ -7355,7 +7373,7 @@ const toggleRangeFilter = (appendParams, facetAction, currentFilters) => {
|
|
|
7355
7373
|
facetValue = currentFilter === facetValue ? "" : facetValue;
|
|
7356
7374
|
appendParams({
|
|
7357
7375
|
params: [getFacetParam(facetAction.key, facetValue, FACET_PARAMS_TYPE.RANGE)],
|
|
7358
|
-
paramsToRemove: [QUERY_PARAMS$1.PAGE],
|
|
7376
|
+
paramsToRemove: [getQueryParamName ? getQueryParamName(QUERY_PARAMS$1.PAGE) : QUERY_PARAMS$1.PAGE],
|
|
7359
7377
|
encode: false
|
|
7360
7378
|
});
|
|
7361
7379
|
};
|
|
@@ -7484,7 +7502,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7484
7502
|
const navigate = (url) => {
|
|
7485
7503
|
var _a, _b, _c;
|
|
7486
7504
|
window.history.pushState("", "Append params", url.pathname + url.search);
|
|
7487
|
-
const params2 = parseParams(url.searchParams);
|
|
7505
|
+
const params2 = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
7488
7506
|
(_c = (_b = (_a = optionsStore == null ? void 0 : optionsStore.searchBoxOptions) == null ? void 0 : _a.callbacks) == null ? void 0 : _b.onSearchResultsNavigate) == null ? void 0 : _c.call(_b, {
|
|
7489
7507
|
params: params2
|
|
7490
7508
|
});
|
|
@@ -7502,7 +7520,7 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7502
7520
|
const paramsToRemove = Array.from(url.searchParams.keys()).filter(isFacetKey);
|
|
7503
7521
|
removeParams(url, paramsToRemove);
|
|
7504
7522
|
navigate(url);
|
|
7505
|
-
params.value = parseParams(url.searchParams);
|
|
7523
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
7506
7524
|
searchString.value = url.search;
|
|
7507
7525
|
};
|
|
7508
7526
|
const removeParameters = ({
|
|
@@ -7510,13 +7528,13 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7510
7528
|
save = true
|
|
7511
7529
|
}) => {
|
|
7512
7530
|
const url = getPageUrl();
|
|
7513
|
-
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
7531
|
+
paramsToRemove = getRemovableParams(url, optionsStore.getQueryParamName, paramsToRemove);
|
|
7514
7532
|
removeParams(url, paramsToRemove);
|
|
7515
7533
|
navigate(url);
|
|
7516
7534
|
if (!save) {
|
|
7517
7535
|
return;
|
|
7518
7536
|
}
|
|
7519
|
-
params.value = parseParams(url.searchParams);
|
|
7537
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
7520
7538
|
searchString.value = url.search;
|
|
7521
7539
|
};
|
|
7522
7540
|
const handleNoResultsFlag = ({
|
|
@@ -7558,13 +7576,22 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7558
7576
|
})
|
|
7559
7577
|
] : [];
|
|
7560
7578
|
appendParams({
|
|
7561
|
-
params: [
|
|
7579
|
+
params: [
|
|
7580
|
+
{ name: optionsStore.getQueryParamName(QUERY_PARAMS$1.QUERY), value: searchText },
|
|
7581
|
+
...facetParam
|
|
7582
|
+
],
|
|
7562
7583
|
paramsToRemove: "all",
|
|
7563
7584
|
searchResultsLink: searchResultsLink.value
|
|
7564
7585
|
});
|
|
7565
7586
|
} else {
|
|
7566
7587
|
const routing = (_a = optionsStore.boxRoutingBehavior) != null ? _a : "direct-link";
|
|
7567
|
-
redirectToResultsPage(
|
|
7588
|
+
redirectToResultsPage(
|
|
7589
|
+
searchResultsLink.value,
|
|
7590
|
+
searchText,
|
|
7591
|
+
optionsStore.getQueryParamName,
|
|
7592
|
+
facet,
|
|
7593
|
+
routing
|
|
7594
|
+
);
|
|
7568
7595
|
}
|
|
7569
7596
|
};
|
|
7570
7597
|
const appendParams = ({
|
|
@@ -7578,14 +7605,14 @@ const useParamsStore = defineStore("params", () => {
|
|
|
7578
7605
|
return { params: params.value };
|
|
7579
7606
|
}
|
|
7580
7607
|
const url = getPageUrl(searchResultsLink2);
|
|
7581
|
-
paramsToRemove = getRemovableParams(url, paramsToRemove);
|
|
7608
|
+
paramsToRemove = getRemovableParams(url, optionsStore.getQueryParamName, paramsToRemove);
|
|
7582
7609
|
removeParams(url, paramsToRemove);
|
|
7583
7610
|
newParams.forEach((p2) => appendParam(url, p2, encode));
|
|
7584
7611
|
navigate(url);
|
|
7585
7612
|
if (!save) {
|
|
7586
7613
|
return;
|
|
7587
7614
|
}
|
|
7588
|
-
params.value = parseParams(url.searchParams);
|
|
7615
|
+
params.value = parseParams(optionsStore.getQueryParamName, url.searchParams);
|
|
7589
7616
|
searchString.value = url.search;
|
|
7590
7617
|
};
|
|
7591
7618
|
const setDefaultLimit = (newDefaultLimit) => {
|
|
@@ -8320,8 +8347,9 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
|
|
|
8320
8347
|
const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
8321
8348
|
const loading = ref(false);
|
|
8322
8349
|
const dynamicDataIdMap = ref({});
|
|
8350
|
+
const loadingIds = ref({});
|
|
8323
8351
|
const optionsStore = useOptionsStore();
|
|
8324
|
-
|
|
8352
|
+
computed(() => Object.keys(dynamicDataIdMap.value));
|
|
8325
8353
|
const searchResultOptions = computed(() => optionsStore.searchResultOptions);
|
|
8326
8354
|
const searchBoxOptions = computed(() => optionsStore.searchBoxOptions);
|
|
8327
8355
|
const dynamicSearchResultData = computed(() => {
|
|
@@ -8361,11 +8389,12 @@ const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
|
8361
8389
|
const similarQueryResultIds = (_e = (_d = (_c = result.similarQueries) == null ? void 0 : _c.map((q) => q.items.map((i) => i.id))) == null ? void 0 : _d.flat()) != null ? _e : [];
|
|
8362
8390
|
let requestedIds = [...resultIds, ...similarQueryResultIds];
|
|
8363
8391
|
if (isCacheEnabled.value) {
|
|
8364
|
-
requestedIds = requestedIds.filter((i) => !
|
|
8392
|
+
requestedIds = requestedIds.filter((i) => !dynamicDataIdMap.value[`${i}`]);
|
|
8365
8393
|
}
|
|
8366
8394
|
if (!requestedIds.length) {
|
|
8367
8395
|
return;
|
|
8368
8396
|
}
|
|
8397
|
+
loadingIds.value = requestedIds.reduce((a, c2) => __spreadProps2(__spreadValues2({}, a), { [c2]: true }), {});
|
|
8369
8398
|
loading.value = true;
|
|
8370
8399
|
try {
|
|
8371
8400
|
const dynamicData = dynamicSearchResultData.value || dynamicSearchBoxData.value;
|
|
@@ -8375,15 +8404,16 @@ const useDynamicDataStore = defineStore("dynamicData", () => {
|
|
|
8375
8404
|
const dynamicDataResult = (_f = yield dynamicData == null ? void 0 : dynamicData.handler(requestedIds)) != null ? _f : [];
|
|
8376
8405
|
const seed = {};
|
|
8377
8406
|
const dynamicDataIdMapValue = dynamicDataResult.reduce(
|
|
8378
|
-
(a, c2) => __spreadProps2(__spreadValues2({}, a), { [c2.id]: c2 }),
|
|
8407
|
+
(a, c2) => __spreadProps2(__spreadValues2({}, a), { [`${c2.id}`]: c2 }),
|
|
8379
8408
|
seed
|
|
8380
8409
|
);
|
|
8381
8410
|
dynamicDataIdMap.value = __spreadValues2(__spreadValues2({}, dynamicDataIdMap.value), dynamicDataIdMapValue);
|
|
8382
8411
|
} finally {
|
|
8383
8412
|
loading.value = false;
|
|
8413
|
+
loadingIds.value = {};
|
|
8384
8414
|
}
|
|
8385
8415
|
});
|
|
8386
|
-
return { dynamicDataIdMap, loading, enhanceSearchResultsWithDynamicData };
|
|
8416
|
+
return { dynamicDataIdMap, loading, loadingIds, enhanceSearchResultsWithDynamicData };
|
|
8387
8417
|
});
|
|
8388
8418
|
const joinUrlParts = (...parts) => {
|
|
8389
8419
|
var _a, _b, _c;
|
|
@@ -8901,7 +8931,7 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
|
|
|
8901
8931
|
setup(__props) {
|
|
8902
8932
|
const props = __props;
|
|
8903
8933
|
const dynamicDataStore = useDynamicDataStore();
|
|
8904
|
-
const { loading, dynamicDataIdMap } = storeToRefs(dynamicDataStore);
|
|
8934
|
+
const { loading, loadingIds, dynamicDataIdMap } = storeToRefs(dynamicDataStore);
|
|
8905
8935
|
const elementComponent = computed(() => {
|
|
8906
8936
|
switch (props.element.type) {
|
|
8907
8937
|
case DocumentElementType.IMAGE:
|
|
@@ -8926,9 +8956,6 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
|
|
|
8926
8956
|
const displayElement = computed(() => {
|
|
8927
8957
|
return props.element.display ? props.element.display(props.item) : true;
|
|
8928
8958
|
});
|
|
8929
|
-
const isLoadingDynamicData = computed(() => {
|
|
8930
|
-
return Boolean(props.element.dynamic && loading.value);
|
|
8931
|
-
});
|
|
8932
8959
|
const enhancedItem = computed(() => {
|
|
8933
8960
|
var _a, _b, _c, _d;
|
|
8934
8961
|
if (!((_a = props.item) == null ? void 0 : _a.id)) {
|
|
@@ -8937,13 +8964,17 @@ const _sfc_main$14 = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValu
|
|
|
8937
8964
|
const enhancementData = (_d = (_c = dynamicDataIdMap.value) == null ? void 0 : _c[(_b = props.item) == null ? void 0 : _b.id]) != null ? _d : {};
|
|
8938
8965
|
return __spreadValues2(__spreadValues2({}, props.item), enhancementData);
|
|
8939
8966
|
});
|
|
8967
|
+
const isLoadingDynamicData = (id) => {
|
|
8968
|
+
return Boolean(props.element.dynamic && id && loading.value && (loadingIds == null ? void 0 : loadingIds.value[id]));
|
|
8969
|
+
};
|
|
8940
8970
|
return (_ctx, _cache) => {
|
|
8971
|
+
var _a;
|
|
8941
8972
|
return displayElement.value ? (openBlock(), createBlock(resolveDynamicComponent(elementComponent.value), {
|
|
8942
8973
|
key: 0,
|
|
8943
8974
|
item: enhancedItem.value,
|
|
8944
8975
|
options: _ctx.element,
|
|
8945
8976
|
labels: _ctx.labels,
|
|
8946
|
-
class: normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData.
|
|
8977
|
+
class: normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData((_a = _ctx.item) == null ? void 0 : _a.id) }),
|
|
8947
8978
|
inStock: _ctx.isInStock
|
|
8948
8979
|
}, null, 8, ["item", "options", "labels", "class", "inStock"])) : createCommentVNode("", true);
|
|
8949
8980
|
};
|
|
@@ -9526,6 +9557,11 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
|
|
|
9526
9557
|
ref: panelContainer
|
|
9527
9558
|
}, [
|
|
9528
9559
|
displayResults.value ? (openBlock(), createElementBlock("div", _hoisted_1$Y, [
|
|
9560
|
+
labels.value.closePanel ? (openBlock(), createElementBlock("a", {
|
|
9561
|
+
key: 0,
|
|
9562
|
+
class: "lupa-search-box-close-panel",
|
|
9563
|
+
onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("close"))
|
|
9564
|
+
}, toDisplayString(labels.value.closePanel), 1)) : createCommentVNode("", true),
|
|
9529
9565
|
createBaseVNode("div", {
|
|
9530
9566
|
class: "lupa-main-panel",
|
|
9531
9567
|
style: normalizeStyle(expandOnSinglePanel.value ? { display: "block" } : {}),
|
|
@@ -9550,9 +9586,9 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
|
|
|
9550
9586
|
debounce: _ctx.options.debounce,
|
|
9551
9587
|
inputValue: getInput(panel),
|
|
9552
9588
|
labels: labels.value,
|
|
9553
|
-
onFetched: _cache[
|
|
9554
|
-
onItemSelect: _cache[
|
|
9555
|
-
onProductClick: _cache[
|
|
9589
|
+
onFetched: _cache[1] || (_cache[1] = (data) => _ctx.$emit("fetched", data)),
|
|
9590
|
+
onItemSelect: _cache[2] || (_cache[2] = (item) => _ctx.$emit("itemSelect", item)),
|
|
9591
|
+
onProductClick: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("product-click"))
|
|
9556
9592
|
}, createSlots({ _: 2 }, [
|
|
9557
9593
|
_ctx.$slots.productCard ? {
|
|
9558
9594
|
name: "productCard",
|
|
@@ -9566,14 +9602,14 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
|
|
|
9566
9602
|
}), 128))
|
|
9567
9603
|
], 4),
|
|
9568
9604
|
!unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1h, {
|
|
9569
|
-
key:
|
|
9605
|
+
key: 1,
|
|
9570
9606
|
labels: labels.value
|
|
9571
9607
|
}, null, 8, ["labels"])) : createCommentVNode("", true),
|
|
9572
9608
|
unref(hasAnyResults) || !_ctx.options.hideMoreResultsButtonOnNoResults ? (openBlock(), createBlock(_sfc_main$1k, {
|
|
9573
|
-
key:
|
|
9609
|
+
key: 2,
|
|
9574
9610
|
labels: labels.value,
|
|
9575
9611
|
showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
|
|
9576
|
-
onGoToResults: _cache[
|
|
9612
|
+
onGoToResults: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("go-to-results"))
|
|
9577
9613
|
}, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
|
|
9578
9614
|
])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_5$e, [
|
|
9579
9615
|
createVNode(_sfc_main$1i, {
|
|
@@ -9684,6 +9720,10 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent({
|
|
|
9684
9720
|
opened.value = false;
|
|
9685
9721
|
suggestedValue.value = defaultSuggestedValue;
|
|
9686
9722
|
};
|
|
9723
|
+
const close = () => {
|
|
9724
|
+
opened.value = false;
|
|
9725
|
+
suggestedValue.value = defaultSuggestedValue;
|
|
9726
|
+
};
|
|
9687
9727
|
const handleKeyDown = (e) => {
|
|
9688
9728
|
var _a2, _b;
|
|
9689
9729
|
if (!opened.value) {
|
|
@@ -9865,7 +9905,8 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent({
|
|
|
9865
9905
|
onFetched: handleItemsFetch,
|
|
9866
9906
|
onItemSelect: handleItemSelect,
|
|
9867
9907
|
onGoToResults: handleSearch,
|
|
9868
|
-
onProductClick: handleProductClick
|
|
9908
|
+
onProductClick: handleProductClick,
|
|
9909
|
+
onClose: close
|
|
9869
9910
|
}, createSlots({ _: 2 }, [
|
|
9870
9911
|
_ctx.$slots.productCard ? {
|
|
9871
9912
|
name: "productCard",
|
|
@@ -10162,6 +10203,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
|
10162
10203
|
setup(__props) {
|
|
10163
10204
|
const isOpen = ref(false);
|
|
10164
10205
|
const paramsStore = useParamsStore();
|
|
10206
|
+
const optionStore = useOptionsStore();
|
|
10165
10207
|
const searchResultStore = useSearchResultStore();
|
|
10166
10208
|
const { filters, displayFilters, currentFilterCount } = storeToRefs(searchResultStore);
|
|
10167
10209
|
const currentFilters = computed(() => filters.value);
|
|
@@ -10179,6 +10221,7 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
|
10179
10221
|
// TODO: Fix any
|
|
10180
10222
|
paramsStore.appendParams,
|
|
10181
10223
|
{ type: "terms", value: filter.value, key: filter.key },
|
|
10224
|
+
optionStore.getQueryParamName,
|
|
10182
10225
|
currentFilters.value
|
|
10183
10226
|
);
|
|
10184
10227
|
break;
|
|
@@ -10186,13 +10229,17 @@ const _sfc_main$V = /* @__PURE__ */ defineComponent({
|
|
|
10186
10229
|
toggleHierarchyFilter(
|
|
10187
10230
|
paramsStore.appendParams,
|
|
10188
10231
|
{ type: "hierarchy", value: filter.value, key: filter.key },
|
|
10232
|
+
optionStore.getQueryParamName,
|
|
10189
10233
|
currentFilters.value,
|
|
10190
10234
|
true
|
|
10191
10235
|
);
|
|
10192
10236
|
break;
|
|
10193
10237
|
case "range":
|
|
10194
10238
|
paramsStore.removeParameters({
|
|
10195
|
-
paramsToRemove: [
|
|
10239
|
+
paramsToRemove: [
|
|
10240
|
+
optionStore.getQueryParamName(QUERY_PARAMS$1.PAGE),
|
|
10241
|
+
`${FACET_PARAMS_TYPE.RANGE}${filter.key}`
|
|
10242
|
+
]
|
|
10196
10243
|
});
|
|
10197
10244
|
break;
|
|
10198
10245
|
}
|
|
@@ -12194,13 +12241,28 @@ const _sfc_main$M = /* @__PURE__ */ defineComponent({
|
|
|
12194
12241
|
const handleFacetSelect = (facetAction) => {
|
|
12195
12242
|
switch (facetAction.type) {
|
|
12196
12243
|
case "terms":
|
|
12197
|
-
toggleTermFilter(
|
|
12244
|
+
toggleTermFilter(
|
|
12245
|
+
paramStore.appendParams,
|
|
12246
|
+
facetAction,
|
|
12247
|
+
optionsStore.getQueryParamName,
|
|
12248
|
+
filters.value
|
|
12249
|
+
);
|
|
12198
12250
|
break;
|
|
12199
12251
|
case "range":
|
|
12200
|
-
toggleRangeFilter(
|
|
12252
|
+
toggleRangeFilter(
|
|
12253
|
+
paramStore.appendParams,
|
|
12254
|
+
facetAction,
|
|
12255
|
+
optionsStore.getQueryParamName,
|
|
12256
|
+
filters.value
|
|
12257
|
+
);
|
|
12201
12258
|
break;
|
|
12202
12259
|
case "hierarchy":
|
|
12203
|
-
toggleHierarchyFilter(
|
|
12260
|
+
toggleHierarchyFilter(
|
|
12261
|
+
paramStore.appendParams,
|
|
12262
|
+
facetAction,
|
|
12263
|
+
optionsStore.getQueryParamName,
|
|
12264
|
+
filters.value
|
|
12265
|
+
);
|
|
12204
12266
|
break;
|
|
12205
12267
|
}
|
|
12206
12268
|
if (scrollToResultsOptions.value.enabled) {
|
|
@@ -12567,7 +12629,7 @@ const _sfc_main$F = /* @__PURE__ */ defineComponent({
|
|
|
12567
12629
|
const handlePageChange = (page) => {
|
|
12568
12630
|
if (page > 0) {
|
|
12569
12631
|
paramStore.appendParams({
|
|
12570
|
-
params: [{ name: QUERY_PARAMS$1.PAGE, value: page.toString() }]
|
|
12632
|
+
params: [{ name: optionsStore.getQueryParamName(QUERY_PARAMS$1.PAGE), value: page.toString() }]
|
|
12571
12633
|
});
|
|
12572
12634
|
if (scrollToResultsOptions.value.enabled) {
|
|
12573
12635
|
scrollToSearchResults(
|
|
@@ -12637,12 +12699,13 @@ const _sfc_main$E = /* @__PURE__ */ defineComponent({
|
|
|
12637
12699
|
},
|
|
12638
12700
|
setup(__props) {
|
|
12639
12701
|
const paramsStore = useParamsStore();
|
|
12702
|
+
const optionsStore = useOptionsStore();
|
|
12640
12703
|
const select = ref(null);
|
|
12641
12704
|
const handleSelect = (e) => {
|
|
12642
12705
|
const value = e.target.value;
|
|
12643
12706
|
paramsStore.appendParams({
|
|
12644
|
-
params: [{ name: QUERY_PARAMS$1.LIMIT, value }],
|
|
12645
|
-
paramsToRemove: [QUERY_PARAMS$1.PAGE]
|
|
12707
|
+
params: [{ name: optionsStore.getQueryParamName(QUERY_PARAMS$1.LIMIT), value }],
|
|
12708
|
+
paramsToRemove: [optionsStore.getQueryParamName(QUERY_PARAMS$1.PAGE)]
|
|
12646
12709
|
});
|
|
12647
12710
|
};
|
|
12648
12711
|
return (_ctx, _cache) => {
|
|
@@ -12683,6 +12746,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
12683
12746
|
setup(__props) {
|
|
12684
12747
|
const props = __props;
|
|
12685
12748
|
const paramStore = useParamsStore();
|
|
12749
|
+
const optionStore = useOptionsStore();
|
|
12686
12750
|
const { sort } = storeToRefs(paramStore);
|
|
12687
12751
|
const selectedKey = ref("");
|
|
12688
12752
|
const previousKey = ref("");
|
|
@@ -12716,8 +12780,8 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
12716
12780
|
paramStore.setSortSettings({ selectedSortKey: value, previousSortKey: previousKey.value });
|
|
12717
12781
|
(_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value, previousSortKey: previousKey.value });
|
|
12718
12782
|
paramStore.appendParams({
|
|
12719
|
-
params: [{ name: QUERY_PARAMS$1.SORT, value }],
|
|
12720
|
-
paramsToRemove: [QUERY_PARAMS$1.PAGE]
|
|
12783
|
+
params: [{ name: optionStore.getQueryParamName(QUERY_PARAMS$1.SORT), value }],
|
|
12784
|
+
paramsToRemove: [optionStore.getQueryParamName(QUERY_PARAMS$1.PAGE)]
|
|
12721
12785
|
});
|
|
12722
12786
|
previousKey.value = selectedKey.value;
|
|
12723
12787
|
};
|
|
@@ -13575,7 +13639,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
|
|
|
13575
13639
|
setup(__props, { emit: emit2 }) {
|
|
13576
13640
|
const props = __props;
|
|
13577
13641
|
const dynamicDataStore = useDynamicDataStore();
|
|
13578
|
-
const { dynamicDataIdMap, loading } = storeToRefs(dynamicDataStore);
|
|
13642
|
+
const { dynamicDataIdMap, loadingIds, loading } = storeToRefs(dynamicDataStore);
|
|
13579
13643
|
const elementComponent = computed(() => {
|
|
13580
13644
|
switch (props.element.type) {
|
|
13581
13645
|
case DocumentElementType.IMAGE:
|
|
@@ -13601,9 +13665,6 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
|
|
|
13601
13665
|
}
|
|
13602
13666
|
return "searchResultsProductTitle";
|
|
13603
13667
|
});
|
|
13604
|
-
const isLoadingDynamicData = computed(() => {
|
|
13605
|
-
return Boolean(props.element.dynamic && loading.value);
|
|
13606
|
-
});
|
|
13607
13668
|
const enhancedItem = computed(() => {
|
|
13608
13669
|
var _a, _b, _c, _d;
|
|
13609
13670
|
if (!((_a = props.item) == null ? void 0 : _a.id)) {
|
|
@@ -13618,7 +13679,11 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
|
|
|
13618
13679
|
const handleProductEvent = (item) => {
|
|
13619
13680
|
emit2("productEvent", item);
|
|
13620
13681
|
};
|
|
13682
|
+
const isLoadingDynamicData = (id) => {
|
|
13683
|
+
return Boolean(props.element.dynamic && id && loading.value && (loadingIds == null ? void 0 : loadingIds.value[id]));
|
|
13684
|
+
};
|
|
13621
13685
|
return (_ctx, _cache) => {
|
|
13686
|
+
var _a;
|
|
13622
13687
|
return displayElement.value ? (openBlock(), createBlock(resolveDynamicComponent(elementComponent.value), {
|
|
13623
13688
|
key: 0,
|
|
13624
13689
|
item: enhancedItem.value,
|
|
@@ -13626,7 +13691,7 @@ const _sfc_main$l = /* @__PURE__ */ defineComponent(__spreadProps2(__spreadValue
|
|
|
13626
13691
|
labels: _ctx.labels,
|
|
13627
13692
|
inStock: _ctx.inStock,
|
|
13628
13693
|
link: _ctx.link,
|
|
13629
|
-
class: normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData.
|
|
13694
|
+
class: normalizeClass({ "lupa-loading-dynamic-data": isLoadingDynamicData((_a = _ctx.item) == null ? void 0 : _a.id) }),
|
|
13630
13695
|
onProductEvent: handleProductEvent
|
|
13631
13696
|
}, null, 40, ["item", "options", "labels", "inStock", "link", "class"])) : createCommentVNode("", true);
|
|
13632
13697
|
};
|
|
@@ -14153,7 +14218,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
14153
14218
|
const props = __props;
|
|
14154
14219
|
const searchResultStore = useSearchResultStore();
|
|
14155
14220
|
const paramStore = useParamsStore();
|
|
14156
|
-
useOptionsStore();
|
|
14221
|
+
const optionStore = useOptionsStore();
|
|
14157
14222
|
const {
|
|
14158
14223
|
hasResults,
|
|
14159
14224
|
currentQueryText,
|
|
@@ -14237,7 +14302,7 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
14237
14302
|
};
|
|
14238
14303
|
const goToFirstPage = () => {
|
|
14239
14304
|
paramStore.appendParams({
|
|
14240
|
-
params: [{ name: QUERY_PARAMS$1.PAGE, value: "1" }]
|
|
14305
|
+
params: [{ name: optionStore.getQueryParamName(QUERY_PARAMS$1.PAGE), value: "1" }]
|
|
14241
14306
|
});
|
|
14242
14307
|
};
|
|
14243
14308
|
return (_ctx, _cache) => {
|
|
@@ -14443,7 +14508,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14443
14508
|
const handlePopState = () => {
|
|
14444
14509
|
var _a;
|
|
14445
14510
|
const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
|
|
14446
|
-
paramStore.add(parseParams(searchParams));
|
|
14511
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, searchParams));
|
|
14447
14512
|
};
|
|
14448
14513
|
onMounted(() => __async(this, null, function* () {
|
|
14449
14514
|
var _a, _b;
|
|
@@ -14543,7 +14608,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14543
14608
|
var _a;
|
|
14544
14609
|
const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url, params);
|
|
14545
14610
|
const publicQuery = createPublicQuery(
|
|
14546
|
-
parseParams(searchParams),
|
|
14611
|
+
parseParams(optionStore.getQueryParamName, searchParams),
|
|
14547
14612
|
props.options.sort,
|
|
14548
14613
|
defaultSearchResultPageSize.value
|
|
14549
14614
|
);
|
|
@@ -14563,10 +14628,10 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14563
14628
|
}
|
|
14564
14629
|
}
|
|
14565
14630
|
const params = new URLSearchParams(window.location.search);
|
|
14566
|
-
if (!params.has(QUERY_PARAMS$1.QUERY) && !props.initialData) {
|
|
14631
|
+
if (!params.has(optionStore.getQueryParamName(QUERY_PARAMS$1.QUERY)) && !props.initialData) {
|
|
14567
14632
|
handleUrlChange(params);
|
|
14568
14633
|
}
|
|
14569
|
-
paramStore.add(parseParams(params));
|
|
14634
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, params));
|
|
14570
14635
|
paramStore.setDefaultLimit(defaultSearchResultPageSize.value);
|
|
14571
14636
|
};
|
|
14572
14637
|
watch(searchString, () => handleParamsChange());
|
|
@@ -14600,7 +14665,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
14600
14665
|
);
|
|
14601
14666
|
optionStore.setSearchResultOptions({ options: props.options });
|
|
14602
14667
|
searchResultStore.add(__spreadValues2({}, initialData));
|
|
14603
|
-
paramStore.add(parseParams(searchParams), props.options.ssr);
|
|
14668
|
+
paramStore.add(parseParams(optionStore.getQueryParamName, searchParams), props.options.ssr);
|
|
14604
14669
|
paramStore.setDefaultLimit(defaultSearchResultPageSize.value);
|
|
14605
14670
|
handleResults({ queryKey: props.options.queryKey, results: initialData });
|
|
14606
14671
|
}
|