@getlupa/client 1.12.5 → 1.12.6
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 +66 -26
- package/dist/lupaSearch.js +66 -26
- package/dist/lupaSearch.mjs +66 -26
- package/dist/lupaSearch.umd.js +66 -26
- package/dist/src/index.d.ts +2 -1
- package/dist/src/utils/mounting.utils.d.ts +10 -0
- package/package.json +1 -1
package/dist/lupaSearch.iife.js
CHANGED
|
@@ -29008,22 +29008,30 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29008
29008
|
getSearchBoxComponent,
|
|
29009
29009
|
getSearchResultsComponent
|
|
29010
29010
|
};
|
|
29011
|
-
const
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
|
|
29015
|
-
|
|
29016
|
-
|
|
29017
|
-
|
|
29018
|
-
|
|
29019
|
-
|
|
29020
|
-
|
|
29011
|
+
const getMountElement = (element, mountingBehavior = "replace", mountToParent) => {
|
|
29012
|
+
const parent = element == null ? void 0 : element.parentElement;
|
|
29013
|
+
if (mountingBehavior === "replace") {
|
|
29014
|
+
let mountElement = element;
|
|
29015
|
+
if (mountToParent) {
|
|
29016
|
+
mountElement = parent;
|
|
29017
|
+
}
|
|
29018
|
+
return mountElement;
|
|
29019
|
+
}
|
|
29020
|
+
if (mountingBehavior === "append") {
|
|
29021
|
+
const newElement = document.createElement("div");
|
|
29022
|
+
element == null ? void 0 : element.append(newElement);
|
|
29023
|
+
return newElement;
|
|
29024
|
+
}
|
|
29025
|
+
if (mountingBehavior === "prepend") {
|
|
29026
|
+
const newElement = document.createElement("div");
|
|
29027
|
+
element == null ? void 0 : element.prepend(newElement);
|
|
29028
|
+
return newElement;
|
|
29029
|
+
}
|
|
29021
29030
|
};
|
|
29022
|
-
const createVue = (selector, rootComponent, options, mountToParent = false) => {
|
|
29031
|
+
const createVue = (selector, mountingBehavior = "replace", rootComponent, options, mountToParent = false) => {
|
|
29023
29032
|
const pinia = initPinia();
|
|
29024
29033
|
const element = typeof selector === "string" ? document.querySelector(selector) : selector;
|
|
29025
|
-
const
|
|
29026
|
-
const mountElement = mountToParent ? parent : element;
|
|
29034
|
+
const mountElement = getMountElement(element, mountingBehavior, mountToParent);
|
|
29027
29035
|
if (!mountElement) {
|
|
29028
29036
|
console.error(`Cannot mount LupaSearch component. Element "${selector}" not found`);
|
|
29029
29037
|
return;
|
|
@@ -29040,6 +29048,17 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29040
29048
|
}
|
|
29041
29049
|
return { mountedApp, mountedComponent, props, app: app2, mountElement };
|
|
29042
29050
|
};
|
|
29051
|
+
const app = {
|
|
29052
|
+
box: {},
|
|
29053
|
+
results: {},
|
|
29054
|
+
productList: {},
|
|
29055
|
+
searchContainer: {},
|
|
29056
|
+
recommendations: {},
|
|
29057
|
+
chat: {}
|
|
29058
|
+
};
|
|
29059
|
+
const tracking = (options) => {
|
|
29060
|
+
setupTracking(options);
|
|
29061
|
+
};
|
|
29043
29062
|
const applySearchBox = (options, mountOptions) => {
|
|
29044
29063
|
const existingInstance = app.box[options.inputSelector];
|
|
29045
29064
|
if (existingInstance) {
|
|
@@ -29054,6 +29073,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29054
29073
|
}
|
|
29055
29074
|
const instance = createVue(
|
|
29056
29075
|
options.inputSelector,
|
|
29076
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29057
29077
|
_sfc_main$4,
|
|
29058
29078
|
{ searchBoxOptions: options },
|
|
29059
29079
|
true
|
|
@@ -29082,9 +29102,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29082
29102
|
}
|
|
29083
29103
|
return;
|
|
29084
29104
|
}
|
|
29085
|
-
const instance = createVue(
|
|
29086
|
-
|
|
29087
|
-
|
|
29105
|
+
const instance = createVue(
|
|
29106
|
+
options.containerSelector,
|
|
29107
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29108
|
+
_sfc_main$3,
|
|
29109
|
+
{
|
|
29110
|
+
searchResultsOptions: options
|
|
29111
|
+
}
|
|
29112
|
+
);
|
|
29088
29113
|
if (!instance) {
|
|
29089
29114
|
return;
|
|
29090
29115
|
}
|
|
@@ -29102,9 +29127,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29102
29127
|
}
|
|
29103
29128
|
return;
|
|
29104
29129
|
}
|
|
29105
|
-
const instance = createVue(
|
|
29106
|
-
|
|
29107
|
-
|
|
29130
|
+
const instance = createVue(
|
|
29131
|
+
options.containerSelector,
|
|
29132
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29133
|
+
_sfc_main$2,
|
|
29134
|
+
{
|
|
29135
|
+
productListOptions: options
|
|
29136
|
+
}
|
|
29137
|
+
);
|
|
29108
29138
|
if (!instance) {
|
|
29109
29139
|
return;
|
|
29110
29140
|
}
|
|
@@ -29134,7 +29164,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29134
29164
|
options: options.options
|
|
29135
29165
|
});
|
|
29136
29166
|
document.body.appendChild(host);
|
|
29137
|
-
const instance = createVue(manager, _sfc_main$1, {
|
|
29167
|
+
const instance = createVue(manager, mountOptions == null ? void 0 : mountOptions.mountingBehavior, _sfc_main$1, {
|
|
29138
29168
|
searchContainerOptions: options
|
|
29139
29169
|
});
|
|
29140
29170
|
if (!instance) {
|
|
@@ -29171,9 +29201,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29171
29201
|
}
|
|
29172
29202
|
return;
|
|
29173
29203
|
}
|
|
29174
|
-
const instance = createVue(
|
|
29175
|
-
|
|
29176
|
-
|
|
29204
|
+
const instance = createVue(
|
|
29205
|
+
options.containerSelector,
|
|
29206
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29207
|
+
_sfc_main,
|
|
29208
|
+
{
|
|
29209
|
+
recommendationOptions: options
|
|
29210
|
+
}
|
|
29211
|
+
);
|
|
29177
29212
|
if (!instance) {
|
|
29178
29213
|
return;
|
|
29179
29214
|
}
|
|
@@ -29191,9 +29226,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29191
29226
|
}
|
|
29192
29227
|
return;
|
|
29193
29228
|
}
|
|
29194
|
-
const instance = createVue(
|
|
29195
|
-
options
|
|
29196
|
-
|
|
29229
|
+
const instance = createVue(
|
|
29230
|
+
options.displayOptions.containerSelector,
|
|
29231
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29232
|
+
_sfc_main$1o,
|
|
29233
|
+
{
|
|
29234
|
+
options
|
|
29235
|
+
}
|
|
29236
|
+
);
|
|
29197
29237
|
if (!instance) {
|
|
29198
29238
|
return;
|
|
29199
29239
|
}
|
package/dist/lupaSearch.js
CHANGED
|
@@ -29008,22 +29008,30 @@ const SearchContainerConfigurationService = {
|
|
|
29008
29008
|
getSearchBoxComponent,
|
|
29009
29009
|
getSearchResultsComponent
|
|
29010
29010
|
};
|
|
29011
|
-
const
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
|
|
29015
|
-
|
|
29016
|
-
|
|
29017
|
-
|
|
29018
|
-
|
|
29019
|
-
|
|
29020
|
-
|
|
29011
|
+
const getMountElement = (element, mountingBehavior = "replace", mountToParent) => {
|
|
29012
|
+
const parent = element == null ? void 0 : element.parentElement;
|
|
29013
|
+
if (mountingBehavior === "replace") {
|
|
29014
|
+
let mountElement = element;
|
|
29015
|
+
if (mountToParent) {
|
|
29016
|
+
mountElement = parent;
|
|
29017
|
+
}
|
|
29018
|
+
return mountElement;
|
|
29019
|
+
}
|
|
29020
|
+
if (mountingBehavior === "append") {
|
|
29021
|
+
const newElement = document.createElement("div");
|
|
29022
|
+
element == null ? void 0 : element.append(newElement);
|
|
29023
|
+
return newElement;
|
|
29024
|
+
}
|
|
29025
|
+
if (mountingBehavior === "prepend") {
|
|
29026
|
+
const newElement = document.createElement("div");
|
|
29027
|
+
element == null ? void 0 : element.prepend(newElement);
|
|
29028
|
+
return newElement;
|
|
29029
|
+
}
|
|
29021
29030
|
};
|
|
29022
|
-
const createVue = (selector, rootComponent, options, mountToParent = false) => {
|
|
29031
|
+
const createVue = (selector, mountingBehavior = "replace", rootComponent, options, mountToParent = false) => {
|
|
29023
29032
|
const pinia = initPinia();
|
|
29024
29033
|
const element = typeof selector === "string" ? document.querySelector(selector) : selector;
|
|
29025
|
-
const
|
|
29026
|
-
const mountElement = mountToParent ? parent : element;
|
|
29034
|
+
const mountElement = getMountElement(element, mountingBehavior, mountToParent);
|
|
29027
29035
|
if (!mountElement) {
|
|
29028
29036
|
console.error(`Cannot mount LupaSearch component. Element "${selector}" not found`);
|
|
29029
29037
|
return;
|
|
@@ -29040,6 +29048,17 @@ const createVue = (selector, rootComponent, options, mountToParent = false) => {
|
|
|
29040
29048
|
}
|
|
29041
29049
|
return { mountedApp, mountedComponent, props, app: app2, mountElement };
|
|
29042
29050
|
};
|
|
29051
|
+
const app = {
|
|
29052
|
+
box: {},
|
|
29053
|
+
results: {},
|
|
29054
|
+
productList: {},
|
|
29055
|
+
searchContainer: {},
|
|
29056
|
+
recommendations: {},
|
|
29057
|
+
chat: {}
|
|
29058
|
+
};
|
|
29059
|
+
const tracking = (options) => {
|
|
29060
|
+
setupTracking(options);
|
|
29061
|
+
};
|
|
29043
29062
|
const applySearchBox = (options, mountOptions) => {
|
|
29044
29063
|
const existingInstance = app.box[options.inputSelector];
|
|
29045
29064
|
if (existingInstance) {
|
|
@@ -29054,6 +29073,7 @@ const applySearchBox = (options, mountOptions) => {
|
|
|
29054
29073
|
}
|
|
29055
29074
|
const instance = createVue(
|
|
29056
29075
|
options.inputSelector,
|
|
29076
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29057
29077
|
_sfc_main$4,
|
|
29058
29078
|
{ searchBoxOptions: options },
|
|
29059
29079
|
true
|
|
@@ -29082,9 +29102,14 @@ const searchResults = (options, mountOptions) => {
|
|
|
29082
29102
|
}
|
|
29083
29103
|
return;
|
|
29084
29104
|
}
|
|
29085
|
-
const instance = createVue(
|
|
29086
|
-
|
|
29087
|
-
|
|
29105
|
+
const instance = createVue(
|
|
29106
|
+
options.containerSelector,
|
|
29107
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29108
|
+
_sfc_main$3,
|
|
29109
|
+
{
|
|
29110
|
+
searchResultsOptions: options
|
|
29111
|
+
}
|
|
29112
|
+
);
|
|
29088
29113
|
if (!instance) {
|
|
29089
29114
|
return;
|
|
29090
29115
|
}
|
|
@@ -29102,9 +29127,14 @@ const productList = (options, mountOptions) => {
|
|
|
29102
29127
|
}
|
|
29103
29128
|
return;
|
|
29104
29129
|
}
|
|
29105
|
-
const instance = createVue(
|
|
29106
|
-
|
|
29107
|
-
|
|
29130
|
+
const instance = createVue(
|
|
29131
|
+
options.containerSelector,
|
|
29132
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29133
|
+
_sfc_main$2,
|
|
29134
|
+
{
|
|
29135
|
+
productListOptions: options
|
|
29136
|
+
}
|
|
29137
|
+
);
|
|
29108
29138
|
if (!instance) {
|
|
29109
29139
|
return;
|
|
29110
29140
|
}
|
|
@@ -29134,7 +29164,7 @@ const searchContainer = (options, mountOptions) => {
|
|
|
29134
29164
|
options: options.options
|
|
29135
29165
|
});
|
|
29136
29166
|
document.body.appendChild(host);
|
|
29137
|
-
const instance = createVue(manager, _sfc_main$1, {
|
|
29167
|
+
const instance = createVue(manager, mountOptions == null ? void 0 : mountOptions.mountingBehavior, _sfc_main$1, {
|
|
29138
29168
|
searchContainerOptions: options
|
|
29139
29169
|
});
|
|
29140
29170
|
if (!instance) {
|
|
@@ -29171,9 +29201,14 @@ const recommendations = (options, mountOptions) => {
|
|
|
29171
29201
|
}
|
|
29172
29202
|
return;
|
|
29173
29203
|
}
|
|
29174
|
-
const instance = createVue(
|
|
29175
|
-
|
|
29176
|
-
|
|
29204
|
+
const instance = createVue(
|
|
29205
|
+
options.containerSelector,
|
|
29206
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29207
|
+
_sfc_main,
|
|
29208
|
+
{
|
|
29209
|
+
recommendationOptions: options
|
|
29210
|
+
}
|
|
29211
|
+
);
|
|
29177
29212
|
if (!instance) {
|
|
29178
29213
|
return;
|
|
29179
29214
|
}
|
|
@@ -29191,9 +29226,14 @@ const chat = (options, mountOptions) => {
|
|
|
29191
29226
|
}
|
|
29192
29227
|
return;
|
|
29193
29228
|
}
|
|
29194
|
-
const instance = createVue(
|
|
29195
|
-
options
|
|
29196
|
-
|
|
29229
|
+
const instance = createVue(
|
|
29230
|
+
options.displayOptions.containerSelector,
|
|
29231
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29232
|
+
_sfc_main$1o,
|
|
29233
|
+
{
|
|
29234
|
+
options
|
|
29235
|
+
}
|
|
29236
|
+
);
|
|
29197
29237
|
if (!instance) {
|
|
29198
29238
|
return;
|
|
29199
29239
|
}
|
package/dist/lupaSearch.mjs
CHANGED
|
@@ -29006,22 +29006,30 @@ const SearchContainerConfigurationService = {
|
|
|
29006
29006
|
getSearchBoxComponent,
|
|
29007
29007
|
getSearchResultsComponent
|
|
29008
29008
|
};
|
|
29009
|
-
const
|
|
29010
|
-
|
|
29011
|
-
|
|
29012
|
-
|
|
29013
|
-
|
|
29014
|
-
|
|
29015
|
-
|
|
29016
|
-
|
|
29017
|
-
|
|
29018
|
-
|
|
29009
|
+
const getMountElement = (element, mountingBehavior = "replace", mountToParent) => {
|
|
29010
|
+
const parent = element == null ? void 0 : element.parentElement;
|
|
29011
|
+
if (mountingBehavior === "replace") {
|
|
29012
|
+
let mountElement = element;
|
|
29013
|
+
if (mountToParent) {
|
|
29014
|
+
mountElement = parent;
|
|
29015
|
+
}
|
|
29016
|
+
return mountElement;
|
|
29017
|
+
}
|
|
29018
|
+
if (mountingBehavior === "append") {
|
|
29019
|
+
const newElement = document.createElement("div");
|
|
29020
|
+
element == null ? void 0 : element.append(newElement);
|
|
29021
|
+
return newElement;
|
|
29022
|
+
}
|
|
29023
|
+
if (mountingBehavior === "prepend") {
|
|
29024
|
+
const newElement = document.createElement("div");
|
|
29025
|
+
element == null ? void 0 : element.prepend(newElement);
|
|
29026
|
+
return newElement;
|
|
29027
|
+
}
|
|
29019
29028
|
};
|
|
29020
|
-
const createVue = (selector, rootComponent, options, mountToParent = false) => {
|
|
29029
|
+
const createVue = (selector, mountingBehavior = "replace", rootComponent, options, mountToParent = false) => {
|
|
29021
29030
|
const pinia = initPinia();
|
|
29022
29031
|
const element = typeof selector === "string" ? document.querySelector(selector) : selector;
|
|
29023
|
-
const
|
|
29024
|
-
const mountElement = mountToParent ? parent : element;
|
|
29032
|
+
const mountElement = getMountElement(element, mountingBehavior, mountToParent);
|
|
29025
29033
|
if (!mountElement) {
|
|
29026
29034
|
console.error(`Cannot mount LupaSearch component. Element "${selector}" not found`);
|
|
29027
29035
|
return;
|
|
@@ -29038,6 +29046,17 @@ const createVue = (selector, rootComponent, options, mountToParent = false) => {
|
|
|
29038
29046
|
}
|
|
29039
29047
|
return { mountedApp, mountedComponent, props, app: app2, mountElement };
|
|
29040
29048
|
};
|
|
29049
|
+
const app = {
|
|
29050
|
+
box: {},
|
|
29051
|
+
results: {},
|
|
29052
|
+
productList: {},
|
|
29053
|
+
searchContainer: {},
|
|
29054
|
+
recommendations: {},
|
|
29055
|
+
chat: {}
|
|
29056
|
+
};
|
|
29057
|
+
const tracking = (options) => {
|
|
29058
|
+
setupTracking(options);
|
|
29059
|
+
};
|
|
29041
29060
|
const applySearchBox = (options, mountOptions) => {
|
|
29042
29061
|
const existingInstance = app.box[options.inputSelector];
|
|
29043
29062
|
if (existingInstance) {
|
|
@@ -29052,6 +29071,7 @@ const applySearchBox = (options, mountOptions) => {
|
|
|
29052
29071
|
}
|
|
29053
29072
|
const instance = createVue(
|
|
29054
29073
|
options.inputSelector,
|
|
29074
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29055
29075
|
_sfc_main$4,
|
|
29056
29076
|
{ searchBoxOptions: options },
|
|
29057
29077
|
true
|
|
@@ -29080,9 +29100,14 @@ const searchResults = (options, mountOptions) => {
|
|
|
29080
29100
|
}
|
|
29081
29101
|
return;
|
|
29082
29102
|
}
|
|
29083
|
-
const instance = createVue(
|
|
29084
|
-
|
|
29085
|
-
|
|
29103
|
+
const instance = createVue(
|
|
29104
|
+
options.containerSelector,
|
|
29105
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29106
|
+
_sfc_main$3,
|
|
29107
|
+
{
|
|
29108
|
+
searchResultsOptions: options
|
|
29109
|
+
}
|
|
29110
|
+
);
|
|
29086
29111
|
if (!instance) {
|
|
29087
29112
|
return;
|
|
29088
29113
|
}
|
|
@@ -29100,9 +29125,14 @@ const productList = (options, mountOptions) => {
|
|
|
29100
29125
|
}
|
|
29101
29126
|
return;
|
|
29102
29127
|
}
|
|
29103
|
-
const instance = createVue(
|
|
29104
|
-
|
|
29105
|
-
|
|
29128
|
+
const instance = createVue(
|
|
29129
|
+
options.containerSelector,
|
|
29130
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29131
|
+
_sfc_main$2,
|
|
29132
|
+
{
|
|
29133
|
+
productListOptions: options
|
|
29134
|
+
}
|
|
29135
|
+
);
|
|
29106
29136
|
if (!instance) {
|
|
29107
29137
|
return;
|
|
29108
29138
|
}
|
|
@@ -29132,7 +29162,7 @@ const searchContainer = (options, mountOptions) => {
|
|
|
29132
29162
|
options: options.options
|
|
29133
29163
|
});
|
|
29134
29164
|
document.body.appendChild(host);
|
|
29135
|
-
const instance = createVue(manager, _sfc_main$1, {
|
|
29165
|
+
const instance = createVue(manager, mountOptions == null ? void 0 : mountOptions.mountingBehavior, _sfc_main$1, {
|
|
29136
29166
|
searchContainerOptions: options
|
|
29137
29167
|
});
|
|
29138
29168
|
if (!instance) {
|
|
@@ -29169,9 +29199,14 @@ const recommendations = (options, mountOptions) => {
|
|
|
29169
29199
|
}
|
|
29170
29200
|
return;
|
|
29171
29201
|
}
|
|
29172
|
-
const instance = createVue(
|
|
29173
|
-
|
|
29174
|
-
|
|
29202
|
+
const instance = createVue(
|
|
29203
|
+
options.containerSelector,
|
|
29204
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29205
|
+
_sfc_main,
|
|
29206
|
+
{
|
|
29207
|
+
recommendationOptions: options
|
|
29208
|
+
}
|
|
29209
|
+
);
|
|
29175
29210
|
if (!instance) {
|
|
29176
29211
|
return;
|
|
29177
29212
|
}
|
|
@@ -29189,9 +29224,14 @@ const chat = (options, mountOptions) => {
|
|
|
29189
29224
|
}
|
|
29190
29225
|
return;
|
|
29191
29226
|
}
|
|
29192
|
-
const instance = createVue(
|
|
29193
|
-
options
|
|
29194
|
-
|
|
29227
|
+
const instance = createVue(
|
|
29228
|
+
options.displayOptions.containerSelector,
|
|
29229
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29230
|
+
_sfc_main$1o,
|
|
29231
|
+
{
|
|
29232
|
+
options
|
|
29233
|
+
}
|
|
29234
|
+
);
|
|
29195
29235
|
if (!instance) {
|
|
29196
29236
|
return;
|
|
29197
29237
|
}
|
package/dist/lupaSearch.umd.js
CHANGED
|
@@ -29010,22 +29010,30 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29010
29010
|
getSearchBoxComponent,
|
|
29011
29011
|
getSearchResultsComponent
|
|
29012
29012
|
};
|
|
29013
|
-
const
|
|
29014
|
-
|
|
29015
|
-
|
|
29016
|
-
|
|
29017
|
-
|
|
29018
|
-
|
|
29019
|
-
|
|
29020
|
-
|
|
29021
|
-
|
|
29022
|
-
|
|
29013
|
+
const getMountElement = (element, mountingBehavior = "replace", mountToParent) => {
|
|
29014
|
+
const parent = element == null ? void 0 : element.parentElement;
|
|
29015
|
+
if (mountingBehavior === "replace") {
|
|
29016
|
+
let mountElement = element;
|
|
29017
|
+
if (mountToParent) {
|
|
29018
|
+
mountElement = parent;
|
|
29019
|
+
}
|
|
29020
|
+
return mountElement;
|
|
29021
|
+
}
|
|
29022
|
+
if (mountingBehavior === "append") {
|
|
29023
|
+
const newElement = document.createElement("div");
|
|
29024
|
+
element == null ? void 0 : element.append(newElement);
|
|
29025
|
+
return newElement;
|
|
29026
|
+
}
|
|
29027
|
+
if (mountingBehavior === "prepend") {
|
|
29028
|
+
const newElement = document.createElement("div");
|
|
29029
|
+
element == null ? void 0 : element.prepend(newElement);
|
|
29030
|
+
return newElement;
|
|
29031
|
+
}
|
|
29023
29032
|
};
|
|
29024
|
-
const createVue = (selector, rootComponent, options, mountToParent = false) => {
|
|
29033
|
+
const createVue = (selector, mountingBehavior = "replace", rootComponent, options, mountToParent = false) => {
|
|
29025
29034
|
const pinia = initPinia();
|
|
29026
29035
|
const element = typeof selector === "string" ? document.querySelector(selector) : selector;
|
|
29027
|
-
const
|
|
29028
|
-
const mountElement = mountToParent ? parent : element;
|
|
29036
|
+
const mountElement = getMountElement(element, mountingBehavior, mountToParent);
|
|
29029
29037
|
if (!mountElement) {
|
|
29030
29038
|
console.error(`Cannot mount LupaSearch component. Element "${selector}" not found`);
|
|
29031
29039
|
return;
|
|
@@ -29042,6 +29050,17 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29042
29050
|
}
|
|
29043
29051
|
return { mountedApp, mountedComponent, props, app: app2, mountElement };
|
|
29044
29052
|
};
|
|
29053
|
+
const app = {
|
|
29054
|
+
box: {},
|
|
29055
|
+
results: {},
|
|
29056
|
+
productList: {},
|
|
29057
|
+
searchContainer: {},
|
|
29058
|
+
recommendations: {},
|
|
29059
|
+
chat: {}
|
|
29060
|
+
};
|
|
29061
|
+
const tracking = (options) => {
|
|
29062
|
+
setupTracking(options);
|
|
29063
|
+
};
|
|
29045
29064
|
const applySearchBox = (options, mountOptions) => {
|
|
29046
29065
|
const existingInstance = app.box[options.inputSelector];
|
|
29047
29066
|
if (existingInstance) {
|
|
@@ -29056,6 +29075,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29056
29075
|
}
|
|
29057
29076
|
const instance = createVue(
|
|
29058
29077
|
options.inputSelector,
|
|
29078
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29059
29079
|
_sfc_main$4,
|
|
29060
29080
|
{ searchBoxOptions: options },
|
|
29061
29081
|
true
|
|
@@ -29084,9 +29104,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29084
29104
|
}
|
|
29085
29105
|
return;
|
|
29086
29106
|
}
|
|
29087
|
-
const instance = createVue(
|
|
29088
|
-
|
|
29089
|
-
|
|
29107
|
+
const instance = createVue(
|
|
29108
|
+
options.containerSelector,
|
|
29109
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29110
|
+
_sfc_main$3,
|
|
29111
|
+
{
|
|
29112
|
+
searchResultsOptions: options
|
|
29113
|
+
}
|
|
29114
|
+
);
|
|
29090
29115
|
if (!instance) {
|
|
29091
29116
|
return;
|
|
29092
29117
|
}
|
|
@@ -29104,9 +29129,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29104
29129
|
}
|
|
29105
29130
|
return;
|
|
29106
29131
|
}
|
|
29107
|
-
const instance = createVue(
|
|
29108
|
-
|
|
29109
|
-
|
|
29132
|
+
const instance = createVue(
|
|
29133
|
+
options.containerSelector,
|
|
29134
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29135
|
+
_sfc_main$2,
|
|
29136
|
+
{
|
|
29137
|
+
productListOptions: options
|
|
29138
|
+
}
|
|
29139
|
+
);
|
|
29110
29140
|
if (!instance) {
|
|
29111
29141
|
return;
|
|
29112
29142
|
}
|
|
@@ -29136,7 +29166,7 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29136
29166
|
options: options.options
|
|
29137
29167
|
});
|
|
29138
29168
|
document.body.appendChild(host);
|
|
29139
|
-
const instance = createVue(manager, _sfc_main$1, {
|
|
29169
|
+
const instance = createVue(manager, mountOptions == null ? void 0 : mountOptions.mountingBehavior, _sfc_main$1, {
|
|
29140
29170
|
searchContainerOptions: options
|
|
29141
29171
|
});
|
|
29142
29172
|
if (!instance) {
|
|
@@ -29173,9 +29203,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29173
29203
|
}
|
|
29174
29204
|
return;
|
|
29175
29205
|
}
|
|
29176
|
-
const instance = createVue(
|
|
29177
|
-
|
|
29178
|
-
|
|
29206
|
+
const instance = createVue(
|
|
29207
|
+
options.containerSelector,
|
|
29208
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29209
|
+
_sfc_main,
|
|
29210
|
+
{
|
|
29211
|
+
recommendationOptions: options
|
|
29212
|
+
}
|
|
29213
|
+
);
|
|
29179
29214
|
if (!instance) {
|
|
29180
29215
|
return;
|
|
29181
29216
|
}
|
|
@@ -29193,9 +29228,14 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
|
29193
29228
|
}
|
|
29194
29229
|
return;
|
|
29195
29230
|
}
|
|
29196
|
-
const instance = createVue(
|
|
29197
|
-
options
|
|
29198
|
-
|
|
29231
|
+
const instance = createVue(
|
|
29232
|
+
options.displayOptions.containerSelector,
|
|
29233
|
+
mountOptions == null ? void 0 : mountOptions.mountingBehavior,
|
|
29234
|
+
_sfc_main$1o,
|
|
29235
|
+
{
|
|
29236
|
+
options
|
|
29237
|
+
}
|
|
29238
|
+
);
|
|
29199
29239
|
if (!instance) {
|
|
29200
29240
|
return;
|
|
29201
29241
|
}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,7 +2,8 @@ import type { Environment, SdkOptions, SortDirection, TrackingOptions, DocumentE
|
|
|
2
2
|
import { DocumentElementType, SearchBoxPanelType, BadgeType, SearchResultBadgeType } from '@getlupa/vue';
|
|
3
3
|
import { PreconfiguredSearchContainerOptions, SearchBoxDemoOptions, SearchDemoFields, SearchResultDemoOptions } from './types/PreconfiguredSearchContainerOptions';
|
|
4
4
|
type MountOptions = {
|
|
5
|
-
fetch
|
|
5
|
+
fetch?: boolean;
|
|
6
|
+
mountingBehavior?: 'replace' | 'append' | 'prepend';
|
|
6
7
|
};
|
|
7
8
|
declare const lupaSearch: {
|
|
8
9
|
searchBox: (options: SearchBoxOptions, mountOptions?: MountOptions) => void;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Component } from 'vue';
|
|
2
|
+
export declare const createVue: (selector: string | Element, mountingBehavior: string, rootComponent: Component, options: Record<string, unknown>, mountToParent?: boolean) => {
|
|
3
|
+
mountedApp: import("vue").ComponentPublicInstance<{}, {}, {}, {}, {}, {}, {}, {}, false, import("vue").ComponentOptionsBase<any, any, any, any, any, any, any, any, any, {}, {}, string, {}>, {}, {}>;
|
|
4
|
+
mountedComponent: any;
|
|
5
|
+
props: {
|
|
6
|
+
[x: string]: unknown;
|
|
7
|
+
};
|
|
8
|
+
app: import("vue").App<Element>;
|
|
9
|
+
mountElement: Element;
|
|
10
|
+
};
|