@sledge-app/react-instant-search 2.0.45 → 2.0.47
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/components/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/utils.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidget.d.ts.map +1 -1
- package/dist/sledge-react-instant-search.cjs +1 -1
- package/dist/sledge-react-instant-search.cjs.map +1 -1
- package/dist/sledge-react-instant-search.js +51 -101
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -4190,7 +4190,7 @@ const addToCartTrigger = async (data) => {
|
|
|
4190
4190
|
});
|
|
4191
4191
|
};
|
|
4192
4192
|
const VariantSelector = (props) => {
|
|
4193
|
-
var _a
|
|
4193
|
+
var _a;
|
|
4194
4194
|
const {
|
|
4195
4195
|
data,
|
|
4196
4196
|
setSelectedVariantId,
|
|
@@ -4201,7 +4201,6 @@ const VariantSelector = (props) => {
|
|
|
4201
4201
|
setSelectedVariantCompareAtPrice,
|
|
4202
4202
|
sourceApp,
|
|
4203
4203
|
instantSearchSettings,
|
|
4204
|
-
optionSelectedValue,
|
|
4205
4204
|
hasEntryImage
|
|
4206
4205
|
} = props;
|
|
4207
4206
|
const { product } = data || {};
|
|
@@ -4209,24 +4208,6 @@ const VariantSelector = (props) => {
|
|
|
4209
4208
|
const { id, handle, url } = product || {};
|
|
4210
4209
|
const options = (product == null ? void 0 : product.options) ? Object.entries(product.options) : [];
|
|
4211
4210
|
const images = (product == null ? void 0 : product.images) ?? [];
|
|
4212
|
-
const isSplitProducts = Boolean((_a = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _a.enable);
|
|
4213
|
-
const bySplitProducts = (_b = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _b.by;
|
|
4214
|
-
React__default.useEffect(() => {
|
|
4215
|
-
if (isSplitProducts && optionSelectedValue) {
|
|
4216
|
-
const productCardElement = document.querySelector(`.sledge__product-grid-card[data-product-id="${id}"][data-option-selected-value="${encodeURIComponent(optionSelectedValue)}"]`);
|
|
4217
|
-
if (productCardElement) {
|
|
4218
|
-
const variantColorSwatch = productCardElement.querySelector(`.sledge__product-variant-color-swatch[data-option-value="${encodeURIComponent(optionSelectedValue)}"]`);
|
|
4219
|
-
if (variantColorSwatch) {
|
|
4220
|
-
variantColorSwatch.dispatchEvent(new Event("click", { bubbles: true }));
|
|
4221
|
-
}
|
|
4222
|
-
const variantSelectOption = productCardElement.querySelector(`.sledge__product-variant-size-swatch-select[data-option-name="${bySplitProducts}"]`);
|
|
4223
|
-
if (variantSelectOption) {
|
|
4224
|
-
variantSelectOption.value = optionSelectedValue;
|
|
4225
|
-
variantSelectOption.dispatchEvent(new Event("change", { bubbles: true }));
|
|
4226
|
-
}
|
|
4227
|
-
}
|
|
4228
|
-
}
|
|
4229
|
-
}, [hasEntryImage]);
|
|
4230
4211
|
const defaultSelected = {};
|
|
4231
4212
|
function setDefaultFunction() {
|
|
4232
4213
|
if (!(variants == null ? void 0 : variants.length))
|
|
@@ -4274,7 +4255,7 @@ const VariantSelector = (props) => {
|
|
|
4274
4255
|
}
|
|
4275
4256
|
}
|
|
4276
4257
|
function setSelectedVariant(element, value, optionIndex) {
|
|
4277
|
-
var _a2,
|
|
4258
|
+
var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4278
4259
|
const parentCard = element.target.offsetParent;
|
|
4279
4260
|
const selectedInput = parentCard.querySelector(`.sledge__product-grid-card-selected-option[data-product-id='${id}']`);
|
|
4280
4261
|
setElementAttribute({
|
|
@@ -4282,8 +4263,8 @@ const VariantSelector = (props) => {
|
|
|
4282
4263
|
attributeName: `data-selected-option${optionIndex}`,
|
|
4283
4264
|
value
|
|
4284
4265
|
});
|
|
4285
|
-
const option1 = `[data-option-1="${stringToSlug((
|
|
4286
|
-
const option2 = `${((
|
|
4266
|
+
const option1 = `[data-option-1="${stringToSlug((_b = (_a2 = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _a2["data-selected-option1"]) == null ? void 0 : _b.value)}"]`;
|
|
4267
|
+
const option2 = `${((_c = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _c["data-selected-option2"]) ? `[data-option-2="${stringToSlug((_e = (_d = selectedInput == null ? void 0 : selectedInput.attributes) == null ? void 0 : _d["data-selected-option2"]) == null ? void 0 : _e.value)}"]` : ""}`;
|
|
4287
4268
|
const selectOption = parentCard.querySelector(`select option${option1}${option2}`);
|
|
4288
4269
|
const variantId = selectOption.attributes["data-graphql-id"].value;
|
|
4289
4270
|
const imageId = (_f = selectOption.attributes["data-image-id"]) == null ? void 0 : _f.value;
|
|
@@ -4301,11 +4282,11 @@ const VariantSelector = (props) => {
|
|
|
4301
4282
|
}
|
|
4302
4283
|
});
|
|
4303
4284
|
const setOther = () => {
|
|
4304
|
-
var _a3,
|
|
4285
|
+
var _a3, _b2;
|
|
4305
4286
|
setElementAttribute({
|
|
4306
4287
|
element: selectedInput,
|
|
4307
4288
|
attributeName: "data-variant-id",
|
|
4308
|
-
value: ((
|
|
4289
|
+
value: ((_b2 = (_a3 = selectOption == null ? void 0 : selectOption.attributes) == null ? void 0 : _a3["data-graphql-id"]) == null ? void 0 : _b2.value) || ""
|
|
4309
4290
|
});
|
|
4310
4291
|
setElementAttribute({
|
|
4311
4292
|
element: selectedInput,
|
|
@@ -4377,7 +4358,7 @@ const VariantSelector = (props) => {
|
|
|
4377
4358
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("option", { ...optionAttributes, children: title }, id2);
|
|
4378
4359
|
}) }),
|
|
4379
4360
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: images == null ? void 0 : images.map((image) => /* @__PURE__ */ jsxRuntimeExports.jsx("input", { type: "hidden", id: image == null ? void 0 : image.id, value: image == null ? void 0 : image.src }, image == null ? void 0 : image.id)) }),
|
|
4380
|
-
(
|
|
4361
|
+
(_a = options == null ? void 0 : options.map) == null ? void 0 : _a.call(options, (option, optionParentIndex) => {
|
|
4381
4362
|
var _a2;
|
|
4382
4363
|
const optionName = option[0];
|
|
4383
4364
|
const optionValues = option[1];
|
|
@@ -4453,7 +4434,7 @@ ${selectedOption === item ? "sledge__product-variant-size-swatch-active" : ""} s
|
|
|
4453
4434
|
] });
|
|
4454
4435
|
};
|
|
4455
4436
|
const ProductCard = React__default.memo((props) => {
|
|
4456
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
4437
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
4457
4438
|
const {
|
|
4458
4439
|
item,
|
|
4459
4440
|
handleAddToCart,
|
|
@@ -4474,7 +4455,6 @@ const ProductCard = React__default.memo((props) => {
|
|
|
4474
4455
|
previewSettings,
|
|
4475
4456
|
isFlyout,
|
|
4476
4457
|
instantSearchSettings,
|
|
4477
|
-
optionSelectedValue,
|
|
4478
4458
|
additionalCardProps,
|
|
4479
4459
|
keyword
|
|
4480
4460
|
} = props;
|
|
@@ -4528,6 +4508,14 @@ const ProductCard = React__default.memo((props) => {
|
|
|
4528
4508
|
sku = ""
|
|
4529
4509
|
} = (variants == null ? void 0 : variants.length) ? variants[0] : {};
|
|
4530
4510
|
const productUrl = `${url}?variant=${(_a = variants == null ? void 0 : variants[0]) == null ? void 0 : _a.id}`;
|
|
4511
|
+
const isSplitProducts = Boolean((_b = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _b.enable);
|
|
4512
|
+
const bySplitProducts = (_c = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _c.by;
|
|
4513
|
+
let optionSelectedValue = "";
|
|
4514
|
+
if (isSplitProducts && bySplitProducts) {
|
|
4515
|
+
const optionFirst = (_d = product == null ? void 0 : product.options) == null ? void 0 : _d[bySplitProducts];
|
|
4516
|
+
const optionFirstValue = (optionFirst == null ? void 0 : optionFirst.length) ? optionFirst == null ? void 0 : optionFirst[0] : "";
|
|
4517
|
+
optionSelectedValue = optionFirstValue;
|
|
4518
|
+
}
|
|
4531
4519
|
const defaultSelectedVariantId = variant_admin_graphql_api_id ? variant_admin_graphql_api_id : "";
|
|
4532
4520
|
const defaultSelectedVariantStock = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_quantity") ? variants[0].inventory_quantity : 0;
|
|
4533
4521
|
const defaultSelectedVariantInventoryManagement = (variants == null ? void 0 : variants.length) && Object.hasOwn(variants[0], "inventory_management") ? variants[0].inventory_management : null;
|
|
@@ -4572,8 +4560,8 @@ const ProductCard = React__default.memo((props) => {
|
|
|
4572
4560
|
},
|
|
4573
4561
|
...dataReviews && Object.keys(dataReviews).length ? {
|
|
4574
4562
|
review: {
|
|
4575
|
-
total: ((
|
|
4576
|
-
average: ((
|
|
4563
|
+
total: ((_e = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _e.review_count) ? dataReviews == null ? void 0 : dataReviews[id].review_count : 0,
|
|
4564
|
+
average: ((_g = (_f = dataReviews == null ? void 0 : dataReviews[id]) == null ? void 0 : _f.rating) == null ? void 0 : _g.average) ? dataReviews == null ? void 0 : dataReviews[id].rating.average : 0
|
|
4577
4565
|
}
|
|
4578
4566
|
} : {}
|
|
4579
4567
|
},
|
|
@@ -4754,7 +4742,7 @@ const ProductCard = React__default.memo((props) => {
|
|
|
4754
4742
|
onAfterAddWishlist,
|
|
4755
4743
|
onAfterRemoveWishlist,
|
|
4756
4744
|
wishlistChecked: dataWishlists == null ? void 0 : dataWishlists[id],
|
|
4757
|
-
...objectPresent(previewSettings) && ((
|
|
4745
|
+
...objectPresent(previewSettings) && ((_i = (_h = previewSettings == null ? void 0 : previewSettings.settings) == null ? void 0 : _h.general) == null ? void 0 : _i.use_dummy_data) ? {
|
|
4758
4746
|
previewSettings
|
|
4759
4747
|
} : {}
|
|
4760
4748
|
}
|
|
@@ -4790,7 +4778,7 @@ const ProductCard = React__default.memo((props) => {
|
|
|
4790
4778
|
}
|
|
4791
4779
|
)
|
|
4792
4780
|
] }),
|
|
4793
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: (
|
|
4781
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__product-grid-card-variant-images", children: (_k = (_j = product == null ? void 0 : product.images) == null ? void 0 : _j.map) == null ? void 0 : _k.call(_j, (image2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4794
4782
|
"img",
|
|
4795
4783
|
{
|
|
4796
4784
|
decoding: "async",
|
|
@@ -5034,9 +5022,6 @@ const ProductGrid = React__default.memo((props) => {
|
|
|
5034
5022
|
"data-custom-card": Boolean(props == null ? void 0 : props.cards),
|
|
5035
5023
|
"data-flyout": isFlyout,
|
|
5036
5024
|
children: data == null ? void 0 : data.map((item, index) => {
|
|
5037
|
-
var _a, _b, _c;
|
|
5038
|
-
const isSplitProducts = Boolean((_a = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _a.enable);
|
|
5039
|
-
const bySplitProducts = (_b = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _b.by;
|
|
5040
5025
|
const productCardProps = {
|
|
5041
5026
|
item,
|
|
5042
5027
|
handleAddToCart,
|
|
@@ -5047,9 +5032,6 @@ const ProductGrid = React__default.memo((props) => {
|
|
|
5047
5032
|
forLoopIndexWithPage: Number(currentPage) && Number(hitsPerPage) ? index + (Number(currentPage) - 1) * Number(hitsPerPage) : index
|
|
5048
5033
|
},
|
|
5049
5034
|
instantSearchSettings,
|
|
5050
|
-
...isSplitProducts && bySplitProducts ? {
|
|
5051
|
-
optionSelectedValue: (_c = item == null ? void 0 : item.product) == null ? void 0 : _c.optionSelectedValue
|
|
5052
|
-
} : {},
|
|
5053
5035
|
...props
|
|
5054
5036
|
};
|
|
5055
5037
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(ProductCard, { ...productCardProps }, `sledge-product-card_${index}`);
|
|
@@ -6018,7 +6000,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
6018
6000
|
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_g2 = valueSearchResultProduct[0]) == null ? void 0 : _g2.hits : [];
|
|
6019
6001
|
let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
|
|
6020
6002
|
let isPriorityZeroCharacter = Boolean(
|
|
6021
|
-
!keyword.length && Object.keys(suggestion).length && ((_i2 = (_h2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _h2.products) == null ? void 0 : _i2.active) && ((_l2 = (_k2 = (_j2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _j2.products) == null ? void 0 : _k2.list) == null ? void 0 : _l2.length)
|
|
6003
|
+
!keyword.length && suggestion && Object.keys(suggestion).length && ((_i2 = (_h2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _h2.products) == null ? void 0 : _i2.active) && ((_l2 = (_k2 = (_j2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _j2.products) == null ? void 0 : _k2.list) == null ? void 0 : _l2.length)
|
|
6022
6004
|
);
|
|
6023
6005
|
let dataSearchResultProduct = isPriorityZeroCharacter ? (_n2 = (_m2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _m2.products) == null ? void 0 : _n2.list : getValueSearchResultProduct;
|
|
6024
6006
|
if (withFetchReviewInfo) {
|
|
@@ -6201,7 +6183,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
6201
6183
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex-item-product", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 6, type: "medium" }) })
|
|
6202
6184
|
] }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex", children: [
|
|
6203
6185
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-flex-item-other", children: [
|
|
6204
|
-
Object.keys(suggestionSettings).length && ((_d = (_c = suggestionSettings[suggestionIndex]) == null ? void 0 : _c.keywords) == null ? void 0 : _d.active) && ((_g = (_f = (_e = suggestionSettings[suggestionIndex]) == null ? void 0 : _e.keywords) == null ? void 0 : _f.list) == null ? void 0 : _g.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6186
|
+
suggestionSettings && Object.keys(suggestionSettings).length && ((_d = (_c = suggestionSettings[suggestionIndex]) == null ? void 0 : _c.keywords) == null ? void 0 : _d.active) && ((_g = (_f = (_e = suggestionSettings[suggestionIndex]) == null ? void 0 : _e.keywords) == null ? void 0 : _f.list) == null ? void 0 : _g.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6205
6187
|
Global.SuggestionKeywordLists,
|
|
6206
6188
|
{
|
|
6207
6189
|
listsComponent: handleFunctions.suggestionKeywordListsComponent,
|
|
@@ -6262,7 +6244,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
6262
6244
|
dataReviews,
|
|
6263
6245
|
previewSettings: handleFunctions == null ? void 0 : handleFunctions.previewSettings
|
|
6264
6246
|
}
|
|
6265
|
-
) }) : Object.keys(suggestionSettings).length && ((_l = (_k = suggestionSettings[suggestionIndex]) == null ? void 0 : _k.products) == null ? void 0 : _l.active) && ((_o = (_n = (_m = suggestionSettings[suggestionIndex]) == null ? void 0 : _m.products) == null ? void 0 : _n.list) == null ? void 0 : _o.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6247
|
+
) }) : suggestionSettings && Object.keys(suggestionSettings).length && ((_l = (_k = suggestionSettings[suggestionIndex]) == null ? void 0 : _k.products) == null ? void 0 : _l.active) && ((_o = (_n = (_m = suggestionSettings[suggestionIndex]) == null ? void 0 : _m.products) == null ? void 0 : _n.list) == null ? void 0 : _o.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
6266
6248
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__icon-widget-search-form-result-product-suggestion-no-result-text", children: [
|
|
6267
6249
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Sorry" }),
|
|
6268
6250
|
", nothing found for ",
|
|
@@ -6304,7 +6286,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
6304
6286
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-title", children: (languageSettings == null ? void 0 : languageSettings.product) || "Products" }),
|
|
6305
6287
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-search-form-result-item-disabled", children: (languageSettings == null ? void 0 : languageSettings.text_no_result) || "No product were found" })
|
|
6306
6288
|
] }),
|
|
6307
|
-
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.active) && ((_w = (_v = (_u = suggestionSettings[suggestionIndex]) == null ? void 0 : _u.products) == null ? void 0 : _v.list) == null ? void 0 : _w.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6289
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) || suggestionSettings && Object.keys(suggestionSettings).length && ((_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.active) && ((_w = (_v = (_u = suggestionSettings[suggestionIndex]) == null ? void 0 : _u.products) == null ? void 0 : _v.list) == null ? void 0 : _w.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__icon-widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6308
6290
|
Global.SearchViewMoreResult,
|
|
6309
6291
|
{
|
|
6310
6292
|
component: handleFunctions.searchViewMoreResultComponent,
|
|
@@ -6586,13 +6568,15 @@ const createHierarchicalFacet = ({
|
|
|
6586
6568
|
let isHideFacetWhenZeroValue = (_b = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b.hide_when_zero_value;
|
|
6587
6569
|
if (isHideFacetWhenZeroValue) {
|
|
6588
6570
|
let filteredFacets = (searchFacetDistribution == null ? void 0 : searchFacetDistribution[`${indexValue}.lvl${level}`]) || {};
|
|
6589
|
-
|
|
6590
|
-
|
|
6591
|
-
|
|
6592
|
-
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
|
|
6571
|
+
if (filteredFacets && Object.keys(filteredFacets).length) {
|
|
6572
|
+
facets = Object.keys(filteredFacets).map((item) => {
|
|
6573
|
+
return {
|
|
6574
|
+
name: item,
|
|
6575
|
+
value: item,
|
|
6576
|
+
total: filteredFacets[item] || 0
|
|
6577
|
+
};
|
|
6578
|
+
});
|
|
6579
|
+
}
|
|
6596
6580
|
}
|
|
6597
6581
|
if (!facets || facets && !Object.keys(facets).length)
|
|
6598
6582
|
continue;
|
|
@@ -9425,13 +9409,15 @@ const SearchResultWidget = (props) => {
|
|
|
9425
9409
|
}
|
|
9426
9410
|
];
|
|
9427
9411
|
} else {
|
|
9428
|
-
|
|
9429
|
-
|
|
9430
|
-
|
|
9431
|
-
|
|
9432
|
-
|
|
9433
|
-
|
|
9434
|
-
|
|
9412
|
+
if ((facetDistribution == null ? void 0 : facetDistribution[value]) && Object.keys(facetDistribution[value]).length) {
|
|
9413
|
+
items = Object.keys(facetDistribution[value]).map((item) => {
|
|
9414
|
+
return {
|
|
9415
|
+
name: item,
|
|
9416
|
+
value: item,
|
|
9417
|
+
total: facetDistribution[value][item] || 0
|
|
9418
|
+
};
|
|
9419
|
+
});
|
|
9420
|
+
}
|
|
9435
9421
|
}
|
|
9436
9422
|
return [value, items];
|
|
9437
9423
|
})
|
|
@@ -9600,7 +9586,7 @@ const SearchResultWidget = (props) => {
|
|
|
9600
9586
|
setTabs(tabs2);
|
|
9601
9587
|
if (!clickedTabIndexId) {
|
|
9602
9588
|
getFirstIndex = (_f2 = tabs2 == null ? void 0 : tabs2.find) == null ? void 0 : _f2.call(tabs2, ({ index }) => index.includes(index_product));
|
|
9603
|
-
if (Object.keys(getFirstIndex).length) {
|
|
9589
|
+
if (getFirstIndex && Object.keys(getFirstIndex).length) {
|
|
9604
9590
|
setClickedTabIndexId(getFirstIndex.index);
|
|
9605
9591
|
setClickedTabIndexName(getFirstIndex.name);
|
|
9606
9592
|
setClickedTabIndexType(getFirstIndex.type);
|
|
@@ -10422,7 +10408,7 @@ const ResultProduct = React__default.memo((props) => {
|
|
|
10422
10408
|
return dataClickedFacets2;
|
|
10423
10409
|
};
|
|
10424
10410
|
const handleSearchResultData = async (props2) => {
|
|
10425
|
-
var _a2, _b2
|
|
10411
|
+
var _a2, _b2;
|
|
10426
10412
|
const { isLoadMore: isLoadMore2 = false, result: resultProp, onSearch } = props2;
|
|
10427
10413
|
const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
|
|
10428
10414
|
const { index_product } = INSTANT_SEARCH_SETTING || {};
|
|
@@ -10432,54 +10418,18 @@ const ResultProduct = React__default.memo((props) => {
|
|
|
10432
10418
|
const result = layoutType === "default" && isFirstTimeOrOnSearch ? (_b2 = resultData == null ? void 0 : resultData.find) == null ? void 0 : _b2.call(resultData, ({ indexUid }) => indexUid.includes(index_product)) : resultData;
|
|
10433
10419
|
if (!result)
|
|
10434
10420
|
return;
|
|
10435
|
-
const { hits
|
|
10436
|
-
const isSplitProducts = Boolean((_c2 = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _c2.enable);
|
|
10437
|
-
const bySplitProducts = (_d2 = instantSearchSettings == null ? void 0 : instantSearchSettings.split_products) == null ? void 0 : _d2.by;
|
|
10438
|
-
const searchParams2 = new URLSearchParams(document.location.search);
|
|
10439
|
-
const searchParamsObject = Object.fromEntries(searchParams2);
|
|
10440
|
-
let hits = hitsResult;
|
|
10441
|
-
if (isSplitProducts && bySplitProducts && (hits == null ? void 0 : hits.length)) {
|
|
10442
|
-
let newHits = [];
|
|
10443
|
-
hits.map((item) => {
|
|
10444
|
-
var _a3;
|
|
10445
|
-
const optionFirst = isSplitProducts && bySplitProducts ? (_a3 = item == null ? void 0 : item.options) == null ? void 0 : _a3[bySplitProducts] : [];
|
|
10446
|
-
const optionFirstValues = (optionFirst == null ? void 0 : optionFirst.length) ? optionFirst : [];
|
|
10447
|
-
if (isSplitProducts && (optionFirstValues == null ? void 0 : optionFirstValues.length)) {
|
|
10448
|
-
optionFirstValues.map((optionFirstValue, indexFirstValue) => {
|
|
10449
|
-
newHits.push({
|
|
10450
|
-
...item,
|
|
10451
|
-
optionSelectedValue: optionFirstValue
|
|
10452
|
-
});
|
|
10453
|
-
});
|
|
10454
|
-
} else {
|
|
10455
|
-
newHits.push(item);
|
|
10456
|
-
}
|
|
10457
|
-
});
|
|
10458
|
-
if (newHits == null ? void 0 : newHits.length) {
|
|
10459
|
-
hits = newHits.filter((item) => {
|
|
10460
|
-
var _a3, _b3, _c3, _d3, _e2;
|
|
10461
|
-
const { optionSelectedValue } = item || {};
|
|
10462
|
-
const optionsFiltered = bySplitProducts ? (_d3 = (_c3 = (_b3 = (_a3 = searchParamsObject == null ? void 0 : searchParamsObject[`options.${bySplitProducts}`]) == null ? void 0 : _a3.split) == null ? void 0 : _b3.call(_a3, ",")) == null ? void 0 : _c3.map) == null ? void 0 : _d3.call(_c3, (item2) => decodeURIComponent(item2)) : [];
|
|
10463
|
-
const hasOptionsFiltered = optionsFiltered && (optionsFiltered == null ? void 0 : optionsFiltered.length) ? !((_e2 = optionsFiltered == null ? void 0 : optionsFiltered.includes) == null ? void 0 : _e2.call(optionsFiltered, optionSelectedValue)) : false;
|
|
10464
|
-
const isOptionNotContainsKeyword = (queryResult == null ? void 0 : queryResult.length) ? !(optionSelectedValue == null ? void 0 : optionSelectedValue.length) ? true : !optionSelectedValue.toLowerCase().includes(queryResult.toLowerCase()) : false;
|
|
10465
|
-
if (isSplitProducts && (hasOptionsFiltered || isOptionNotContainsKeyword)) {
|
|
10466
|
-
return false;
|
|
10467
|
-
}
|
|
10468
|
-
return true;
|
|
10469
|
-
});
|
|
10470
|
-
}
|
|
10471
|
-
}
|
|
10421
|
+
const { hits, hitsPerPage, processingTimeMs, totalHits, totalPages, facetDistribution, query: queryResult } = result;
|
|
10472
10422
|
const updateTabs = () => {
|
|
10473
10423
|
const valueAllowedTabs = objectPresent(previewSettings) ? tabs : allowedTabs;
|
|
10474
10424
|
if (valueAllowedTabs == null ? void 0 : valueAllowedTabs.length) {
|
|
10475
10425
|
setAllowedTabs == null ? void 0 : setAllowedTabs(
|
|
10476
10426
|
valueAllowedTabs.map((tab) => {
|
|
10477
|
-
var _a3, _b3,
|
|
10427
|
+
var _a3, _b3, _c2;
|
|
10478
10428
|
const { index, total } = tab;
|
|
10479
10429
|
let isCurrentIndex = index.includes(clickedTabIndexId);
|
|
10480
10430
|
let tabTotal = isCurrentIndex ? totalHits : total;
|
|
10481
10431
|
if (layoutType === "default" && ((_a3 = resultProp == null ? void 0 : resultProp.results) == null ? void 0 : _a3.length)) {
|
|
10482
|
-
const { totalHits: totalHits2 } = (
|
|
10432
|
+
const { totalHits: totalHits2 } = (_c2 = (_b3 = resultProp == null ? void 0 : resultProp.results) == null ? void 0 : _b3.find) == null ? void 0 : _c2.call(_b3, ({ indexUid }) => indexUid.includes(index));
|
|
10483
10433
|
tabTotal = totalHits2 || tabTotal;
|
|
10484
10434
|
}
|
|
10485
10435
|
return {
|
|
@@ -11452,7 +11402,7 @@ const SearchWidget = (props) => {
|
|
|
11452
11402
|
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_f2 = valueSearchResultProduct[0]) == null ? void 0 : _f2.hits : [];
|
|
11453
11403
|
let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
|
|
11454
11404
|
let isPriorityZeroCharacter = Boolean(
|
|
11455
|
-
!keyword.length && Object.keys(suggestion).length && ((_h2 = (_g2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _g2.products) == null ? void 0 : _h2.active) && ((_k2 = (_j2 = (_i2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _i2.products) == null ? void 0 : _j2.list) == null ? void 0 : _k2.length)
|
|
11405
|
+
!keyword.length && suggestion && Object.keys(suggestion).length && ((_h2 = (_g2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _g2.products) == null ? void 0 : _h2.active) && ((_k2 = (_j2 = (_i2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _i2.products) == null ? void 0 : _j2.list) == null ? void 0 : _k2.length)
|
|
11456
11406
|
);
|
|
11457
11407
|
setSearchResultProduct(isPriorityZeroCharacter ? (_m2 = (_l2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _l2.products) == null ? void 0 : _m2.list : getValueSearchResultProduct);
|
|
11458
11408
|
setSearchResultOther(valueSearchResultOther);
|
|
@@ -11574,7 +11524,7 @@ const SearchWidget = (props) => {
|
|
|
11574
11524
|
] }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { isLoading, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
11575
11525
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex", children: [
|
|
11576
11526
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-flex-item-other", children: [
|
|
11577
|
-
Object.keys(suggestionSettings).length && ((_d = (_c = suggestionSettings[suggestionIndex]) == null ? void 0 : _c.keywords) == null ? void 0 : _d.active) && ((_g = (_f = (_e = suggestionSettings[suggestionIndex]) == null ? void 0 : _e.keywords) == null ? void 0 : _f.list) == null ? void 0 : _g.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11527
|
+
suggestionSettings && Object.keys(suggestionSettings).length && ((_d = (_c = suggestionSettings[suggestionIndex]) == null ? void 0 : _c.keywords) == null ? void 0 : _d.active) && ((_g = (_f = (_e = suggestionSettings[suggestionIndex]) == null ? void 0 : _e.keywords) == null ? void 0 : _f.list) == null ? void 0 : _g.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11578
11528
|
Global.SuggestionKeywordLists,
|
|
11579
11529
|
{
|
|
11580
11530
|
listsComponent: suggestionKeywordListsComponent,
|
|
@@ -11628,7 +11578,7 @@ const SearchWidget = (props) => {
|
|
|
11628
11578
|
onAfterRemoveWishlist,
|
|
11629
11579
|
onAfterRenderProduct
|
|
11630
11580
|
}
|
|
11631
|
-
) }) : Object.keys(suggestionSettings).length && ((_l = (_k = suggestionSettings[suggestionIndex]) == null ? void 0 : _k.products) == null ? void 0 : _l.active) && ((_o = (_n = (_m = suggestionSettings[suggestionIndex]) == null ? void 0 : _m.products) == null ? void 0 : _n.list) == null ? void 0 : _o.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
11581
|
+
) }) : suggestionSettings && Object.keys(suggestionSettings).length && ((_l = (_k = suggestionSettings[suggestionIndex]) == null ? void 0 : _k.products) == null ? void 0 : _l.active) && ((_o = (_n = (_m = suggestionSettings[suggestionIndex]) == null ? void 0 : _m.products) == null ? void 0 : _n.list) == null ? void 0 : _o.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
11632
11582
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__widget-search-form-result-product-suggestion-no-result-text", children: [
|
|
11633
11583
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Sorry, nothing found for" }),
|
|
11634
11584
|
" ",
|
|
@@ -11667,7 +11617,7 @@ const SearchWidget = (props) => {
|
|
|
11667
11617
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-product-disabled", children: (languageSettings == null ? void 0 : languageSettings.text_no_result) || "No product were found" })
|
|
11668
11618
|
] })
|
|
11669
11619
|
] }),
|
|
11670
|
-
(searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.active) && ((_w = (_v = (_u = suggestionSettings[suggestionIndex]) == null ? void 0 : _u.products) == null ? void 0 : _v.list) == null ? void 0 : _w.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11620
|
+
(searchResultProduct == null ? void 0 : searchResultProduct.length) || suggestionSettings && Object.keys(suggestionSettings).length && ((_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.active) && ((_w = (_v = (_u = suggestionSettings[suggestionIndex]) == null ? void 0 : _u.products) == null ? void 0 : _v.list) == null ? void 0 : _w.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
11671
11621
|
Global.SearchViewMoreResult,
|
|
11672
11622
|
{
|
|
11673
11623
|
component: searchViewMoreResultComponent,
|