@getlupa/client 1.6.3 → 1.6.4
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 -111
- package/dist/lupaSearch.js +128 -111
- package/dist/lupaSearch.mjs +128 -111
- package/dist/lupaSearch.umd.js +128 -111
- package/package.json +2 -2
package/dist/lupaSearch.iife.js
CHANGED
|
@@ -6572,21 +6572,21 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
6572
6572
|
);
|
|
6573
6573
|
};
|
|
6574
6574
|
const sendGa4AnalyticsEvent = (data, options) => {
|
|
6575
|
-
var _a, _b, _c, _d, _e;
|
|
6575
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
6576
6576
|
if (!window || !window.dataLayer) {
|
|
6577
6577
|
console.error("dataLayer object not found.");
|
|
6578
6578
|
return;
|
|
6579
6579
|
}
|
|
6580
6580
|
const sendItemTitle = data.searchQuery !== ((_a = data.analytics) == null ? void 0 : _a.label);
|
|
6581
6581
|
const title = sendItemTitle ? (_b = data.analytics) == null ? void 0 : _b.label : void 0;
|
|
6582
|
-
const params = {
|
|
6582
|
+
const params = __spreadValues2({
|
|
6583
6583
|
search_text: data.searchQuery,
|
|
6584
6584
|
item_title: title,
|
|
6585
6585
|
item_id: data.itemId,
|
|
6586
6586
|
ecommerce: parseEcommerceData(data, (_c = data.analytics) == null ? void 0 : _c.listLabel)
|
|
6587
|
-
};
|
|
6587
|
+
}, (_e = (_d = data.analytics) == null ? void 0 : _d.additionalParams) != null ? _e : {});
|
|
6588
6588
|
window.dataLayer.push(__spreadValues2({
|
|
6589
|
-
event: (
|
|
6589
|
+
event: (_g = (_f = data.analytics) == null ? void 0 : _f.type) != null ? _g : options.parentEventName
|
|
6590
6590
|
}, params));
|
|
6591
6591
|
};
|
|
6592
6592
|
const processDebugEvent = (data) => {
|
|
@@ -7429,6 +7429,10 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7429
7429
|
const searchString = ref("");
|
|
7430
7430
|
const optionsStore = useOptionsStore();
|
|
7431
7431
|
const redirectionStore = useRedirectionStore();
|
|
7432
|
+
const sortParams = ref({
|
|
7433
|
+
selectedSortKey: "",
|
|
7434
|
+
previousSortKey: ""
|
|
7435
|
+
});
|
|
7432
7436
|
const query = computed(() => params.value[QUERY_PARAMS_PARSED.QUERY]);
|
|
7433
7437
|
const page = computed(() => {
|
|
7434
7438
|
const page2 = Number(params.value[QUERY_PARAMS_PARSED.PAGE]) || 1;
|
|
@@ -7563,6 +7567,12 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7563
7567
|
}
|
|
7564
7568
|
searchResultsLink.value = newSearchResultsLink;
|
|
7565
7569
|
};
|
|
7570
|
+
const setSortSettings = ({ selectedSortKey, previousSortKey }) => {
|
|
7571
|
+
sortParams.value = {
|
|
7572
|
+
selectedSortKey,
|
|
7573
|
+
previousSortKey
|
|
7574
|
+
};
|
|
7575
|
+
};
|
|
7566
7576
|
return {
|
|
7567
7577
|
params,
|
|
7568
7578
|
defaultLimit,
|
|
@@ -7573,6 +7583,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7573
7583
|
limit,
|
|
7574
7584
|
sort,
|
|
7575
7585
|
filters,
|
|
7586
|
+
sortParams,
|
|
7576
7587
|
add: add2,
|
|
7577
7588
|
removeAllFilters,
|
|
7578
7589
|
removeParameters,
|
|
@@ -7580,7 +7591,8 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
7580
7591
|
goToResults,
|
|
7581
7592
|
appendParams,
|
|
7582
7593
|
setDefaultLimit,
|
|
7583
|
-
setSearchResultsLink
|
|
7594
|
+
setSearchResultsLink,
|
|
7595
|
+
setSortSettings
|
|
7584
7596
|
};
|
|
7585
7597
|
});
|
|
7586
7598
|
const flattenFacet = (key, facets, suggestion, inputValue) => {
|
|
@@ -8889,61 +8901,6 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
8889
8901
|
};
|
|
8890
8902
|
}
|
|
8891
8903
|
}));
|
|
8892
|
-
const getSearchTrackingData = (searchText, type) => {
|
|
8893
|
-
return {
|
|
8894
|
-
searchQuery: searchText,
|
|
8895
|
-
analytics: {
|
|
8896
|
-
type,
|
|
8897
|
-
label: searchText
|
|
8898
|
-
}
|
|
8899
|
-
};
|
|
8900
|
-
};
|
|
8901
|
-
const useTrackingStore = defineStore("tracking", () => {
|
|
8902
|
-
const optionsStore = useOptionsStore();
|
|
8903
|
-
const trackSearch = ({
|
|
8904
|
-
queryKey,
|
|
8905
|
-
query,
|
|
8906
|
-
type = "search_query"
|
|
8907
|
-
}) => {
|
|
8908
|
-
var _a, _b;
|
|
8909
|
-
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
8910
|
-
const hasFilters = Object.keys((_b = query.filters) != null ? _b : {}).length > 0;
|
|
8911
|
-
if (hasFilters) {
|
|
8912
|
-
const data2 = getSearchTrackingData(query.searchText, "search_filters");
|
|
8913
|
-
track(queryKey, data2, options);
|
|
8914
|
-
return;
|
|
8915
|
-
}
|
|
8916
|
-
const data = getSearchTrackingData(query.searchText, type);
|
|
8917
|
-
track(queryKey, data, options);
|
|
8918
|
-
};
|
|
8919
|
-
const trackResults = ({
|
|
8920
|
-
queryKey,
|
|
8921
|
-
results
|
|
8922
|
-
}) => {
|
|
8923
|
-
var _a;
|
|
8924
|
-
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
8925
|
-
if (results.total > 0) {
|
|
8926
|
-
return;
|
|
8927
|
-
}
|
|
8928
|
-
const data = getSearchTrackingData(results.searchText, "search_zero_results");
|
|
8929
|
-
track(queryKey, data, options);
|
|
8930
|
-
};
|
|
8931
|
-
const trackEvent = ({ queryKey, data }) => {
|
|
8932
|
-
var _a, _b, _c, _d, _e;
|
|
8933
|
-
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
8934
|
-
const trackingOptions = (_b = optionsStore.trackingOptions) != null ? _b : {};
|
|
8935
|
-
const items = (_d = (_c = data.analytics) == null ? void 0 : _c.items) != null ? _d : [];
|
|
8936
|
-
const mappedItems = ((_e = trackingOptions.analytics) == null ? void 0 : _e.itemMap) ? items.map(trackingOptions.analytics.itemMap) : items;
|
|
8937
|
-
track(
|
|
8938
|
-
queryKey,
|
|
8939
|
-
__spreadProps2(__spreadValues2({}, data), {
|
|
8940
|
-
analytics: data.analytics ? __spreadProps2(__spreadValues2({}, data.analytics), { items: mappedItems }) : void 0
|
|
8941
|
-
}),
|
|
8942
|
-
options
|
|
8943
|
-
);
|
|
8944
|
-
};
|
|
8945
|
-
return { trackSearch, trackResults, trackEvent };
|
|
8946
|
-
});
|
|
8947
8904
|
const _hoisted_1$_ = ["href"];
|
|
8948
8905
|
const _hoisted_2$I = { class: "lupa-search-box-product-image-section" };
|
|
8949
8906
|
const _hoisted_3$x = { class: "lupa-search-box-product-details-section" };
|
|
@@ -8963,11 +8920,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
8963
8920
|
emits: ["product-click"],
|
|
8964
8921
|
setup(__props, { emit: emit2 }) {
|
|
8965
8922
|
const props = __props;
|
|
8966
|
-
const historyStore = useHistoryStore();
|
|
8967
|
-
const trackingStore = useTrackingStore();
|
|
8968
|
-
const optionsStore = useOptionsStore();
|
|
8969
8923
|
const isInStock = ref(true);
|
|
8970
|
-
const { boxRoutingBehavior } = storeToRefs(optionsStore);
|
|
8971
8924
|
const link = computed(() => {
|
|
8972
8925
|
var _a, _b;
|
|
8973
8926
|
return generateLink((_b = (_a = props.panelOptions.links) == null ? void 0 : _a.details) != null ? _b : "", props.item);
|
|
@@ -8982,54 +8935,16 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
8982
8935
|
(e) => e.type !== DocumentElementType.IMAGE && e.type !== DocumentElementType.ADDTOCART
|
|
8983
8936
|
)) != null ? _b : [];
|
|
8984
8937
|
});
|
|
8985
|
-
const id = computed(() => {
|
|
8986
|
-
if (props.panelOptions.idKey) {
|
|
8987
|
-
return props.item[props.panelOptions.idKey];
|
|
8988
|
-
}
|
|
8989
|
-
return "";
|
|
8990
|
-
});
|
|
8991
|
-
const title = computed(() => {
|
|
8992
|
-
if (!props.panelOptions.titleKey) {
|
|
8993
|
-
return "";
|
|
8994
|
-
}
|
|
8995
|
-
const title2 = props.item[props.panelOptions.titleKey] || "";
|
|
8996
|
-
historyStore.add({
|
|
8997
|
-
item: title2
|
|
8998
|
-
});
|
|
8999
|
-
return title2;
|
|
9000
|
-
});
|
|
9001
8938
|
const addToCartElement = computed(() => {
|
|
9002
8939
|
var _a;
|
|
9003
8940
|
return (_a = props.panelOptions.elements) == null ? void 0 : _a.find((e) => e.type === DocumentElementType.ADDTOCART);
|
|
9004
8941
|
});
|
|
9005
8942
|
const handleClick = (event) => {
|
|
9006
|
-
|
|
9007
|
-
|
|
9008
|
-
|
|
9009
|
-
|
|
9010
|
-
});
|
|
9011
|
-
}
|
|
9012
|
-
if (!props.panelOptions.idKey) {
|
|
9013
|
-
return;
|
|
9014
|
-
}
|
|
9015
|
-
trackingStore.trackEvent({
|
|
9016
|
-
queryKey: props.panelOptions.queryKey,
|
|
9017
|
-
data: {
|
|
9018
|
-
itemId: id.value,
|
|
9019
|
-
searchQuery: props.inputValue,
|
|
9020
|
-
type: "itemClick",
|
|
9021
|
-
analytics: {
|
|
9022
|
-
type: "autocomplete_product_click",
|
|
9023
|
-
label: (_a = title.value) != null ? _a : link.value,
|
|
9024
|
-
items: [props.item]
|
|
9025
|
-
}
|
|
9026
|
-
}
|
|
8943
|
+
emit2("product-click", {
|
|
8944
|
+
item: props.item,
|
|
8945
|
+
eventType: "itemClick",
|
|
8946
|
+
event
|
|
9027
8947
|
});
|
|
9028
|
-
if (!link.value) {
|
|
9029
|
-
return;
|
|
9030
|
-
}
|
|
9031
|
-
emit2("product-click");
|
|
9032
|
-
handleRoutingEvent(link.value, event, boxRoutingBehavior.value === "event");
|
|
9033
8948
|
};
|
|
9034
8949
|
onMounted(() => {
|
|
9035
8950
|
checkIfIsInStock();
|
|
@@ -9082,6 +8997,61 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9082
8997
|
};
|
|
9083
8998
|
}
|
|
9084
8999
|
});
|
|
9000
|
+
const getSearchTrackingData = (searchText, type) => {
|
|
9001
|
+
return {
|
|
9002
|
+
searchQuery: searchText,
|
|
9003
|
+
analytics: {
|
|
9004
|
+
type,
|
|
9005
|
+
label: searchText
|
|
9006
|
+
}
|
|
9007
|
+
};
|
|
9008
|
+
};
|
|
9009
|
+
const useTrackingStore = defineStore("tracking", () => {
|
|
9010
|
+
const optionsStore = useOptionsStore();
|
|
9011
|
+
const trackSearch = ({
|
|
9012
|
+
queryKey,
|
|
9013
|
+
query,
|
|
9014
|
+
type = "search_query"
|
|
9015
|
+
}) => {
|
|
9016
|
+
var _a, _b;
|
|
9017
|
+
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
9018
|
+
const hasFilters = Object.keys((_b = query.filters) != null ? _b : {}).length > 0;
|
|
9019
|
+
if (hasFilters) {
|
|
9020
|
+
const data2 = getSearchTrackingData(query.searchText, "search_filters");
|
|
9021
|
+
track(queryKey, data2, options);
|
|
9022
|
+
return;
|
|
9023
|
+
}
|
|
9024
|
+
const data = getSearchTrackingData(query.searchText, type);
|
|
9025
|
+
track(queryKey, data, options);
|
|
9026
|
+
};
|
|
9027
|
+
const trackResults = ({
|
|
9028
|
+
queryKey,
|
|
9029
|
+
results
|
|
9030
|
+
}) => {
|
|
9031
|
+
var _a;
|
|
9032
|
+
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
9033
|
+
if (results.total > 0) {
|
|
9034
|
+
return;
|
|
9035
|
+
}
|
|
9036
|
+
const data = getSearchTrackingData(results.searchText, "search_zero_results");
|
|
9037
|
+
track(queryKey, data, options);
|
|
9038
|
+
};
|
|
9039
|
+
const trackEvent = ({ queryKey, data }) => {
|
|
9040
|
+
var _a, _b, _c, _d, _e;
|
|
9041
|
+
const options = (_a = optionsStore.envOptions) != null ? _a : { environment: "production" };
|
|
9042
|
+
const trackingOptions = (_b = optionsStore.trackingOptions) != null ? _b : {};
|
|
9043
|
+
const items = (_d = (_c = data.analytics) == null ? void 0 : _c.items) != null ? _d : [];
|
|
9044
|
+
const mappedItems = ((_e = trackingOptions.analytics) == null ? void 0 : _e.itemMap) ? items.map(trackingOptions.analytics.itemMap) : items;
|
|
9045
|
+
track(
|
|
9046
|
+
queryKey,
|
|
9047
|
+
__spreadProps2(__spreadValues2({}, data), {
|
|
9048
|
+
analytics: data.analytics ? __spreadProps2(__spreadValues2({}, data.analytics), { items: mappedItems }) : void 0
|
|
9049
|
+
}),
|
|
9050
|
+
options
|
|
9051
|
+
);
|
|
9052
|
+
};
|
|
9053
|
+
return { trackSearch, trackResults, trackEvent };
|
|
9054
|
+
});
|
|
9085
9055
|
const _hoisted_1$Z = { id: "lupa-search-box-products" };
|
|
9086
9056
|
const _sfc_main$11 = /* @__PURE__ */ defineComponent({
|
|
9087
9057
|
__name: "SearchBoxProducts",
|
|
@@ -9091,9 +9061,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9091
9061
|
panelOptions: {},
|
|
9092
9062
|
labels: {}
|
|
9093
9063
|
},
|
|
9094
|
-
|
|
9064
|
+
emits: ["product-click"],
|
|
9065
|
+
setup(__props, { emit: emit2 }) {
|
|
9095
9066
|
const props = __props;
|
|
9096
9067
|
const searchBoxStore = useSearchBoxStore();
|
|
9068
|
+
const historyStore = useHistoryStore();
|
|
9069
|
+
const trackingStore = useTrackingStore();
|
|
9070
|
+
const optionsStore = useOptionsStore();
|
|
9071
|
+
const { boxRoutingBehavior } = storeToRefs(optionsStore);
|
|
9097
9072
|
const { highlightedItem } = storeToRefs(searchBoxStore);
|
|
9098
9073
|
const highlightedIndex = computed(() => {
|
|
9099
9074
|
var _a, _b, _c;
|
|
@@ -9102,6 +9077,42 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9102
9077
|
}
|
|
9103
9078
|
return (_c = (_b = highlightedItem.value) == null ? void 0 : _b.index) != null ? _c : -1;
|
|
9104
9079
|
});
|
|
9080
|
+
const handleProductClick = ({
|
|
9081
|
+
item,
|
|
9082
|
+
eventType,
|
|
9083
|
+
event
|
|
9084
|
+
}) => {
|
|
9085
|
+
var _a, _b;
|
|
9086
|
+
const link = generateLink((_b = (_a = props.panelOptions.links) == null ? void 0 : _a.details) != null ? _b : "", item);
|
|
9087
|
+
const title = props.panelOptions.titleKey ? item[props.panelOptions.titleKey] || "" : "";
|
|
9088
|
+
const id = props.panelOptions.idKey ? item[props.panelOptions.idKey] : "";
|
|
9089
|
+
if (props.panelOptions.titleKey) {
|
|
9090
|
+
historyStore.add({
|
|
9091
|
+
item: item[props.panelOptions.titleKey] || ""
|
|
9092
|
+
});
|
|
9093
|
+
}
|
|
9094
|
+
if (!props.panelOptions.idKey) {
|
|
9095
|
+
return;
|
|
9096
|
+
}
|
|
9097
|
+
trackingStore.trackEvent({
|
|
9098
|
+
queryKey: props.panelOptions.queryKey,
|
|
9099
|
+
data: {
|
|
9100
|
+
itemId: id,
|
|
9101
|
+
searchQuery: props.inputValue,
|
|
9102
|
+
type: eventType || "itemClick",
|
|
9103
|
+
analytics: {
|
|
9104
|
+
type: "autocomplete_product_click",
|
|
9105
|
+
label: title != null ? title : link,
|
|
9106
|
+
items: [item]
|
|
9107
|
+
}
|
|
9108
|
+
}
|
|
9109
|
+
});
|
|
9110
|
+
if (!link) {
|
|
9111
|
+
return;
|
|
9112
|
+
}
|
|
9113
|
+
emit2("product-click");
|
|
9114
|
+
handleRoutingEvent(link, event, boxRoutingBehavior.value === "event");
|
|
9115
|
+
};
|
|
9105
9116
|
return (_ctx, _cache) => {
|
|
9106
9117
|
return openBlock(), createElementBlock("div", _hoisted_1$Z, [
|
|
9107
9118
|
_ctx.$slots.productCard ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(_ctx.items, (item, index) => {
|
|
@@ -9112,7 +9123,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9112
9123
|
labels: _ctx.labels,
|
|
9113
9124
|
highlighted: index === highlightedIndex.value,
|
|
9114
9125
|
inputValue: _ctx.inputValue,
|
|
9115
|
-
|
|
9126
|
+
itemClicked: handleProductClick
|
|
9116
9127
|
});
|
|
9117
9128
|
}), 128)) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(_ctx.items, (item, index) => {
|
|
9118
9129
|
return openBlock(), createBlock(_sfc_main$12, {
|
|
@@ -9122,7 +9133,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
9122
9133
|
labels: _ctx.labels,
|
|
9123
9134
|
highlighted: index === highlightedIndex.value,
|
|
9124
9135
|
inputValue: _ctx.inputValue,
|
|
9125
|
-
onProductClick:
|
|
9136
|
+
onProductClick: handleProductClick
|
|
9126
9137
|
}, null, 8, ["item", "panelOptions", "labels", "highlighted", "inputValue"]);
|
|
9127
9138
|
}), 128))
|
|
9128
9139
|
]);
|
|
@@ -12458,6 +12469,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
12458
12469
|
if (!value) {
|
|
12459
12470
|
return;
|
|
12460
12471
|
}
|
|
12472
|
+
paramStore.setSortSettings({ selectedSortKey: value, previousSortKey: previousKey.value });
|
|
12461
12473
|
(_c = (_b = props.callbacks) == null ? void 0 : _b.onSortChange) == null ? void 0 : _c.call(_b, { selectedSortKey: value, previousSortKey: previousKey.value });
|
|
12462
12474
|
paramStore.appendParams({
|
|
12463
12475
|
params: [{ name: QUERY_PARAMS$1.SORT, value }],
|
|
@@ -14164,7 +14176,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
14164
14176
|
return (_a = props.initialFilters) != null ? _a : {};
|
|
14165
14177
|
});
|
|
14166
14178
|
const { currentQueryText, hasResults, currentFilterCount } = storeToRefs(searchResultStore);
|
|
14167
|
-
const { searchString } = storeToRefs(paramStore);
|
|
14179
|
+
const { searchString, sortParams } = storeToRefs(paramStore);
|
|
14168
14180
|
const { defaultSearchResultPageSize } = storeToRefs(optionStore);
|
|
14169
14181
|
const searchResultsFilters = ref(null);
|
|
14170
14182
|
const mounted = ref(false);
|
|
@@ -14201,6 +14213,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
14201
14213
|
window.removeEventListener("popstate", handlePopState);
|
|
14202
14214
|
});
|
|
14203
14215
|
const trackItemListView = (title, items = []) => {
|
|
14216
|
+
var _a, _b;
|
|
14204
14217
|
trackingStore.trackEvent({
|
|
14205
14218
|
queryKey: props.options.queryKey,
|
|
14206
14219
|
data: {
|
|
@@ -14208,7 +14221,11 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
14208
14221
|
type: "view_item_list",
|
|
14209
14222
|
label: title,
|
|
14210
14223
|
listLabel: title,
|
|
14211
|
-
items
|
|
14224
|
+
items,
|
|
14225
|
+
additionalParams: {
|
|
14226
|
+
previousSortKey: (_a = sortParams.value) == null ? void 0 : _a.previousSortKey,
|
|
14227
|
+
newSortKey: (_b = sortParams.value) == null ? void 0 : _b.selectedSortKey
|
|
14228
|
+
}
|
|
14212
14229
|
},
|
|
14213
14230
|
options: { allowEmptySearchQuery: true }
|
|
14214
14231
|
}
|