@getlupa/vue 0.5.0 → 0.5.2
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
|
@@ -3035,7 +3035,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
|
|
|
3035
3035
|
const _hoisted_1$1b = { id: "lupa-search-box-input-container" };
|
|
3036
3036
|
const _hoisted_2$O = { class: "lupa-input-clear" };
|
|
3037
3037
|
const _hoisted_3$A = { id: "lupa-search-box-input" };
|
|
3038
|
-
const _hoisted_4$
|
|
3038
|
+
const _hoisted_4$q = ["value"];
|
|
3039
3039
|
const _hoisted_5$f = ["placeholder"];
|
|
3040
3040
|
const _hoisted_6$8 = {
|
|
3041
3041
|
key: 0,
|
|
@@ -3130,7 +3130,7 @@ const _sfc_main$1j = /* @__PURE__ */ vue.defineComponent({
|
|
|
3130
3130
|
class: "lupa-hint",
|
|
3131
3131
|
value: showHint.value ? suggestedValue.value.item.suggestion : "",
|
|
3132
3132
|
disabled: ""
|
|
3133
|
-
}, null, 8, _hoisted_4$
|
|
3133
|
+
}, null, 8, _hoisted_4$q),
|
|
3134
3134
|
vue.withDirectives(vue.createElementVNode("input", vue.mergeProps({
|
|
3135
3135
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
|
|
3136
3136
|
}, inputAttributes.value, {
|
|
@@ -3309,7 +3309,7 @@ const _hoisted_3$z = {
|
|
|
3309
3309
|
class: "lupa-suggestion-facet",
|
|
3310
3310
|
"data-cy": "lupa-suggestion-facet"
|
|
3311
3311
|
};
|
|
3312
|
-
const _hoisted_4$
|
|
3312
|
+
const _hoisted_4$p = {
|
|
3313
3313
|
class: "lupa-suggestion-facet-label",
|
|
3314
3314
|
"data-cy": "lupa-suggestion-facet-label"
|
|
3315
3315
|
};
|
|
@@ -3355,7 +3355,7 @@ const _sfc_main$1e = /* @__PURE__ */ vue.defineComponent({
|
|
|
3355
3355
|
innerHTML: _ctx.suggestion.displayHighlight
|
|
3356
3356
|
}, null, 8, _hoisted_1$17)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$M, vue.toDisplayString(_ctx.suggestion.display), 1)),
|
|
3357
3357
|
_ctx.suggestion.facet ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$z, [
|
|
3358
|
-
vue.createElementVNode("span", _hoisted_4$
|
|
3358
|
+
vue.createElementVNode("span", _hoisted_4$p, vue.toDisplayString(facetLabel.value), 1),
|
|
3359
3359
|
vue.createElementVNode("span", _hoisted_5$e, vue.toDisplayString(_ctx.suggestion.facet.title), 1)
|
|
3360
3360
|
])) : vue.createCommentVNode("", true)
|
|
3361
3361
|
]);
|
|
@@ -3757,7 +3757,7 @@ const _sfc_main$16 = /* @__PURE__ */ vue.defineComponent({
|
|
|
3757
3757
|
const _hoisted_1$10 = ["innerHTML"];
|
|
3758
3758
|
const _hoisted_2$J = { key: 0 };
|
|
3759
3759
|
const _hoisted_3$y = { key: 1 };
|
|
3760
|
-
const _hoisted_4$
|
|
3760
|
+
const _hoisted_4$o = { class: "lupa-search-box-custom-label" };
|
|
3761
3761
|
const _hoisted_5$d = { class: "lupa-search-box-custom-text" };
|
|
3762
3762
|
const _sfc_main$15 = /* @__PURE__ */ vue.defineComponent({
|
|
3763
3763
|
__name: "SearchBoxProductCustom",
|
|
@@ -3790,7 +3790,7 @@ const _sfc_main$15 = /* @__PURE__ */ vue.defineComponent({
|
|
|
3790
3790
|
class: [className.value, "lupa-search-box-product-custom"]
|
|
3791
3791
|
}, vue.toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
|
|
3792
3792
|
!label.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_2$J, vue.toDisplayString(text.value), 1)) : (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$y, [
|
|
3793
|
-
vue.createElementVNode("div", _hoisted_4$
|
|
3793
|
+
vue.createElementVNode("div", _hoisted_4$o, vue.toDisplayString(label.value), 1),
|
|
3794
3794
|
vue.createElementVNode("div", _hoisted_5$d, vue.toDisplayString(text.value), 1)
|
|
3795
3795
|
]))
|
|
3796
3796
|
], 16));
|
|
@@ -4186,7 +4186,7 @@ const useTrackingStore = defineStore("tracking", () => {
|
|
|
4186
4186
|
const _hoisted_1$Z = ["href"];
|
|
4187
4187
|
const _hoisted_2$H = { class: "lupa-search-box-product-image-section" };
|
|
4188
4188
|
const _hoisted_3$w = { class: "lupa-search-box-product-details-section" };
|
|
4189
|
-
const _hoisted_4$
|
|
4189
|
+
const _hoisted_4$n = {
|
|
4190
4190
|
key: 0,
|
|
4191
4191
|
class: "lupa-search-box-product-add-to-cart-section"
|
|
4192
4192
|
};
|
|
@@ -4307,7 +4307,7 @@ const _sfc_main$11 = /* @__PURE__ */ vue.defineComponent({
|
|
|
4307
4307
|
}, null, 8, ["item", "element", "labels", "link"]);
|
|
4308
4308
|
}), 128))
|
|
4309
4309
|
]),
|
|
4310
|
-
addToCartElement.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$
|
|
4310
|
+
addToCartElement.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_4$n, [
|
|
4311
4311
|
vue.createVNode(_sfc_main$12, {
|
|
4312
4312
|
class: "lupa-search-box-product-element",
|
|
4313
4313
|
item: _ctx.item,
|
|
@@ -4442,12 +4442,8 @@ const _hoisted_1$X = {
|
|
|
4442
4442
|
key: 0,
|
|
4443
4443
|
id: "lupa-search-box-panel"
|
|
4444
4444
|
};
|
|
4445
|
-
const _hoisted_2$G =
|
|
4446
|
-
|
|
4447
|
-
"data-cy": "lupa-main-panel"
|
|
4448
|
-
};
|
|
4449
|
-
const _hoisted_3$v = ["data-cy"];
|
|
4450
|
-
const _hoisted_4$n = {
|
|
4445
|
+
const _hoisted_2$G = ["data-cy"];
|
|
4446
|
+
const _hoisted_3$v = {
|
|
4451
4447
|
key: 1,
|
|
4452
4448
|
id: "lupa-search-box-panel"
|
|
4453
4449
|
};
|
|
@@ -4484,7 +4480,7 @@ const _sfc_main$_ = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
4484
4480
|
const panels = vue.computed(() => props.options.panels);
|
|
4485
4481
|
const sdkOptions = vue.computed(() => props.options.options);
|
|
4486
4482
|
const searchBoxStore = useSearchBoxStore();
|
|
4487
|
-
const { suggestionResults, hasAnyResults } = storeToRefs(searchBoxStore);
|
|
4483
|
+
const { suggestionResults, hasAnyResults, panelItemCounts } = storeToRefs(searchBoxStore);
|
|
4488
4484
|
const displayResults = vue.computed(
|
|
4489
4485
|
() => {
|
|
4490
4486
|
var _a, _b;
|
|
@@ -4565,6 +4561,12 @@ const _sfc_main$_ = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
4565
4561
|
`${window.innerHeight - panel.getBoundingClientRect().y - 10}px`
|
|
4566
4562
|
);
|
|
4567
4563
|
};
|
|
4564
|
+
const numberOfVisiblePanels = vue.computed(() => {
|
|
4565
|
+
return panelItemCounts.value.filter((v) => v.count > 0).length;
|
|
4566
|
+
});
|
|
4567
|
+
const expandOnSinglePanel = vue.computed(() => {
|
|
4568
|
+
return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
|
|
4569
|
+
});
|
|
4568
4570
|
return (_ctx, _cache) => {
|
|
4569
4571
|
var _a;
|
|
4570
4572
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -4572,7 +4574,11 @@ const _sfc_main$_ = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
4572
4574
|
ref: panelContainer
|
|
4573
4575
|
}, [
|
|
4574
4576
|
displayResults.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$X, [
|
|
4575
|
-
vue.createElementVNode("div",
|
|
4577
|
+
vue.createElementVNode("div", {
|
|
4578
|
+
class: "lupa-main-panel",
|
|
4579
|
+
style: vue.normalizeStyle(expandOnSinglePanel.value ? { display: "block" } : {}),
|
|
4580
|
+
"data-cy": "lupa-main-panel"
|
|
4581
|
+
}, [
|
|
4576
4582
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(displayPanels.value, (panel, index) => {
|
|
4577
4583
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
4578
4584
|
key: index,
|
|
@@ -4601,9 +4607,9 @@ const _sfc_main$_ = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
4601
4607
|
key: "0"
|
|
4602
4608
|
} : void 0
|
|
4603
4609
|
]), 1064, ["panel", "options", "debounce", "inputValue", "labels"])) : vue.createCommentVNode("", true)
|
|
4604
|
-
], 10,
|
|
4610
|
+
], 10, _hoisted_2$G);
|
|
4605
4611
|
}), 128))
|
|
4606
|
-
]),
|
|
4612
|
+
], 4),
|
|
4607
4613
|
!vue.unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (vue.openBlock(), vue.createBlock(_sfc_main$1f, {
|
|
4608
4614
|
key: 0,
|
|
4609
4615
|
labels: labels.value
|
|
@@ -4614,7 +4620,7 @@ const _sfc_main$_ = /* @__PURE__ */ vue.defineComponent(__spreadProps(__spreadVa
|
|
|
4614
4620
|
showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
|
|
4615
4621
|
onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
|
|
4616
4622
|
}, null, 8, ["labels", "showTotalCount"])) : vue.createCommentVNode("", true)
|
|
4617
|
-
])) : displayHistory.value ? (vue.openBlock(), vue.createElementBlock("div",
|
|
4623
|
+
])) : displayHistory.value ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_3$v, [
|
|
4618
4624
|
vue.createVNode(_sfc_main$1g, {
|
|
4619
4625
|
options: _ctx.options.history,
|
|
4620
4626
|
history: history.value,
|
|
@@ -4683,7 +4689,8 @@ const _sfc_main$Z = /* @__PURE__ */ vue.defineComponent({
|
|
|
4683
4689
|
"debounce",
|
|
4684
4690
|
"showTotalCount",
|
|
4685
4691
|
"hideMoreResultsButtonOnNoResults",
|
|
4686
|
-
"showNoResultsPanel"
|
|
4692
|
+
"showNoResultsPanel",
|
|
4693
|
+
"expandOnSinglePanel"
|
|
4687
4694
|
])
|
|
4688
4695
|
);
|
|
4689
4696
|
const searchTriggers = vue.computed(() => {
|
|
@@ -9368,8 +9375,14 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
9368
9375
|
const isTitleResultTopPosition = vue.computed(() => {
|
|
9369
9376
|
return props.options.searchTitlePosition === "search-results-top";
|
|
9370
9377
|
});
|
|
9378
|
+
const handlePopState = () => {
|
|
9379
|
+
var _a;
|
|
9380
|
+
const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
|
|
9381
|
+
paramStore.add(parseParams(searchParams));
|
|
9382
|
+
};
|
|
9371
9383
|
vue.onMounted(() => {
|
|
9372
9384
|
var _a, _b;
|
|
9385
|
+
window.addEventListener("popstate", handlePopState);
|
|
9373
9386
|
window.addEventListener("resize", handleResize);
|
|
9374
9387
|
if (props.initialData) {
|
|
9375
9388
|
searchResultStore.add(__spreadValues({}, props.initialData));
|
|
@@ -9380,6 +9393,7 @@ const _sfc_main$c = /* @__PURE__ */ vue.defineComponent({
|
|
|
9380
9393
|
});
|
|
9381
9394
|
vue.onBeforeUnmount(() => {
|
|
9382
9395
|
window.removeEventListener("resize", handleResize);
|
|
9396
|
+
window.removeEventListener("popstate", handlePopState);
|
|
9383
9397
|
});
|
|
9384
9398
|
const trackItemListView = (title, items = []) => {
|
|
9385
9399
|
trackingStore.trackEvent({
|
|
@@ -16128,11 +16142,12 @@ const getApiUrl = (environment, customBaseUrl) => {
|
|
|
16128
16142
|
}
|
|
16129
16143
|
return Env[environment] || Env["production"];
|
|
16130
16144
|
};
|
|
16131
|
-
const suggestSearchChatPhrases = (options, request) => __async(exports, null, function* () {
|
|
16145
|
+
const suggestSearchChatPhrases = (options, request, chatSettings) => __async(exports, null, function* () {
|
|
16132
16146
|
var _a, _b, _c;
|
|
16133
16147
|
const { environment, customBaseUrl } = options;
|
|
16148
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16134
16149
|
try {
|
|
16135
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat
|
|
16150
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16136
16151
|
body: JSON.stringify(request),
|
|
16137
16152
|
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16138
16153
|
}));
|
|
@@ -16148,14 +16163,18 @@ const suggestSearchChatPhrases = (options, request) => __async(exports, null, fu
|
|
|
16148
16163
|
return { success: false, errors: [e] };
|
|
16149
16164
|
}
|
|
16150
16165
|
});
|
|
16151
|
-
const suggestPhraseAlternatives = (_0, _1) => __async(exports, [_0, _1], function* (options, { phrases }) {
|
|
16166
|
+
const suggestPhraseAlternatives = (_0, _1, _2) => __async(exports, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
|
|
16152
16167
|
var _a, _b, _c;
|
|
16153
16168
|
const { environment, customBaseUrl } = options;
|
|
16169
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16154
16170
|
try {
|
|
16155
|
-
const res = yield fetch(
|
|
16156
|
-
|
|
16157
|
-
|
|
16158
|
-
|
|
16171
|
+
const res = yield fetch(
|
|
16172
|
+
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
16173
|
+
__spreadProps(__spreadValues({}, defaultConfig), {
|
|
16174
|
+
body: JSON.stringify({ phrases }),
|
|
16175
|
+
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16176
|
+
})
|
|
16177
|
+
);
|
|
16159
16178
|
if (res.status < 400) {
|
|
16160
16179
|
const data = yield res.json();
|
|
16161
16180
|
return __spreadProps(__spreadValues({}, data), { success: true });
|
|
@@ -16168,11 +16187,12 @@ const suggestPhraseAlternatives = (_0, _1) => __async(exports, [_0, _1], functio
|
|
|
16168
16187
|
return { success: false, errors: [e] };
|
|
16169
16188
|
}
|
|
16170
16189
|
});
|
|
16171
|
-
const suggestSimplifiedPhrases = (_0, _1) => __async(exports, [_0, _1], function* (options, { phrases }) {
|
|
16190
|
+
const suggestSimplifiedPhrases = (_0, _1, _2) => __async(exports, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
|
|
16172
16191
|
var _a, _b, _c;
|
|
16173
16192
|
const { environment, customBaseUrl } = options;
|
|
16193
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16174
16194
|
try {
|
|
16175
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16195
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16176
16196
|
body: JSON.stringify({ phrases }),
|
|
16177
16197
|
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16178
16198
|
}));
|
|
@@ -16188,15 +16208,16 @@ const suggestSimplifiedPhrases = (_0, _1) => __async(exports, [_0, _1], function
|
|
|
16188
16208
|
return { success: false, errors: [e] };
|
|
16189
16209
|
}
|
|
16190
16210
|
});
|
|
16191
|
-
const suggestBestProductMatches = (_0, _1) => __async(exports, [_0, _1], function* (options, {
|
|
16211
|
+
const suggestBestProductMatches = (_0, _1, _2) => __async(exports, [_0, _1, _2], function* (options, {
|
|
16192
16212
|
initialQuery,
|
|
16193
16213
|
productStrings,
|
|
16194
16214
|
messageHistory
|
|
16195
|
-
}) {
|
|
16215
|
+
}, chatSettings) {
|
|
16196
16216
|
var _a, _b, _c;
|
|
16197
16217
|
const { environment, customBaseUrl } = options;
|
|
16218
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16198
16219
|
try {
|
|
16199
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16220
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16200
16221
|
body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
|
|
16201
16222
|
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16202
16223
|
}));
|
|
@@ -16233,9 +16254,10 @@ const prepareChatHistory = (chatLog) => {
|
|
|
16233
16254
|
}
|
|
16234
16255
|
return history;
|
|
16235
16256
|
};
|
|
16236
|
-
const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived) => {
|
|
16257
|
+
const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived, chatSettings) => {
|
|
16237
16258
|
var _a;
|
|
16238
|
-
|
|
16259
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16260
|
+
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16239
16261
|
body: JSON.stringify({ initialQuery, messageHistory }),
|
|
16240
16262
|
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16241
16263
|
})).then((response) => {
|
|
@@ -16375,9 +16397,13 @@ const _sfc_main$4 = /* @__PURE__ */ vue.defineComponent({
|
|
|
16375
16397
|
return result.items;
|
|
16376
16398
|
});
|
|
16377
16399
|
const getPhraseAlternatives = () => __async(this, null, function* () {
|
|
16378
|
-
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
16379
|
-
|
|
16380
|
-
|
|
16400
|
+
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
16401
|
+
props.options.sdkOptions,
|
|
16402
|
+
{
|
|
16403
|
+
phrases: [props.phrase]
|
|
16404
|
+
},
|
|
16405
|
+
props.options.chatSettings
|
|
16406
|
+
);
|
|
16381
16407
|
return phrases != null ? phrases : [];
|
|
16382
16408
|
});
|
|
16383
16409
|
return (_ctx, _cache) => {
|
|
@@ -16442,11 +16468,15 @@ const _sfc_main$3 = /* @__PURE__ */ vue.defineComponent({
|
|
|
16442
16468
|
return (_b = (_a2 = result[titleKey.value]) == null ? void 0 : _a2.toString()) != null ? _b : "";
|
|
16443
16469
|
}
|
|
16444
16470
|
);
|
|
16445
|
-
const { products } = yield ChatService.suggestBestProductMatches(
|
|
16446
|
-
|
|
16447
|
-
|
|
16448
|
-
|
|
16449
|
-
|
|
16471
|
+
const { products } = yield ChatService.suggestBestProductMatches(
|
|
16472
|
+
props.options.sdkOptions,
|
|
16473
|
+
{
|
|
16474
|
+
initialQuery: props.entry.userInput,
|
|
16475
|
+
productStrings: productResultStrings,
|
|
16476
|
+
messageHistory: (_a = props.history) != null ? _a : []
|
|
16477
|
+
},
|
|
16478
|
+
props.options.chatSettings
|
|
16479
|
+
);
|
|
16450
16480
|
bestMatches.value = products;
|
|
16451
16481
|
emit("loaded", products);
|
|
16452
16482
|
} finally {
|
|
@@ -16519,7 +16549,8 @@ const _sfc_main$2 = /* @__PURE__ */ vue.defineComponent({
|
|
|
16519
16549
|
initialQuery: props.content,
|
|
16520
16550
|
messageHistory: (_a = props.history) != null ? _a : []
|
|
16521
16551
|
},
|
|
16522
|
-
processChunk
|
|
16552
|
+
processChunk,
|
|
16553
|
+
props.options.chatSettings
|
|
16523
16554
|
);
|
|
16524
16555
|
});
|
|
16525
16556
|
return (_ctx, _cache) => {
|
|
@@ -16616,7 +16647,8 @@ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
|
|
|
16616
16647
|
};
|
|
16617
16648
|
const { phrases, success } = yield ChatService.suggestSearchChatPhrases(
|
|
16618
16649
|
props.options.sdkOptions,
|
|
16619
|
-
request
|
|
16650
|
+
request,
|
|
16651
|
+
props.options.chatSettings
|
|
16620
16652
|
);
|
|
16621
16653
|
if (!success || !phrases.length) {
|
|
16622
16654
|
error.value = "Something went wrong";
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -37,7 +37,7 @@ var __async = (__this, __arguments, generator) => {
|
|
|
37
37
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
38
38
|
});
|
|
39
39
|
};
|
|
40
|
-
import { toRaw, isRef, isReactive, toRef, effectScope, ref, markRaw, hasInjectionContext, inject, getCurrentInstance, watch, reactive, nextTick, computed, unref, getCurrentScope, onScopeDispose, toRefs, defineComponent, openBlock, createElementBlock, createElementVNode, normalizeClass, withDirectives, mergeProps, vModelText, toDisplayString, createCommentVNode, onMounted, onBeforeMount, Fragment, renderList, createBlock, toHandlers, withModifiers, resolveDynamicComponent, createVNode, renderSlot, createSlots, withCtx, normalizeProps, guardReactiveProps, onBeforeUnmount, createTextVNode, onUnmounted, resolveComponent, vModelSelect,
|
|
40
|
+
import { toRaw, isRef, isReactive, toRef, effectScope, ref, markRaw, hasInjectionContext, inject, getCurrentInstance, watch, reactive, nextTick, computed, unref, getCurrentScope, onScopeDispose, toRefs, defineComponent, openBlock, createElementBlock, createElementVNode, normalizeClass, withDirectives, mergeProps, vModelText, toDisplayString, createCommentVNode, onMounted, onBeforeMount, Fragment, renderList, createBlock, toHandlers, withModifiers, resolveDynamicComponent, createVNode, renderSlot, createSlots, withCtx, normalizeProps, guardReactiveProps, onBeforeUnmount, normalizeStyle, createTextVNode, onUnmounted, resolveComponent, vModelSelect, h as h$1, provide, cloneVNode } from "vue";
|
|
41
41
|
var isVue2 = false;
|
|
42
42
|
function set(target, key, val) {
|
|
43
43
|
if (Array.isArray(target)) {
|
|
@@ -3033,7 +3033,7 @@ const useSearchBoxStore = defineStore("searchBox", () => {
|
|
|
3033
3033
|
const _hoisted_1$1b = { id: "lupa-search-box-input-container" };
|
|
3034
3034
|
const _hoisted_2$O = { class: "lupa-input-clear" };
|
|
3035
3035
|
const _hoisted_3$A = { id: "lupa-search-box-input" };
|
|
3036
|
-
const _hoisted_4$
|
|
3036
|
+
const _hoisted_4$q = ["value"];
|
|
3037
3037
|
const _hoisted_5$f = ["placeholder"];
|
|
3038
3038
|
const _hoisted_6$8 = {
|
|
3039
3039
|
key: 0,
|
|
@@ -3128,7 +3128,7 @@ const _sfc_main$1j = /* @__PURE__ */ defineComponent({
|
|
|
3128
3128
|
class: "lupa-hint",
|
|
3129
3129
|
value: showHint.value ? suggestedValue.value.item.suggestion : "",
|
|
3130
3130
|
disabled: ""
|
|
3131
|
-
}, null, 8, _hoisted_4$
|
|
3131
|
+
}, null, 8, _hoisted_4$q),
|
|
3132
3132
|
withDirectives(createElementVNode("input", mergeProps({
|
|
3133
3133
|
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => inputValue.value = $event)
|
|
3134
3134
|
}, inputAttributes.value, {
|
|
@@ -3307,7 +3307,7 @@ const _hoisted_3$z = {
|
|
|
3307
3307
|
class: "lupa-suggestion-facet",
|
|
3308
3308
|
"data-cy": "lupa-suggestion-facet"
|
|
3309
3309
|
};
|
|
3310
|
-
const _hoisted_4$
|
|
3310
|
+
const _hoisted_4$p = {
|
|
3311
3311
|
class: "lupa-suggestion-facet-label",
|
|
3312
3312
|
"data-cy": "lupa-suggestion-facet-label"
|
|
3313
3313
|
};
|
|
@@ -3353,7 +3353,7 @@ const _sfc_main$1e = /* @__PURE__ */ defineComponent({
|
|
|
3353
3353
|
innerHTML: _ctx.suggestion.displayHighlight
|
|
3354
3354
|
}, null, 8, _hoisted_1$17)) : (openBlock(), createElementBlock("div", _hoisted_2$M, toDisplayString(_ctx.suggestion.display), 1)),
|
|
3355
3355
|
_ctx.suggestion.facet ? (openBlock(), createElementBlock("div", _hoisted_3$z, [
|
|
3356
|
-
createElementVNode("span", _hoisted_4$
|
|
3356
|
+
createElementVNode("span", _hoisted_4$p, toDisplayString(facetLabel.value), 1),
|
|
3357
3357
|
createElementVNode("span", _hoisted_5$e, toDisplayString(_ctx.suggestion.facet.title), 1)
|
|
3358
3358
|
])) : createCommentVNode("", true)
|
|
3359
3359
|
]);
|
|
@@ -3755,7 +3755,7 @@ const _sfc_main$16 = /* @__PURE__ */ defineComponent({
|
|
|
3755
3755
|
const _hoisted_1$10 = ["innerHTML"];
|
|
3756
3756
|
const _hoisted_2$J = { key: 0 };
|
|
3757
3757
|
const _hoisted_3$y = { key: 1 };
|
|
3758
|
-
const _hoisted_4$
|
|
3758
|
+
const _hoisted_4$o = { class: "lupa-search-box-custom-label" };
|
|
3759
3759
|
const _hoisted_5$d = { class: "lupa-search-box-custom-text" };
|
|
3760
3760
|
const _sfc_main$15 = /* @__PURE__ */ defineComponent({
|
|
3761
3761
|
__name: "SearchBoxProductCustom",
|
|
@@ -3788,7 +3788,7 @@ const _sfc_main$15 = /* @__PURE__ */ defineComponent({
|
|
|
3788
3788
|
class: [className.value, "lupa-search-box-product-custom"]
|
|
3789
3789
|
}, toHandlers(_ctx.options.action ? { click: handleClick } : {}, true)), [
|
|
3790
3790
|
!label.value ? (openBlock(), createElementBlock("div", _hoisted_2$J, toDisplayString(text.value), 1)) : (openBlock(), createElementBlock("div", _hoisted_3$y, [
|
|
3791
|
-
createElementVNode("div", _hoisted_4$
|
|
3791
|
+
createElementVNode("div", _hoisted_4$o, toDisplayString(label.value), 1),
|
|
3792
3792
|
createElementVNode("div", _hoisted_5$d, toDisplayString(text.value), 1)
|
|
3793
3793
|
]))
|
|
3794
3794
|
], 16));
|
|
@@ -4184,7 +4184,7 @@ const useTrackingStore = defineStore("tracking", () => {
|
|
|
4184
4184
|
const _hoisted_1$Z = ["href"];
|
|
4185
4185
|
const _hoisted_2$H = { class: "lupa-search-box-product-image-section" };
|
|
4186
4186
|
const _hoisted_3$w = { class: "lupa-search-box-product-details-section" };
|
|
4187
|
-
const _hoisted_4$
|
|
4187
|
+
const _hoisted_4$n = {
|
|
4188
4188
|
key: 0,
|
|
4189
4189
|
class: "lupa-search-box-product-add-to-cart-section"
|
|
4190
4190
|
};
|
|
@@ -4305,7 +4305,7 @@ const _sfc_main$11 = /* @__PURE__ */ defineComponent({
|
|
|
4305
4305
|
}, null, 8, ["item", "element", "labels", "link"]);
|
|
4306
4306
|
}), 128))
|
|
4307
4307
|
]),
|
|
4308
|
-
addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$
|
|
4308
|
+
addToCartElement.value ? (openBlock(), createElementBlock("div", _hoisted_4$n, [
|
|
4309
4309
|
createVNode(_sfc_main$12, {
|
|
4310
4310
|
class: "lupa-search-box-product-element",
|
|
4311
4311
|
item: _ctx.item,
|
|
@@ -4440,12 +4440,8 @@ const _hoisted_1$X = {
|
|
|
4440
4440
|
key: 0,
|
|
4441
4441
|
id: "lupa-search-box-panel"
|
|
4442
4442
|
};
|
|
4443
|
-
const _hoisted_2$G =
|
|
4444
|
-
|
|
4445
|
-
"data-cy": "lupa-main-panel"
|
|
4446
|
-
};
|
|
4447
|
-
const _hoisted_3$v = ["data-cy"];
|
|
4448
|
-
const _hoisted_4$n = {
|
|
4443
|
+
const _hoisted_2$G = ["data-cy"];
|
|
4444
|
+
const _hoisted_3$v = {
|
|
4449
4445
|
key: 1,
|
|
4450
4446
|
id: "lupa-search-box-panel"
|
|
4451
4447
|
};
|
|
@@ -4482,7 +4478,7 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
4482
4478
|
const panels = computed(() => props.options.panels);
|
|
4483
4479
|
const sdkOptions = computed(() => props.options.options);
|
|
4484
4480
|
const searchBoxStore = useSearchBoxStore();
|
|
4485
|
-
const { suggestionResults, hasAnyResults } = storeToRefs(searchBoxStore);
|
|
4481
|
+
const { suggestionResults, hasAnyResults, panelItemCounts } = storeToRefs(searchBoxStore);
|
|
4486
4482
|
const displayResults = computed(
|
|
4487
4483
|
() => {
|
|
4488
4484
|
var _a, _b;
|
|
@@ -4563,6 +4559,12 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
4563
4559
|
`${window.innerHeight - panel.getBoundingClientRect().y - 10}px`
|
|
4564
4560
|
);
|
|
4565
4561
|
};
|
|
4562
|
+
const numberOfVisiblePanels = computed(() => {
|
|
4563
|
+
return panelItemCounts.value.filter((v) => v.count > 0).length;
|
|
4564
|
+
});
|
|
4565
|
+
const expandOnSinglePanel = computed(() => {
|
|
4566
|
+
return numberOfVisiblePanels.value === 1 && props.options.expandOnSinglePanel;
|
|
4567
|
+
});
|
|
4566
4568
|
return (_ctx, _cache) => {
|
|
4567
4569
|
var _a;
|
|
4568
4570
|
return openBlock(), createElementBlock("div", {
|
|
@@ -4570,7 +4572,11 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
4570
4572
|
ref: panelContainer
|
|
4571
4573
|
}, [
|
|
4572
4574
|
displayResults.value ? (openBlock(), createElementBlock("div", _hoisted_1$X, [
|
|
4573
|
-
createElementVNode("div",
|
|
4575
|
+
createElementVNode("div", {
|
|
4576
|
+
class: "lupa-main-panel",
|
|
4577
|
+
style: normalizeStyle(expandOnSinglePanel.value ? { display: "block" } : {}),
|
|
4578
|
+
"data-cy": "lupa-main-panel"
|
|
4579
|
+
}, [
|
|
4574
4580
|
(openBlock(true), createElementBlock(Fragment, null, renderList(displayPanels.value, (panel, index) => {
|
|
4575
4581
|
return openBlock(), createElementBlock("div", {
|
|
4576
4582
|
key: index,
|
|
@@ -4599,9 +4605,9 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
4599
4605
|
key: "0"
|
|
4600
4606
|
} : void 0
|
|
4601
4607
|
]), 1064, ["panel", "options", "debounce", "inputValue", "labels"])) : createCommentVNode("", true)
|
|
4602
|
-
], 10,
|
|
4608
|
+
], 10, _hoisted_2$G);
|
|
4603
4609
|
}), 128))
|
|
4604
|
-
]),
|
|
4610
|
+
], 4),
|
|
4605
4611
|
!unref(hasAnyResults) && _ctx.options.showNoResultsPanel ? (openBlock(), createBlock(_sfc_main$1f, {
|
|
4606
4612
|
key: 0,
|
|
4607
4613
|
labels: labels.value
|
|
@@ -4612,7 +4618,7 @@ const _sfc_main$_ = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
|
|
|
4612
4618
|
showTotalCount: (_a = _ctx.options.showTotalCount) != null ? _a : false,
|
|
4613
4619
|
onGoToResults: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("go-to-results"))
|
|
4614
4620
|
}, null, 8, ["labels", "showTotalCount"])) : createCommentVNode("", true)
|
|
4615
|
-
])) : displayHistory.value ? (openBlock(), createElementBlock("div",
|
|
4621
|
+
])) : displayHistory.value ? (openBlock(), createElementBlock("div", _hoisted_3$v, [
|
|
4616
4622
|
createVNode(_sfc_main$1g, {
|
|
4617
4623
|
options: _ctx.options.history,
|
|
4618
4624
|
history: history.value,
|
|
@@ -4681,7 +4687,8 @@ const _sfc_main$Z = /* @__PURE__ */ defineComponent({
|
|
|
4681
4687
|
"debounce",
|
|
4682
4688
|
"showTotalCount",
|
|
4683
4689
|
"hideMoreResultsButtonOnNoResults",
|
|
4684
|
-
"showNoResultsPanel"
|
|
4690
|
+
"showNoResultsPanel",
|
|
4691
|
+
"expandOnSinglePanel"
|
|
4685
4692
|
])
|
|
4686
4693
|
);
|
|
4687
4694
|
const searchTriggers = computed(() => {
|
|
@@ -9366,8 +9373,14 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
9366
9373
|
const isTitleResultTopPosition = computed(() => {
|
|
9367
9374
|
return props.options.searchTitlePosition === "search-results-top";
|
|
9368
9375
|
});
|
|
9376
|
+
const handlePopState = () => {
|
|
9377
|
+
var _a;
|
|
9378
|
+
const searchParams = getSearchParams((_a = props.options.ssr) == null ? void 0 : _a.url);
|
|
9379
|
+
paramStore.add(parseParams(searchParams));
|
|
9380
|
+
};
|
|
9369
9381
|
onMounted(() => {
|
|
9370
9382
|
var _a, _b;
|
|
9383
|
+
window.addEventListener("popstate", handlePopState);
|
|
9371
9384
|
window.addEventListener("resize", handleResize);
|
|
9372
9385
|
if (props.initialData) {
|
|
9373
9386
|
searchResultStore.add(__spreadValues({}, props.initialData));
|
|
@@ -9378,6 +9391,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
|
|
|
9378
9391
|
});
|
|
9379
9392
|
onBeforeUnmount(() => {
|
|
9380
9393
|
window.removeEventListener("resize", handleResize);
|
|
9394
|
+
window.removeEventListener("popstate", handlePopState);
|
|
9381
9395
|
});
|
|
9382
9396
|
const trackItemListView = (title, items = []) => {
|
|
9383
9397
|
trackingStore.trackEvent({
|
|
@@ -16126,11 +16140,12 @@ const getApiUrl = (environment, customBaseUrl) => {
|
|
|
16126
16140
|
}
|
|
16127
16141
|
return Env[environment] || Env["production"];
|
|
16128
16142
|
};
|
|
16129
|
-
const suggestSearchChatPhrases = (options, request) => __async(void 0, null, function* () {
|
|
16143
|
+
const suggestSearchChatPhrases = (options, request, chatSettings) => __async(void 0, null, function* () {
|
|
16130
16144
|
var _a, _b, _c;
|
|
16131
16145
|
const { environment, customBaseUrl } = options;
|
|
16146
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16132
16147
|
try {
|
|
16133
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat
|
|
16148
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat${model}`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16134
16149
|
body: JSON.stringify(request),
|
|
16135
16150
|
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16136
16151
|
}));
|
|
@@ -16146,14 +16161,18 @@ const suggestSearchChatPhrases = (options, request) => __async(void 0, null, fun
|
|
|
16146
16161
|
return { success: false, errors: [e] };
|
|
16147
16162
|
}
|
|
16148
16163
|
});
|
|
16149
|
-
const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
|
|
16164
|
+
const suggestPhraseAlternatives = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
|
|
16150
16165
|
var _a, _b, _c;
|
|
16151
16166
|
const { environment, customBaseUrl } = options;
|
|
16167
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16152
16168
|
try {
|
|
16153
|
-
const res = yield fetch(
|
|
16154
|
-
|
|
16155
|
-
|
|
16156
|
-
|
|
16169
|
+
const res = yield fetch(
|
|
16170
|
+
`${getApiUrl(environment, customBaseUrl)}chat/phraseAlternatives${model}`,
|
|
16171
|
+
__spreadProps(__spreadValues({}, defaultConfig), {
|
|
16172
|
+
body: JSON.stringify({ phrases }),
|
|
16173
|
+
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16174
|
+
})
|
|
16175
|
+
);
|
|
16157
16176
|
if (res.status < 400) {
|
|
16158
16177
|
const data = yield res.json();
|
|
16159
16178
|
return __spreadProps(__spreadValues({}, data), { success: true });
|
|
@@ -16166,11 +16185,12 @@ const suggestPhraseAlternatives = (_0, _1) => __async(void 0, [_0, _1], function
|
|
|
16166
16185
|
return { success: false, errors: [e] };
|
|
16167
16186
|
}
|
|
16168
16187
|
});
|
|
16169
|
-
const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function* (options, { phrases }) {
|
|
16188
|
+
const suggestSimplifiedPhrases = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, { phrases }, chatSettings) {
|
|
16170
16189
|
var _a, _b, _c;
|
|
16171
16190
|
const { environment, customBaseUrl } = options;
|
|
16191
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16172
16192
|
try {
|
|
16173
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16193
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/simplify${model}`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16174
16194
|
body: JSON.stringify({ phrases }),
|
|
16175
16195
|
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16176
16196
|
}));
|
|
@@ -16186,15 +16206,16 @@ const suggestSimplifiedPhrases = (_0, _1) => __async(void 0, [_0, _1], function*
|
|
|
16186
16206
|
return { success: false, errors: [e] };
|
|
16187
16207
|
}
|
|
16188
16208
|
});
|
|
16189
|
-
const suggestBestProductMatches = (_0, _1) => __async(void 0, [_0, _1], function* (options, {
|
|
16209
|
+
const suggestBestProductMatches = (_0, _1, _2) => __async(void 0, [_0, _1, _2], function* (options, {
|
|
16190
16210
|
initialQuery,
|
|
16191
16211
|
productStrings,
|
|
16192
16212
|
messageHistory
|
|
16193
|
-
}) {
|
|
16213
|
+
}, chatSettings) {
|
|
16194
16214
|
var _a, _b, _c;
|
|
16195
16215
|
const { environment, customBaseUrl } = options;
|
|
16216
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16196
16217
|
try {
|
|
16197
|
-
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16218
|
+
const res = yield fetch(`${getApiUrl(environment, customBaseUrl)}chat/bestProducts${model}`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16198
16219
|
body: JSON.stringify({ initialQuery, messageHistory, productStrings }),
|
|
16199
16220
|
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16200
16221
|
}));
|
|
@@ -16231,9 +16252,10 @@ const prepareChatHistory = (chatLog) => {
|
|
|
16231
16252
|
}
|
|
16232
16253
|
return history;
|
|
16233
16254
|
};
|
|
16234
|
-
const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived) => {
|
|
16255
|
+
const getTextResponseChunkStream = (options, { initialQuery, messageHistory }, onChunkReceived, chatSettings) => {
|
|
16235
16256
|
var _a;
|
|
16236
|
-
|
|
16257
|
+
const model = (chatSettings == null ? void 0 : chatSettings.model) ? `?model=${chatSettings.model}` : ``;
|
|
16258
|
+
fetch(`${getApiUrl(options.environment, options.customBaseUrl)}chat/text${model}`, __spreadProps(__spreadValues({}, defaultConfig), {
|
|
16237
16259
|
body: JSON.stringify({ initialQuery, messageHistory }),
|
|
16238
16260
|
headers: __spreadValues(__spreadValues({}, headers), (_a = options.customHeaders) != null ? _a : {})
|
|
16239
16261
|
})).then((response) => {
|
|
@@ -16373,9 +16395,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
16373
16395
|
return result.items;
|
|
16374
16396
|
});
|
|
16375
16397
|
const getPhraseAlternatives = () => __async(this, null, function* () {
|
|
16376
|
-
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
16377
|
-
|
|
16378
|
-
|
|
16398
|
+
const { phrases } = yield ChatService.suggestPhraseAlternatives(
|
|
16399
|
+
props.options.sdkOptions,
|
|
16400
|
+
{
|
|
16401
|
+
phrases: [props.phrase]
|
|
16402
|
+
},
|
|
16403
|
+
props.options.chatSettings
|
|
16404
|
+
);
|
|
16379
16405
|
return phrases != null ? phrases : [];
|
|
16380
16406
|
});
|
|
16381
16407
|
return (_ctx, _cache) => {
|
|
@@ -16440,11 +16466,15 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
16440
16466
|
return (_b = (_a2 = result[titleKey.value]) == null ? void 0 : _a2.toString()) != null ? _b : "";
|
|
16441
16467
|
}
|
|
16442
16468
|
);
|
|
16443
|
-
const { products } = yield ChatService.suggestBestProductMatches(
|
|
16444
|
-
|
|
16445
|
-
|
|
16446
|
-
|
|
16447
|
-
|
|
16469
|
+
const { products } = yield ChatService.suggestBestProductMatches(
|
|
16470
|
+
props.options.sdkOptions,
|
|
16471
|
+
{
|
|
16472
|
+
initialQuery: props.entry.userInput,
|
|
16473
|
+
productStrings: productResultStrings,
|
|
16474
|
+
messageHistory: (_a = props.history) != null ? _a : []
|
|
16475
|
+
},
|
|
16476
|
+
props.options.chatSettings
|
|
16477
|
+
);
|
|
16448
16478
|
bestMatches.value = products;
|
|
16449
16479
|
emit("loaded", products);
|
|
16450
16480
|
} finally {
|
|
@@ -16517,7 +16547,8 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
16517
16547
|
initialQuery: props.content,
|
|
16518
16548
|
messageHistory: (_a = props.history) != null ? _a : []
|
|
16519
16549
|
},
|
|
16520
|
-
processChunk
|
|
16550
|
+
processChunk,
|
|
16551
|
+
props.options.chatSettings
|
|
16521
16552
|
);
|
|
16522
16553
|
});
|
|
16523
16554
|
return (_ctx, _cache) => {
|
|
@@ -16614,7 +16645,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
16614
16645
|
};
|
|
16615
16646
|
const { phrases, success } = yield ChatService.suggestSearchChatPhrases(
|
|
16616
16647
|
props.options.sdkOptions,
|
|
16617
|
-
request
|
|
16648
|
+
request,
|
|
16649
|
+
props.options.chatSettings
|
|
16618
16650
|
);
|
|
16619
16651
|
if (!success || !phrases.length) {
|
|
16620
16652
|
error.value = "Something went wrong";
|
|
@@ -2,20 +2,21 @@ import { SdkOptions } from '..';
|
|
|
2
2
|
import { ChatMessage, SearchChatRequest } from '../types/chat/SearchChatRequest';
|
|
3
3
|
import { SearchChatResponse } from '../types/chat/SearchChatResponse';
|
|
4
4
|
import { ChatContent } from '../types/chat/ChatLog';
|
|
5
|
+
import { ChatSettings } from '../types/chat/ChatOptions';
|
|
5
6
|
declare const _default: {
|
|
6
|
-
suggestSearchChatPhrases: (options: SdkOptions, request: SearchChatRequest) => Promise<Partial<SearchChatResponse> & {
|
|
7
|
+
suggestSearchChatPhrases: (options: SdkOptions, request: SearchChatRequest, chatSettings?: ChatSettings) => Promise<Partial<SearchChatResponse> & {
|
|
7
8
|
success: boolean;
|
|
8
9
|
errors: any;
|
|
9
10
|
}>;
|
|
10
11
|
suggestPhraseAlternatives: (options: SdkOptions, { phrases }: {
|
|
11
12
|
phrases: string[];
|
|
12
|
-
}) => Promise<Partial<SearchChatResponse> & {
|
|
13
|
+
}, chatSettings?: ChatSettings) => Promise<Partial<SearchChatResponse> & {
|
|
13
14
|
success: boolean;
|
|
14
15
|
errors: any;
|
|
15
16
|
}>;
|
|
16
17
|
suggestSimplifiedPhrases: (options: SdkOptions, { phrases }: {
|
|
17
18
|
phrases: string[];
|
|
18
|
-
}) => Promise<Partial<SearchChatResponse> & {
|
|
19
|
+
}, chatSettings?: ChatSettings) => Promise<Partial<SearchChatResponse> & {
|
|
19
20
|
success: boolean;
|
|
20
21
|
errors: any;
|
|
21
22
|
}>;
|
|
@@ -23,7 +24,7 @@ declare const _default: {
|
|
|
23
24
|
initialQuery: string;
|
|
24
25
|
productStrings: string[];
|
|
25
26
|
messageHistory: ChatMessage[];
|
|
26
|
-
}) => Promise<{
|
|
27
|
+
}, chatSettings?: ChatSettings) => Promise<{
|
|
27
28
|
products?: string[];
|
|
28
29
|
success: boolean;
|
|
29
30
|
errors: any;
|
|
@@ -32,6 +33,6 @@ declare const _default: {
|
|
|
32
33
|
getTextResponseChunkStream: (options: SdkOptions, { initialQuery, messageHistory }: {
|
|
33
34
|
initialQuery: string;
|
|
34
35
|
messageHistory: ChatMessage[];
|
|
35
|
-
}, onChunkReceived: (chunk: string) => void) => void;
|
|
36
|
+
}, onChunkReceived: (chunk: string) => void, chatSettings?: ChatSettings) => void;
|
|
36
37
|
};
|
|
37
38
|
export default _default;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -20,11 +20,11 @@ import SearchContainer from './components/search-container/SearchContainer.vue';
|
|
|
20
20
|
import Recommendations from './components/recommendations/Recommendations.vue';
|
|
21
21
|
import ChatContainer from './components/chat/ChatContainer.vue';
|
|
22
22
|
import { getInitialSearchResults } from './utils/ssr.utils';
|
|
23
|
-
import { ChatOptions } from './types/chat/ChatOptions';
|
|
23
|
+
import { ChatOptions, ChatSettings } from './types/chat/ChatOptions';
|
|
24
24
|
declare const initPinia: () => Pinia;
|
|
25
25
|
declare const setupTracking: (options: TrackingOptions) => void;
|
|
26
26
|
declare const LupaSearch: {
|
|
27
27
|
install: (app: any, options: any) => void;
|
|
28
28
|
};
|
|
29
29
|
export { SearchBox, SearchResults, ProductList, Recommendations, SearchContainer, ChatContainer, DocumentElementType, SearchBoxPanelType, BadgeType, setupTracking, LupaSearch, initPinia, getInitialSearchResults };
|
|
30
|
-
export type { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, FacetStyle, Environment, RoutingBehavior, AnchorPosition, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, SearchBoxEventCallbacks, SearchBoxResultCallbackContext };
|
|
30
|
+
export type { TrackingOptions, SearchBoxOptions, SearchResultsOptions, ProductListOptions, SdkOptions, FacetStyle, Environment, RoutingBehavior, AnchorPosition, SortDirection, DocumentElement, ImageDocumentElement, TitleDocumentElement, DescriptionDocumentElement, CustomDocumentElement, PriceElement, RegularPriceDocumentElement, RatingElement, AddToCartElement, CustomHtmlElement, SortOptions, SearchResultsSortOptions, SearchResultEventCallbacks, CallbackContext, SortCallbackContext, ResultCallbackContext, FacetFilterQuery, CategoryFilterOptions, SearchResultsFilterOptions, SearchResultBadgeType, SearchResultBadgeElement, ResultFacetOptions, BadgeGenerateSeed, BadgeGenerateOptions, BadgeOptions, SearchContainerOptions, SearchContainerConfigOptions, SingleStarRatingElement, DynamicData, ProductRecommendationOptions, RecommendationABTestingOptions, SsrOptions, ChatOptions, ChatSettings, SearchBoxEventCallbacks, SearchBoxResultCallbackContext };
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { SdkOptions } from '../General';
|
|
2
2
|
import { SearchResultsOptions } from '../search-results/SearchResultsOptions';
|
|
3
|
+
export type ChatSettings = {
|
|
4
|
+
model?: string;
|
|
5
|
+
};
|
|
3
6
|
export type ChatOptions = {
|
|
4
7
|
sdkOptions: SdkOptions;
|
|
5
8
|
displayOptions: SearchResultsOptions;
|
|
9
|
+
chatSettings?: ChatSettings;
|
|
6
10
|
};
|