@getlupa/vue 0.7.6 → 0.7.8
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 +19 -7
- package/dist/lupaSearch.mjs +19 -7
- package/dist/src/stores/searchBox.d.ts +6 -0
- package/package.json +2 -2
package/dist/lupaSearch.js
CHANGED
|
@@ -1629,11 +1629,15 @@ const suggest = (queryKey, query, environment, customBaseUrl) => __awaiter(void
|
|
|
1629
1629
|
return { success: false, errors };
|
|
1630
1630
|
});
|
|
1631
1631
|
const track$1 = (queryKey, event, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1632
|
-
|
|
1633
|
-
|
|
1632
|
+
try {
|
|
1633
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}events`, Object.assign(Object.assign({}, defaultConfig$1), { body: JSON.stringify(Object.assign({ queryKey }, event)) }));
|
|
1634
|
+
if (res.status < 400) {
|
|
1635
|
+
return { success: false };
|
|
1636
|
+
}
|
|
1637
|
+
return res.json();
|
|
1638
|
+
} catch (e) {
|
|
1634
1639
|
return { success: false };
|
|
1635
1640
|
}
|
|
1636
|
-
return res.json();
|
|
1637
1641
|
});
|
|
1638
1642
|
const loadRedirectionRules = (queryKey, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1639
1643
|
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}redirections/${queryKey}`, Object.assign(Object.assign({}, defaultConfig$1), { method: "GET" }));
|
|
@@ -2993,6 +2997,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
|
|
|
2993
2997
|
const suggestionResults = vue.ref({});
|
|
2994
2998
|
const highlightedIndex = vue.ref(-1);
|
|
2995
2999
|
const inputValue = vue.ref("");
|
|
3000
|
+
const resultInputValue = vue.ref("");
|
|
2996
3001
|
const historyStore = useHistoryStore();
|
|
2997
3002
|
const resultsVisible = vue.computed(() => {
|
|
2998
3003
|
var _a;
|
|
@@ -3005,13 +3010,15 @@ const useSearchBoxStore = defineStore("searchBox", () => {
|
|
|
3005
3010
|
return {
|
|
3006
3011
|
queryKey: p2.queryKey,
|
|
3007
3012
|
count: (_b = (_a = suggestionResults.value[p2.queryKey]) == null ? void 0 : _a.length) != null ? _b : 0,
|
|
3008
|
-
panel: p2
|
|
3013
|
+
panel: p2,
|
|
3014
|
+
input: resultInputValue.value
|
|
3009
3015
|
};
|
|
3010
3016
|
}
|
|
3011
3017
|
return {
|
|
3012
3018
|
queryKey: p2.queryKey,
|
|
3013
3019
|
count: (_e = (_d = (_c = docResults.value[p2.queryKey]) == null ? void 0 : _c.items) == null ? void 0 : _d.length) != null ? _e : 0,
|
|
3014
|
-
panel: p2
|
|
3020
|
+
panel: p2,
|
|
3021
|
+
input: resultInputValue.value
|
|
3015
3022
|
};
|
|
3016
3023
|
})
|
|
3017
3024
|
);
|
|
@@ -3071,6 +3078,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
|
|
|
3071
3078
|
[queryKey]: flattenSuggestions(result.items, (_a = publicQuery.searchText) != null ? _a : "")
|
|
3072
3079
|
});
|
|
3073
3080
|
inputValue.value = publicQuery.searchText;
|
|
3081
|
+
resultInputValue.value = publicQuery.searchText;
|
|
3074
3082
|
emitSearchResultsCallback();
|
|
3075
3083
|
return {
|
|
3076
3084
|
suggestions: result.items
|
|
@@ -4463,7 +4471,7 @@ const _sfc_main$11 = /* @__PURE__ */ vue.defineComponent({
|
|
|
4463
4471
|
}
|
|
4464
4472
|
}
|
|
4465
4473
|
});
|
|
4466
|
-
if (!link) {
|
|
4474
|
+
if (!link || eventType === "addToCart") {
|
|
4467
4475
|
return;
|
|
4468
4476
|
}
|
|
4469
4477
|
emit("product-click");
|
|
@@ -4697,6 +4705,10 @@ const _sfc_main$$ = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
4697
4705
|
const expandOnSinglePanel = vue.computed(() => {
|
|
4698
4706
|
return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
|
|
4699
4707
|
});
|
|
4708
|
+
const showTopResultsPanelTitle = (queryKey) => {
|
|
4709
|
+
const panel = panelItemCounts.value.find((v) => v.queryKey === queryKey);
|
|
4710
|
+
return (panel == null ? void 0 : panel.count) > 0 && (panel == null ? void 0 : panel.input.length) < 1;
|
|
4711
|
+
};
|
|
4700
4712
|
return (_ctx, _cache) => {
|
|
4701
4713
|
var _a;
|
|
4702
4714
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -4719,7 +4731,7 @@ const _sfc_main$$ = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
4719
4731
|
]),
|
|
4720
4732
|
"data-cy": "lupa-panel-" + panel.type + "-index"
|
|
4721
4733
|
}, [
|
|
4722
|
-
|
|
4734
|
+
((_a2 = panel.labels) == null ? void 0 : _a2.topResultsTitle) && showTopResultsPanelTitle(panel.queryKey) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$w, vue.toDisplayString((_b = panel.labels) == null ? void 0 : _b.topResultsTitle), 1)) : vue.createCommentVNode("", true),
|
|
4723
4735
|
panel.queryKey ? (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(getComponent(panel.type)), {
|
|
4724
4736
|
key: 1,
|
|
4725
4737
|
panel,
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -1627,11 +1627,15 @@ const suggest = (queryKey, query, environment, customBaseUrl) => __awaiter(void
|
|
|
1627
1627
|
return { success: false, errors };
|
|
1628
1628
|
});
|
|
1629
1629
|
const track$1 = (queryKey, event, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1630
|
-
|
|
1631
|
-
|
|
1630
|
+
try {
|
|
1631
|
+
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}events`, Object.assign(Object.assign({}, defaultConfig$1), { body: JSON.stringify(Object.assign({ queryKey }, event)) }));
|
|
1632
|
+
if (res.status < 400) {
|
|
1633
|
+
return { success: false };
|
|
1634
|
+
}
|
|
1635
|
+
return res.json();
|
|
1636
|
+
} catch (e) {
|
|
1632
1637
|
return { success: false };
|
|
1633
1638
|
}
|
|
1634
|
-
return res.json();
|
|
1635
1639
|
});
|
|
1636
1640
|
const loadRedirectionRules = (queryKey, environment, customBaseUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1637
1641
|
const res = yield fetch(`${getApiUrl$1(environment, customBaseUrl)}redirections/${queryKey}`, Object.assign(Object.assign({}, defaultConfig$1), { method: "GET" }));
|
|
@@ -2991,6 +2995,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
|
|
|
2991
2995
|
const suggestionResults = ref({});
|
|
2992
2996
|
const highlightedIndex = ref(-1);
|
|
2993
2997
|
const inputValue = ref("");
|
|
2998
|
+
const resultInputValue = ref("");
|
|
2994
2999
|
const historyStore = useHistoryStore();
|
|
2995
3000
|
const resultsVisible = computed(() => {
|
|
2996
3001
|
var _a;
|
|
@@ -3003,13 +3008,15 @@ const useSearchBoxStore = defineStore("searchBox", () => {
|
|
|
3003
3008
|
return {
|
|
3004
3009
|
queryKey: p2.queryKey,
|
|
3005
3010
|
count: (_b = (_a = suggestionResults.value[p2.queryKey]) == null ? void 0 : _a.length) != null ? _b : 0,
|
|
3006
|
-
panel: p2
|
|
3011
|
+
panel: p2,
|
|
3012
|
+
input: resultInputValue.value
|
|
3007
3013
|
};
|
|
3008
3014
|
}
|
|
3009
3015
|
return {
|
|
3010
3016
|
queryKey: p2.queryKey,
|
|
3011
3017
|
count: (_e = (_d = (_c = docResults.value[p2.queryKey]) == null ? void 0 : _c.items) == null ? void 0 : _d.length) != null ? _e : 0,
|
|
3012
|
-
panel: p2
|
|
3018
|
+
panel: p2,
|
|
3019
|
+
input: resultInputValue.value
|
|
3013
3020
|
};
|
|
3014
3021
|
})
|
|
3015
3022
|
);
|
|
@@ -3069,6 +3076,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
|
|
|
3069
3076
|
[queryKey]: flattenSuggestions(result.items, (_a = publicQuery.searchText) != null ? _a : "")
|
|
3070
3077
|
});
|
|
3071
3078
|
inputValue.value = publicQuery.searchText;
|
|
3079
|
+
resultInputValue.value = publicQuery.searchText;
|
|
3072
3080
|
emitSearchResultsCallback();
|
|
3073
3081
|
return {
|
|
3074
3082
|
suggestions: result.items
|
|
@@ -4461,7 +4469,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
|
|
|
4461
4469
|
}
|
|
4462
4470
|
}
|
|
4463
4471
|
});
|
|
4464
|
-
if (!link) {
|
|
4472
|
+
if (!link || eventType === "addToCart") {
|
|
4465
4473
|
return;
|
|
4466
4474
|
}
|
|
4467
4475
|
emit("product-click");
|
|
@@ -4695,6 +4703,10 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
4695
4703
|
const expandOnSinglePanel = computed(() => {
|
|
4696
4704
|
return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
|
|
4697
4705
|
});
|
|
4706
|
+
const showTopResultsPanelTitle = (queryKey) => {
|
|
4707
|
+
const panel = panelItemCounts.value.find((v) => v.queryKey === queryKey);
|
|
4708
|
+
return (panel == null ? void 0 : panel.count) > 0 && (panel == null ? void 0 : panel.input.length) < 1;
|
|
4709
|
+
};
|
|
4698
4710
|
return (_ctx, _cache) => {
|
|
4699
4711
|
var _a;
|
|
4700
4712
|
return openBlock(), createElementBlock("div", {
|
|
@@ -4717,7 +4729,7 @@ const _sfc_main$$ = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
4717
4729
|
]),
|
|
4718
4730
|
"data-cy": "lupa-panel-" + panel.type + "-index"
|
|
4719
4731
|
}, [
|
|
4720
|
-
|
|
4732
|
+
((_a2 = panel.labels) == null ? void 0 : _a2.topResultsTitle) && showTopResultsPanelTitle(panel.queryKey) ? (openBlock(), createElementBlock("div", _hoisted_3$w, toDisplayString((_b = panel.labels) == null ? void 0 : _b.topResultsTitle), 1)) : createCommentVNode("", true),
|
|
4721
4733
|
panel.queryKey ? (openBlock(), createBlock(resolveDynamicComponent(getComponent(panel.type)), {
|
|
4722
4734
|
key: 1,
|
|
4723
4735
|
panel,
|
|
@@ -14,10 +14,12 @@ export declare const useSearchBoxStore: import("pinia").StoreDefinition<"searchB
|
|
|
14
14
|
queryKey: string;
|
|
15
15
|
count: number;
|
|
16
16
|
panel: import('../types/search-box/SearchBoxPanel').SuggestionSearchBoxPanel;
|
|
17
|
+
input: string;
|
|
17
18
|
} | {
|
|
18
19
|
queryKey: string;
|
|
19
20
|
count: number;
|
|
20
21
|
panel: import('../types/search-box/SearchBoxPanel').DocumentSearchBoxPanel;
|
|
22
|
+
input: string;
|
|
21
23
|
})[]>;
|
|
22
24
|
totalCount: import("vue").ComputedRef<number>;
|
|
23
25
|
highlightedItem: import("vue").ComputedRef<{
|
|
@@ -82,10 +84,12 @@ export declare const useSearchBoxStore: import("pinia").StoreDefinition<"searchB
|
|
|
82
84
|
queryKey: string;
|
|
83
85
|
count: number;
|
|
84
86
|
panel: import('../types/search-box/SearchBoxPanel').SuggestionSearchBoxPanel;
|
|
87
|
+
input: string;
|
|
85
88
|
} | {
|
|
86
89
|
queryKey: string;
|
|
87
90
|
count: number;
|
|
88
91
|
panel: import('../types/search-box/SearchBoxPanel').DocumentSearchBoxPanel;
|
|
92
|
+
input: string;
|
|
89
93
|
})[]>;
|
|
90
94
|
totalCount: import("vue").ComputedRef<number>;
|
|
91
95
|
highlightedItem: import("vue").ComputedRef<{
|
|
@@ -150,10 +154,12 @@ export declare const useSearchBoxStore: import("pinia").StoreDefinition<"searchB
|
|
|
150
154
|
queryKey: string;
|
|
151
155
|
count: number;
|
|
152
156
|
panel: import('../types/search-box/SearchBoxPanel').SuggestionSearchBoxPanel;
|
|
157
|
+
input: string;
|
|
153
158
|
} | {
|
|
154
159
|
queryKey: string;
|
|
155
160
|
count: number;
|
|
156
161
|
panel: import('../types/search-box/SearchBoxPanel').DocumentSearchBoxPanel;
|
|
162
|
+
input: string;
|
|
157
163
|
})[]>;
|
|
158
164
|
totalCount: import("vue").ComputedRef<number>;
|
|
159
165
|
highlightedItem: import("vue").ComputedRef<{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getlupa/vue",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.8",
|
|
4
4
|
"main": "dist/lupaSearch.mjs",
|
|
5
5
|
"module": "dist/lupaSearch.mjs",
|
|
6
6
|
"types": "dist/src/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"vue": "^3.0.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@getlupa/client-sdk": "^1.4.
|
|
26
|
+
"@getlupa/client-sdk": "^1.4.1",
|
|
27
27
|
"@pinia/testing": "^0.1.2",
|
|
28
28
|
"@rollup/plugin-babel": "5.3.0",
|
|
29
29
|
"@rollup/plugin-commonjs": "^21.0.1",
|