@getlupa/vue 0.15.9 → 0.15.11
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
|
@@ -20107,7 +20107,10 @@ const _hoisted_2$a = {
|
|
|
20107
20107
|
class: "lupa-category-back"
|
|
20108
20108
|
};
|
|
20109
20109
|
const _hoisted_3$6 = ["href"];
|
|
20110
|
-
const _hoisted_4$3 = {
|
|
20110
|
+
const _hoisted_4$3 = {
|
|
20111
|
+
key: 1,
|
|
20112
|
+
class: "lupa-child-category-list"
|
|
20113
|
+
};
|
|
20111
20114
|
const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
20112
20115
|
__name: "CategoryTopFilters",
|
|
20113
20116
|
props: {
|
|
@@ -20121,6 +20124,10 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20121
20124
|
var _a, _b;
|
|
20122
20125
|
return Boolean((_b = (_a = props.options.categories) == null ? void 0 : _a.back) == null ? void 0 : _b.title);
|
|
20123
20126
|
});
|
|
20127
|
+
const hasRelatedCategoryChildren = vue.computed(() => {
|
|
20128
|
+
var _a;
|
|
20129
|
+
return ((_a = relatedCategoryChildren.value) == null ? void 0 : _a.length) > 0;
|
|
20130
|
+
});
|
|
20124
20131
|
const backTitle = vue.computed(() => {
|
|
20125
20132
|
var _a, _b;
|
|
20126
20133
|
return (_b = (_a = props.options.categories) == null ? void 0 : _a.back) == null ? void 0 : _b.title;
|
|
@@ -20147,7 +20154,10 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20147
20154
|
};
|
|
20148
20155
|
return (_ctx, _cache) => {
|
|
20149
20156
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
20150
|
-
class: vue.normalizeClass(["lupa-category-top-mobile-filters", {
|
|
20157
|
+
class: vue.normalizeClass(["lupa-category-top-mobile-filters", {
|
|
20158
|
+
"lupa-has-back-button": hasBackButton.value,
|
|
20159
|
+
"has-related-category-children": hasRelatedCategoryChildren.value
|
|
20160
|
+
}])
|
|
20151
20161
|
}, [
|
|
20152
20162
|
vue.createElementVNode("div", _hoisted_1$d, [
|
|
20153
20163
|
hasBackButton.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$a, [
|
|
@@ -20157,7 +20167,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20157
20167
|
onClick: handleNavigationBack
|
|
20158
20168
|
}, vue.toDisplayString(backTitle.value), 9, _hoisted_3$6)
|
|
20159
20169
|
])) : vue.createCommentVNode("", true),
|
|
20160
|
-
vue.
|
|
20170
|
+
hasRelatedCategoryChildren.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$3, [
|
|
20161
20171
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(vue.unref(relatedCategoryChildren), (child) => {
|
|
20162
20172
|
return vue.openBlock(), vue.createBlock(_sfc_main$U, {
|
|
20163
20173
|
key: getCategoryKey(child),
|
|
@@ -20165,7 +20175,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20165
20175
|
options: categoryOptions.value
|
|
20166
20176
|
}, null, 8, ["item", "options"]);
|
|
20167
20177
|
}), 128))
|
|
20168
|
-
]),
|
|
20178
|
+
])) : vue.createCommentVNode("", true),
|
|
20169
20179
|
vue.createVNode(_sfc_main$B, {
|
|
20170
20180
|
class: "lupa-toolbar-mobile",
|
|
20171
20181
|
"pagination-location": "top",
|
|
@@ -20176,6 +20186,74 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
|
|
|
20176
20186
|
};
|
|
20177
20187
|
}
|
|
20178
20188
|
});
|
|
20189
|
+
const extractValue = (options) => {
|
|
20190
|
+
switch (options.extractFrom) {
|
|
20191
|
+
case "url":
|
|
20192
|
+
return extractFromUrl(options);
|
|
20193
|
+
case "localStorage":
|
|
20194
|
+
case "sessionStorage":
|
|
20195
|
+
return extractFromStorage(options);
|
|
20196
|
+
case "htmlElementText":
|
|
20197
|
+
return extractFromHtmlElementText(options);
|
|
20198
|
+
case "cookie":
|
|
20199
|
+
return extractFromCookie(options);
|
|
20200
|
+
default:
|
|
20201
|
+
return options.default;
|
|
20202
|
+
}
|
|
20203
|
+
};
|
|
20204
|
+
const extractFromCookie = (options) => {
|
|
20205
|
+
var _a, _b;
|
|
20206
|
+
try {
|
|
20207
|
+
const cookieValue = (_b = (_a = document.cookie) == null ? void 0 : _a.split("; ")) == null ? void 0 : _b.find((row) => row == null ? void 0 : row.startsWith(`${options.cookieName}=`));
|
|
20208
|
+
return cookieValue ? cookieValue.split("=")[1] : options.default;
|
|
20209
|
+
} catch (e2) {
|
|
20210
|
+
return options.default;
|
|
20211
|
+
}
|
|
20212
|
+
};
|
|
20213
|
+
const extractFromUrl = (options) => {
|
|
20214
|
+
const regex = new RegExp(options.regex);
|
|
20215
|
+
const match = window.location.href.match(regex);
|
|
20216
|
+
return match ? match[1] : options.default;
|
|
20217
|
+
};
|
|
20218
|
+
const extractFromStorage = (options) => {
|
|
20219
|
+
const storage = options.extractFrom === "localStorage" ? localStorage : sessionStorage;
|
|
20220
|
+
let rawValue2 = "";
|
|
20221
|
+
try {
|
|
20222
|
+
rawValue2 = storage.getItem(options.key);
|
|
20223
|
+
} catch (e2) {
|
|
20224
|
+
return options.default;
|
|
20225
|
+
}
|
|
20226
|
+
if (rawValue2) {
|
|
20227
|
+
try {
|
|
20228
|
+
const parsedValue = JSON.parse(rawValue2);
|
|
20229
|
+
return options.path ? getValueFromPath(parsedValue, options.path) : parsedValue;
|
|
20230
|
+
} catch (e2) {
|
|
20231
|
+
return rawValue2;
|
|
20232
|
+
}
|
|
20233
|
+
}
|
|
20234
|
+
return options.default;
|
|
20235
|
+
};
|
|
20236
|
+
const extractFromHtmlElementText = (options) => {
|
|
20237
|
+
var _a;
|
|
20238
|
+
const element = document.querySelector(options.querySelector);
|
|
20239
|
+
return element ? ((_a = element.textContent) == null ? void 0 : _a.trim()) || options.default : options.default;
|
|
20240
|
+
};
|
|
20241
|
+
const getValueFromPath = (obj, path) => {
|
|
20242
|
+
return path.split(".").reduce((value, key) => value && value[key] || null, obj);
|
|
20243
|
+
};
|
|
20244
|
+
const processExtractionObject = (value = {}) => {
|
|
20245
|
+
var _a;
|
|
20246
|
+
const parsedObject = {};
|
|
20247
|
+
for (const key in value) {
|
|
20248
|
+
if (isObject$1(value[key]) && ((_a = value[key]) == null ? void 0 : _a.extractFrom)) {
|
|
20249
|
+
const extractedValue = extractValue(value[key]);
|
|
20250
|
+
parsedObject[key] = Array.isArray(extractedValue) ? extractedValue : [extractedValue];
|
|
20251
|
+
} else {
|
|
20252
|
+
parsedObject[key] = value[key];
|
|
20253
|
+
}
|
|
20254
|
+
}
|
|
20255
|
+
return parsedObject;
|
|
20256
|
+
};
|
|
20179
20257
|
const _hoisted_1$c = {
|
|
20180
20258
|
key: 0,
|
|
20181
20259
|
class: "lupa-container-title-summary-mobile"
|
|
@@ -20205,9 +20283,12 @@ const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
|
|
|
20205
20283
|
const dynamicDataStore = useDynamicDataStore();
|
|
20206
20284
|
const screenStore = useScreenStore();
|
|
20207
20285
|
const redirectionStore = useRedirectionStore();
|
|
20286
|
+
const extractedInitialFilters = vue.computed(() => {
|
|
20287
|
+
return __spreadValues({}, processExtractionObject(props.options.initialFilters));
|
|
20288
|
+
});
|
|
20208
20289
|
const initialFilters = vue.computed(() => {
|
|
20209
|
-
var _a;
|
|
20210
|
-
return (_a = props.initialFilters) != null ? _a : {};
|
|
20290
|
+
var _a, _b;
|
|
20291
|
+
return (_b = (_a = props.initialFilters) != null ? _a : extractedInitialFilters.value) != null ? _b : {};
|
|
20211
20292
|
});
|
|
20212
20293
|
const { currentQueryText, hasResults, currentFilterCount } = storeToRefs(searchResultStore);
|
|
20213
20294
|
const { searchString, sortParams } = storeToRefs(paramStore);
|
|
@@ -20513,62 +20594,6 @@ const _sfc_main$d = /* @__PURE__ */ vue.defineComponent({
|
|
|
20513
20594
|
};
|
|
20514
20595
|
}
|
|
20515
20596
|
});
|
|
20516
|
-
const extractValue = (options) => {
|
|
20517
|
-
switch (options.extractFrom) {
|
|
20518
|
-
case "url":
|
|
20519
|
-
return extractFromUrl(options);
|
|
20520
|
-
case "localStorage":
|
|
20521
|
-
case "sessionStorage":
|
|
20522
|
-
return extractFromStorage(options);
|
|
20523
|
-
case "htmlElementText":
|
|
20524
|
-
return extractFromHtmlElementText(options);
|
|
20525
|
-
default:
|
|
20526
|
-
return options.default;
|
|
20527
|
-
}
|
|
20528
|
-
};
|
|
20529
|
-
const extractFromUrl = (options) => {
|
|
20530
|
-
const regex = new RegExp(options.regex);
|
|
20531
|
-
const match = window.location.href.match(regex);
|
|
20532
|
-
return match ? match[1] : options.default;
|
|
20533
|
-
};
|
|
20534
|
-
const extractFromStorage = (options) => {
|
|
20535
|
-
const storage = options.extractFrom === "localStorage" ? localStorage : sessionStorage;
|
|
20536
|
-
let rawValue2 = "";
|
|
20537
|
-
try {
|
|
20538
|
-
rawValue2 = storage.getItem(options.key);
|
|
20539
|
-
} catch (e2) {
|
|
20540
|
-
return options.default;
|
|
20541
|
-
}
|
|
20542
|
-
if (rawValue2) {
|
|
20543
|
-
try {
|
|
20544
|
-
const parsedValue = JSON.parse(rawValue2);
|
|
20545
|
-
return options.path ? getValueFromPath(parsedValue, options.path) : parsedValue;
|
|
20546
|
-
} catch (e2) {
|
|
20547
|
-
return rawValue2;
|
|
20548
|
-
}
|
|
20549
|
-
}
|
|
20550
|
-
return options.default;
|
|
20551
|
-
};
|
|
20552
|
-
const extractFromHtmlElementText = (options) => {
|
|
20553
|
-
var _a;
|
|
20554
|
-
const element = document.querySelector(options.querySelector);
|
|
20555
|
-
return element ? ((_a = element.textContent) == null ? void 0 : _a.trim()) || options.default : options.default;
|
|
20556
|
-
};
|
|
20557
|
-
const getValueFromPath = (obj, path) => {
|
|
20558
|
-
return path.split(".").reduce((value, key) => value && value[key] || null, obj);
|
|
20559
|
-
};
|
|
20560
|
-
const processExtractionObject = (value = {}) => {
|
|
20561
|
-
var _a;
|
|
20562
|
-
const parsedObject = {};
|
|
20563
|
-
for (const key in value) {
|
|
20564
|
-
if (isObject$1(value[key]) && ((_a = value[key]) == null ? void 0 : _a.extractFrom)) {
|
|
20565
|
-
parsedObject[key] = extractValue(value[key]);
|
|
20566
|
-
} else {
|
|
20567
|
-
parsedObject[key] = value[key];
|
|
20568
|
-
}
|
|
20569
|
-
}
|
|
20570
|
-
return parsedObject;
|
|
20571
|
-
};
|
|
20572
20597
|
const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
20573
20598
|
__name: "ProductList",
|
|
20574
20599
|
props: {
|
|
@@ -20588,7 +20613,7 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
20588
20613
|
var _a;
|
|
20589
20614
|
(_a = searchResults.value) == null ? void 0 : _a.handleMounted();
|
|
20590
20615
|
};
|
|
20591
|
-
vue.computed(() => {
|
|
20616
|
+
const initialFilters = vue.computed(() => {
|
|
20592
20617
|
return __spreadValues({}, processExtractionObject(props.options.initialFilters));
|
|
20593
20618
|
});
|
|
20594
20619
|
__expose({ fetch: fetch2 });
|
|
@@ -20596,7 +20621,7 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
20596
20621
|
return vue.openBlock(), vue.createElementBlock("div", null, [
|
|
20597
20622
|
vue.createVNode(_sfc_main$e, {
|
|
20598
20623
|
options: componentOptions.value,
|
|
20599
|
-
"initial-filters":
|
|
20624
|
+
"initial-filters": initialFilters.value,
|
|
20600
20625
|
"is-product-list": true,
|
|
20601
20626
|
ref_key: "searchResults",
|
|
20602
20627
|
ref: searchResults
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -20105,7 +20105,10 @@ const _hoisted_2$a = {
|
|
|
20105
20105
|
class: "lupa-category-back"
|
|
20106
20106
|
};
|
|
20107
20107
|
const _hoisted_3$6 = ["href"];
|
|
20108
|
-
const _hoisted_4$3 = {
|
|
20108
|
+
const _hoisted_4$3 = {
|
|
20109
|
+
key: 1,
|
|
20110
|
+
class: "lupa-child-category-list"
|
|
20111
|
+
};
|
|
20109
20112
|
const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
20110
20113
|
__name: "CategoryTopFilters",
|
|
20111
20114
|
props: {
|
|
@@ -20119,6 +20122,10 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20119
20122
|
var _a, _b;
|
|
20120
20123
|
return Boolean((_b = (_a = props.options.categories) == null ? void 0 : _a.back) == null ? void 0 : _b.title);
|
|
20121
20124
|
});
|
|
20125
|
+
const hasRelatedCategoryChildren = computed(() => {
|
|
20126
|
+
var _a;
|
|
20127
|
+
return ((_a = relatedCategoryChildren.value) == null ? void 0 : _a.length) > 0;
|
|
20128
|
+
});
|
|
20122
20129
|
const backTitle = computed(() => {
|
|
20123
20130
|
var _a, _b;
|
|
20124
20131
|
return (_b = (_a = props.options.categories) == null ? void 0 : _a.back) == null ? void 0 : _b.title;
|
|
@@ -20145,7 +20152,10 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20145
20152
|
};
|
|
20146
20153
|
return (_ctx, _cache) => {
|
|
20147
20154
|
return openBlock(), createElementBlock("div", {
|
|
20148
|
-
class: normalizeClass(["lupa-category-top-mobile-filters", {
|
|
20155
|
+
class: normalizeClass(["lupa-category-top-mobile-filters", {
|
|
20156
|
+
"lupa-has-back-button": hasBackButton.value,
|
|
20157
|
+
"has-related-category-children": hasRelatedCategoryChildren.value
|
|
20158
|
+
}])
|
|
20149
20159
|
}, [
|
|
20150
20160
|
createElementVNode("div", _hoisted_1$d, [
|
|
20151
20161
|
hasBackButton.value ? (openBlock(), createElementBlock("div", _hoisted_2$a, [
|
|
@@ -20155,7 +20165,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20155
20165
|
onClick: handleNavigationBack
|
|
20156
20166
|
}, toDisplayString(backTitle.value), 9, _hoisted_3$6)
|
|
20157
20167
|
])) : createCommentVNode("", true),
|
|
20158
|
-
|
|
20168
|
+
hasRelatedCategoryChildren.value ? (openBlock(), createElementBlock("div", _hoisted_4$3, [
|
|
20159
20169
|
(openBlock(true), createElementBlock(Fragment, null, renderList(unref(relatedCategoryChildren), (child) => {
|
|
20160
20170
|
return openBlock(), createBlock(_sfc_main$U, {
|
|
20161
20171
|
key: getCategoryKey(child),
|
|
@@ -20163,7 +20173,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20163
20173
|
options: categoryOptions.value
|
|
20164
20174
|
}, null, 8, ["item", "options"]);
|
|
20165
20175
|
}), 128))
|
|
20166
|
-
]),
|
|
20176
|
+
])) : createCommentVNode("", true),
|
|
20167
20177
|
createVNode(_sfc_main$B, {
|
|
20168
20178
|
class: "lupa-toolbar-mobile",
|
|
20169
20179
|
"pagination-location": "top",
|
|
@@ -20174,6 +20184,74 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
20174
20184
|
};
|
|
20175
20185
|
}
|
|
20176
20186
|
});
|
|
20187
|
+
const extractValue = (options) => {
|
|
20188
|
+
switch (options.extractFrom) {
|
|
20189
|
+
case "url":
|
|
20190
|
+
return extractFromUrl(options);
|
|
20191
|
+
case "localStorage":
|
|
20192
|
+
case "sessionStorage":
|
|
20193
|
+
return extractFromStorage(options);
|
|
20194
|
+
case "htmlElementText":
|
|
20195
|
+
return extractFromHtmlElementText(options);
|
|
20196
|
+
case "cookie":
|
|
20197
|
+
return extractFromCookie(options);
|
|
20198
|
+
default:
|
|
20199
|
+
return options.default;
|
|
20200
|
+
}
|
|
20201
|
+
};
|
|
20202
|
+
const extractFromCookie = (options) => {
|
|
20203
|
+
var _a, _b;
|
|
20204
|
+
try {
|
|
20205
|
+
const cookieValue = (_b = (_a = document.cookie) == null ? void 0 : _a.split("; ")) == null ? void 0 : _b.find((row) => row == null ? void 0 : row.startsWith(`${options.cookieName}=`));
|
|
20206
|
+
return cookieValue ? cookieValue.split("=")[1] : options.default;
|
|
20207
|
+
} catch (e2) {
|
|
20208
|
+
return options.default;
|
|
20209
|
+
}
|
|
20210
|
+
};
|
|
20211
|
+
const extractFromUrl = (options) => {
|
|
20212
|
+
const regex = new RegExp(options.regex);
|
|
20213
|
+
const match = window.location.href.match(regex);
|
|
20214
|
+
return match ? match[1] : options.default;
|
|
20215
|
+
};
|
|
20216
|
+
const extractFromStorage = (options) => {
|
|
20217
|
+
const storage = options.extractFrom === "localStorage" ? localStorage : sessionStorage;
|
|
20218
|
+
let rawValue2 = "";
|
|
20219
|
+
try {
|
|
20220
|
+
rawValue2 = storage.getItem(options.key);
|
|
20221
|
+
} catch (e2) {
|
|
20222
|
+
return options.default;
|
|
20223
|
+
}
|
|
20224
|
+
if (rawValue2) {
|
|
20225
|
+
try {
|
|
20226
|
+
const parsedValue = JSON.parse(rawValue2);
|
|
20227
|
+
return options.path ? getValueFromPath(parsedValue, options.path) : parsedValue;
|
|
20228
|
+
} catch (e2) {
|
|
20229
|
+
return rawValue2;
|
|
20230
|
+
}
|
|
20231
|
+
}
|
|
20232
|
+
return options.default;
|
|
20233
|
+
};
|
|
20234
|
+
const extractFromHtmlElementText = (options) => {
|
|
20235
|
+
var _a;
|
|
20236
|
+
const element = document.querySelector(options.querySelector);
|
|
20237
|
+
return element ? ((_a = element.textContent) == null ? void 0 : _a.trim()) || options.default : options.default;
|
|
20238
|
+
};
|
|
20239
|
+
const getValueFromPath = (obj, path) => {
|
|
20240
|
+
return path.split(".").reduce((value, key) => value && value[key] || null, obj);
|
|
20241
|
+
};
|
|
20242
|
+
const processExtractionObject = (value = {}) => {
|
|
20243
|
+
var _a;
|
|
20244
|
+
const parsedObject = {};
|
|
20245
|
+
for (const key in value) {
|
|
20246
|
+
if (isObject$1(value[key]) && ((_a = value[key]) == null ? void 0 : _a.extractFrom)) {
|
|
20247
|
+
const extractedValue = extractValue(value[key]);
|
|
20248
|
+
parsedObject[key] = Array.isArray(extractedValue) ? extractedValue : [extractedValue];
|
|
20249
|
+
} else {
|
|
20250
|
+
parsedObject[key] = value[key];
|
|
20251
|
+
}
|
|
20252
|
+
}
|
|
20253
|
+
return parsedObject;
|
|
20254
|
+
};
|
|
20177
20255
|
const _hoisted_1$c = {
|
|
20178
20256
|
key: 0,
|
|
20179
20257
|
class: "lupa-container-title-summary-mobile"
|
|
@@ -20203,9 +20281,12 @@ const _sfc_main$e = /* @__PURE__ */ defineComponent({
|
|
|
20203
20281
|
const dynamicDataStore = useDynamicDataStore();
|
|
20204
20282
|
const screenStore = useScreenStore();
|
|
20205
20283
|
const redirectionStore = useRedirectionStore();
|
|
20284
|
+
const extractedInitialFilters = computed(() => {
|
|
20285
|
+
return __spreadValues({}, processExtractionObject(props.options.initialFilters));
|
|
20286
|
+
});
|
|
20206
20287
|
const initialFilters = computed(() => {
|
|
20207
|
-
var _a;
|
|
20208
|
-
return (_a = props.initialFilters) != null ? _a : {};
|
|
20288
|
+
var _a, _b;
|
|
20289
|
+
return (_b = (_a = props.initialFilters) != null ? _a : extractedInitialFilters.value) != null ? _b : {};
|
|
20209
20290
|
});
|
|
20210
20291
|
const { currentQueryText, hasResults, currentFilterCount } = storeToRefs(searchResultStore);
|
|
20211
20292
|
const { searchString, sortParams } = storeToRefs(paramStore);
|
|
@@ -20511,62 +20592,6 @@ const _sfc_main$d = /* @__PURE__ */ defineComponent({
|
|
|
20511
20592
|
};
|
|
20512
20593
|
}
|
|
20513
20594
|
});
|
|
20514
|
-
const extractValue = (options) => {
|
|
20515
|
-
switch (options.extractFrom) {
|
|
20516
|
-
case "url":
|
|
20517
|
-
return extractFromUrl(options);
|
|
20518
|
-
case "localStorage":
|
|
20519
|
-
case "sessionStorage":
|
|
20520
|
-
return extractFromStorage(options);
|
|
20521
|
-
case "htmlElementText":
|
|
20522
|
-
return extractFromHtmlElementText(options);
|
|
20523
|
-
default:
|
|
20524
|
-
return options.default;
|
|
20525
|
-
}
|
|
20526
|
-
};
|
|
20527
|
-
const extractFromUrl = (options) => {
|
|
20528
|
-
const regex = new RegExp(options.regex);
|
|
20529
|
-
const match = window.location.href.match(regex);
|
|
20530
|
-
return match ? match[1] : options.default;
|
|
20531
|
-
};
|
|
20532
|
-
const extractFromStorage = (options) => {
|
|
20533
|
-
const storage = options.extractFrom === "localStorage" ? localStorage : sessionStorage;
|
|
20534
|
-
let rawValue2 = "";
|
|
20535
|
-
try {
|
|
20536
|
-
rawValue2 = storage.getItem(options.key);
|
|
20537
|
-
} catch (e2) {
|
|
20538
|
-
return options.default;
|
|
20539
|
-
}
|
|
20540
|
-
if (rawValue2) {
|
|
20541
|
-
try {
|
|
20542
|
-
const parsedValue = JSON.parse(rawValue2);
|
|
20543
|
-
return options.path ? getValueFromPath(parsedValue, options.path) : parsedValue;
|
|
20544
|
-
} catch (e2) {
|
|
20545
|
-
return rawValue2;
|
|
20546
|
-
}
|
|
20547
|
-
}
|
|
20548
|
-
return options.default;
|
|
20549
|
-
};
|
|
20550
|
-
const extractFromHtmlElementText = (options) => {
|
|
20551
|
-
var _a;
|
|
20552
|
-
const element = document.querySelector(options.querySelector);
|
|
20553
|
-
return element ? ((_a = element.textContent) == null ? void 0 : _a.trim()) || options.default : options.default;
|
|
20554
|
-
};
|
|
20555
|
-
const getValueFromPath = (obj, path) => {
|
|
20556
|
-
return path.split(".").reduce((value, key) => value && value[key] || null, obj);
|
|
20557
|
-
};
|
|
20558
|
-
const processExtractionObject = (value = {}) => {
|
|
20559
|
-
var _a;
|
|
20560
|
-
const parsedObject = {};
|
|
20561
|
-
for (const key in value) {
|
|
20562
|
-
if (isObject$1(value[key]) && ((_a = value[key]) == null ? void 0 : _a.extractFrom)) {
|
|
20563
|
-
parsedObject[key] = extractValue(value[key]);
|
|
20564
|
-
} else {
|
|
20565
|
-
parsedObject[key] = value[key];
|
|
20566
|
-
}
|
|
20567
|
-
}
|
|
20568
|
-
return parsedObject;
|
|
20569
|
-
};
|
|
20570
20595
|
const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
20571
20596
|
__name: "ProductList",
|
|
20572
20597
|
props: {
|
|
@@ -20586,7 +20611,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
20586
20611
|
var _a;
|
|
20587
20612
|
(_a = searchResults.value) == null ? void 0 : _a.handleMounted();
|
|
20588
20613
|
};
|
|
20589
|
-
computed(() => {
|
|
20614
|
+
const initialFilters = computed(() => {
|
|
20590
20615
|
return __spreadValues({}, processExtractionObject(props.options.initialFilters));
|
|
20591
20616
|
});
|
|
20592
20617
|
__expose({ fetch: fetch2 });
|
|
@@ -20594,7 +20619,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
20594
20619
|
return openBlock(), createElementBlock("div", null, [
|
|
20595
20620
|
createVNode(_sfc_main$e, {
|
|
20596
20621
|
options: componentOptions.value,
|
|
20597
|
-
"initial-filters":
|
|
20622
|
+
"initial-filters": initialFilters.value,
|
|
20598
20623
|
"is-product-list": true,
|
|
20599
20624
|
ref_key: "searchResults",
|
|
20600
20625
|
ref: searchResults
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ExtractFrom = 'url' | 'localStorage' | 'sessionStorage' | 'htmlElementText';
|
|
1
|
+
export type ExtractFrom = 'url' | 'localStorage' | 'sessionStorage' | 'htmlElementText' | 'cookie';
|
|
2
2
|
export type BaseExtractFrom = {
|
|
3
3
|
extractFrom: ExtractFrom;
|
|
4
4
|
default: string | number | Record<string, unknown>;
|
|
@@ -16,4 +16,8 @@ export type ExtractFromHtmlElementText = BaseExtractFrom & {
|
|
|
16
16
|
extractFrom: 'htmlElementText';
|
|
17
17
|
querySelector: string;
|
|
18
18
|
};
|
|
19
|
-
export type
|
|
19
|
+
export type ExtractFromCookie = BaseExtractFrom & {
|
|
20
|
+
extractFrom: 'cookie';
|
|
21
|
+
cookieName: string;
|
|
22
|
+
};
|
|
23
|
+
export type DataExtraction = ExtractFromUrl | ExtractFromStorage | ExtractFromHtmlElementText | ExtractFromCookie;
|
|
@@ -6,6 +6,8 @@ import type { SearchResultsSortOptions } from './SearchResultsSort';
|
|
|
6
6
|
import { RedirectionOptions } from '../redirections/RedirectionOptions';
|
|
7
7
|
import { RelatedQueryOptions } from './RelatedQueryOptions';
|
|
8
8
|
import { RedirectionSuggestionOptions } from './RedirectionSuggestionOptionts';
|
|
9
|
+
import { FilterGroup } from '@getlupa/client-sdk/Types';
|
|
10
|
+
import { DataExtraction } from '../DataExtraction';
|
|
9
11
|
export type SearchResultsOptions = SearchResultsProductOptions & SearchResultsAdditionalPanels & {
|
|
10
12
|
containerSelector: string;
|
|
11
13
|
breadcrumbs: SearchResultsBreadcrumb[];
|
|
@@ -17,6 +19,7 @@ export type SearchResultsOptions = SearchResultsProductOptions & SearchResultsAd
|
|
|
17
19
|
ssr?: SsrOptions;
|
|
18
20
|
redirections?: RedirectionOptions;
|
|
19
21
|
scrollToResults?: ScrollToResultsOptions;
|
|
22
|
+
initialFilters?: FilterGroup | Record<string, DataExtraction>;
|
|
20
23
|
};
|
|
21
24
|
export type ScrollToResultsOptions = {
|
|
22
25
|
enabled?: boolean;
|