@sledge-app/react-instant-search 2.0.17 → 2.0.19
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/SearchResultWidget/SearchResultWidget.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/components/Facet.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/components/FilterHorizontal.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 +79 -45
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1145,7 +1145,7 @@ const RadioGroup = ({ id, name, required, value, items, labelStyle = {}, onValue
|
|
|
1145
1145
|
) }) }) });
|
|
1146
1146
|
};
|
|
1147
1147
|
const ColorSwatch$1 = "";
|
|
1148
|
-
const ColorSwatch = ({ id, name, value, rgb, image, required, checked, onClick }) => {
|
|
1148
|
+
const ColorSwatch = ({ id, name, value, rgb, image, required, checked, onClick, labelType = "tooltip", label, labelStyle = {} }) => {
|
|
1149
1149
|
const styles = {
|
|
1150
1150
|
...(image == null ? void 0 : image.length) ? {
|
|
1151
1151
|
backgroundImage: `url("${image}")`,
|
|
@@ -1154,27 +1154,19 @@ const ColorSwatch = ({ id, name, value, rgb, image, required, checked, onClick }
|
|
|
1154
1154
|
backgroundColor: rgb
|
|
1155
1155
|
}
|
|
1156
1156
|
};
|
|
1157
|
-
|
|
1157
|
+
const colorSwatchComponent = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge__color-swatch-wrapper", children: [
|
|
1158
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($e698a72e93240346$export$be92b6f5f03c0fe9, { className: "sledge__color-swatch-root", checked, id, name, value, required, onClick, style: styles }),
|
|
1159
|
+
labelType === "text" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: label && /* @__PURE__ */ jsxRuntimeExports.jsx("label", { className: "sledge__color-swatch-label", htmlFor: id, style: labelStyle, children: label }) }) : null
|
|
1160
|
+
] });
|
|
1161
|
+
return labelType === "tooltip" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1158
1162
|
Tooltip,
|
|
1159
1163
|
{
|
|
1160
1164
|
content: value,
|
|
1161
1165
|
customArrow: `<svg width="19" height="5" viewBox="0 0 19 5" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M9 4.99998C9 9.48298e-05 16.4996 1.99678e-05 18.4999 0L9 2.2985e-06L0.5 2.04891e-06C9 2.2985e-06 9 4.99998 9 4.99998Z" fill="#43c6ac"/></svg>`,
|
|
1162
1166
|
wrapTrigger: false,
|
|
1163
|
-
children:
|
|
1164
|
-
$e698a72e93240346$export$be92b6f5f03c0fe9,
|
|
1165
|
-
{
|
|
1166
|
-
className: "sledge__color-swatch-root",
|
|
1167
|
-
checked,
|
|
1168
|
-
id,
|
|
1169
|
-
name,
|
|
1170
|
-
value,
|
|
1171
|
-
required,
|
|
1172
|
-
onClick,
|
|
1173
|
-
style: styles
|
|
1174
|
-
}
|
|
1175
|
-
) })
|
|
1167
|
+
children: colorSwatchComponent
|
|
1176
1168
|
}
|
|
1177
|
-
);
|
|
1169
|
+
) : colorSwatchComponent;
|
|
1178
1170
|
};
|
|
1179
1171
|
const Select$1 = "";
|
|
1180
1172
|
const Select = ({ name, placeholder, required, defaultValue, items, labelStyle = {}, onValueChange, useLoadMore = false, loadMoreText = "Load More" }) => {
|
|
@@ -7227,7 +7219,8 @@ const FilterItem = (props) => {
|
|
|
7227
7219
|
allowedFilter = [],
|
|
7228
7220
|
layoutType,
|
|
7229
7221
|
collectionId,
|
|
7230
|
-
isHorizontalGroup = false
|
|
7222
|
+
isHorizontalGroup = false,
|
|
7223
|
+
renderedCount = 0
|
|
7231
7224
|
} = props;
|
|
7232
7225
|
const { value, label } = filter;
|
|
7233
7226
|
const filterItemId = `filter-${indexFilter}-${layoutType}-${collectionId || "all"}-${deviceType}-${stringToSlug(value)}`;
|
|
@@ -7255,7 +7248,7 @@ const FilterItem = (props) => {
|
|
|
7255
7248
|
setClickedOpenFilterHorizontalId == null ? void 0 : setClickedOpenFilterHorizontalId(valueOpenFilterHorizontal);
|
|
7256
7249
|
}
|
|
7257
7250
|
},
|
|
7258
|
-
className: isHorizontalGroup ? "sledge-instant-search__result-filter-trigger-horizontal-group" : `${isLastIndex ?
|
|
7251
|
+
className: isHorizontalGroup ? "sledge-instant-search__result-filter-trigger-horizontal-group" : `${isLastIndex ? renderedCount % 2 ? "sledge-instant-search__result-filter-trigger-odd" : "sledge-instant-search__result-filter-trigger-even" : ""}`,
|
|
7259
7252
|
style: filterTitleStyle,
|
|
7260
7253
|
children: [
|
|
7261
7254
|
label,
|
|
@@ -7351,9 +7344,21 @@ const FilterHorizontal = (props) => {
|
|
|
7351
7344
|
isHorizontalGroup = false,
|
|
7352
7345
|
allowedFilterSlider
|
|
7353
7346
|
} = props;
|
|
7347
|
+
const [renderedCount, setRenderedCount] = React__default.useState(0);
|
|
7348
|
+
React__default.useEffect(() => {
|
|
7349
|
+
const countRenderedComponents = () => {
|
|
7350
|
+
const renderedComponents = document.querySelectorAll(".sledge-instant-search__result-filter-horizontal.sledge-instant-search__result-filter-horizontal-component .sledge__button");
|
|
7351
|
+
setRenderedCount(renderedComponents.length);
|
|
7352
|
+
};
|
|
7353
|
+
const timer = setTimeout(countRenderedComponents, 0);
|
|
7354
|
+
return () => clearTimeout(timer);
|
|
7355
|
+
}, [items]);
|
|
7354
7356
|
const { sort = null, limit = null } = components;
|
|
7355
7357
|
const wrapperAdditionalProps = {
|
|
7356
|
-
...isHorizontalGroup && { "horizontal-group": "" }
|
|
7358
|
+
...isHorizontalGroup && { "horizontal-group": "" },
|
|
7359
|
+
...{
|
|
7360
|
+
[renderedCount % 2 ? "odd-items" : "even-items"]: ""
|
|
7361
|
+
}
|
|
7357
7362
|
};
|
|
7358
7363
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isSkeleton ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-skeleton", ...wrapperAdditionalProps, children: [1, 2, 3, 4, 5, 6, 7].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "106px", height: "42px", rounded: "md", color: "lighten" }, index)) }) : (items == null ? void 0 : items.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal-wrapper", ...wrapperAdditionalProps, children: [
|
|
7359
7364
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -7376,7 +7381,8 @@ const FilterHorizontal = (props) => {
|
|
|
7376
7381
|
allowedFilter: items,
|
|
7377
7382
|
layoutType,
|
|
7378
7383
|
collectionId,
|
|
7379
|
-
isHorizontalGroup
|
|
7384
|
+
isHorizontalGroup,
|
|
7385
|
+
renderedCount
|
|
7380
7386
|
}
|
|
7381
7387
|
)),
|
|
7382
7388
|
sort ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-sort", children: sort }) : null,
|
|
@@ -7539,6 +7545,7 @@ const Facet = (props) => {
|
|
|
7539
7545
|
let blockComponent = null;
|
|
7540
7546
|
const isShowNumberMatchingProduct = (_b = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b.show_number_matching_product;
|
|
7541
7547
|
const isDisplaySlider = ["slider", "input_range", "slider_with_input_range"].includes(display.toLowerCase());
|
|
7548
|
+
const isDisplayColorSwatch = ["swatch", "swatch_with_label"].includes(display.toLowerCase());
|
|
7542
7549
|
const isDisplayInputRange = display.toLowerCase() === "input_range";
|
|
7543
7550
|
const getValue = `${value}-${indexFilter}`;
|
|
7544
7551
|
if (show_search && keywordFacet && !isDisplaySlider)
|
|
@@ -7718,6 +7725,30 @@ const Facet = (props) => {
|
|
|
7718
7725
|
] });
|
|
7719
7726
|
});
|
|
7720
7727
|
};
|
|
7728
|
+
const colorSwatchComponent = ({ item = {}, index }) => {
|
|
7729
|
+
var _a2;
|
|
7730
|
+
let getColorSwatch = (colorSwatches == null ? void 0 : colorSwatches.filter(({ name }) => name == null ? void 0 : name.includes(item == null ? void 0 : item.value))[0]) || {};
|
|
7731
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7732
|
+
ColorSwatch,
|
|
7733
|
+
{
|
|
7734
|
+
id: `${getValue}_${index}`,
|
|
7735
|
+
name: value,
|
|
7736
|
+
value: item == null ? void 0 : item.value,
|
|
7737
|
+
rgb: getColorSwatch == null ? void 0 : getColorSwatch.rgb,
|
|
7738
|
+
image: getColorSwatch == null ? void 0 : getColorSwatch.image,
|
|
7739
|
+
onClick: (e) => handleFilterChange({
|
|
7740
|
+
parentId: value,
|
|
7741
|
+
value: e.currentTarget.value
|
|
7742
|
+
}),
|
|
7743
|
+
checked: Boolean(clickedFacets && ((_a2 = clickedFacets[value]) == null ? void 0 : _a2.includes(item == null ? void 0 : item.value))),
|
|
7744
|
+
...display.toLowerCase() === "swatch_with_label" ? {
|
|
7745
|
+
labelType: "text",
|
|
7746
|
+
label: `${item == null ? void 0 : item.labelName} ${(item == null ? void 0 : item.counter) !== void 0 && isShowNumberMatchingProduct ? ` (${item == null ? void 0 : item.counter})` : ""}`,
|
|
7747
|
+
labelStyle: filter_option_style
|
|
7748
|
+
} : {}
|
|
7749
|
+
}
|
|
7750
|
+
) }, index);
|
|
7751
|
+
};
|
|
7721
7752
|
let scrollElement = document.querySelector(
|
|
7722
7753
|
scrollElementSelector || `#filter-${indexFilter}-${layoutType}-${collectionId || "all"}-standard-${stringToSlug(value)} .sledge-instant-search__result-filter-item-list`
|
|
7723
7754
|
);
|
|
@@ -7884,26 +7915,19 @@ const Facet = (props) => {
|
|
|
7884
7915
|
useLoadMore: true
|
|
7885
7916
|
}
|
|
7886
7917
|
) });
|
|
7887
|
-
} else if (
|
|
7888
|
-
blockComponent =
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
|
|
7899
|
-
|
|
7900
|
-
parentId: value,
|
|
7901
|
-
value: e.currentTarget.value
|
|
7902
|
-
}),
|
|
7903
|
-
checked: Boolean(clickedFacets && ((_a2 = clickedFacets[value]) == null ? void 0 : _a2.includes(item.value)))
|
|
7904
|
-
}
|
|
7905
|
-
) }, index);
|
|
7906
|
-
}) });
|
|
7918
|
+
} else if (isDisplayColorSwatch && (currentItems == null ? void 0 : currentItems.length)) {
|
|
7919
|
+
blockComponent = display.toLowerCase() === "swatch_with_label" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7920
|
+
VirtualizedList,
|
|
7921
|
+
{
|
|
7922
|
+
selector: scrollElementSelector,
|
|
7923
|
+
...scrollElement && {
|
|
7924
|
+
scrollElement
|
|
7925
|
+
},
|
|
7926
|
+
rowCount: currentItems == null ? void 0 : currentItems.length,
|
|
7927
|
+
rowRenderer: ({ index }) => colorSwatchComponent({ item: currentItems == null ? void 0 : currentItems[index], index }),
|
|
7928
|
+
parentRef: ulListRef
|
|
7929
|
+
}
|
|
7930
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: currentItems == null ? void 0 : currentItems.map((item, index) => colorSwatchComponent({ item, index })) });
|
|
7907
7931
|
} else {
|
|
7908
7932
|
blockComponent = /* @__PURE__ */ jsxRuntimeExports.jsx("li", { className: "sledge-instant-search__result-filter-item-no-result", style: filter_option_style, children: search_filter_no_result || "No result..." });
|
|
7909
7933
|
}
|
|
@@ -8950,9 +8974,10 @@ const SearchResultWidget = (props) => {
|
|
|
8950
8974
|
let valueAllowedFilterSlider = [];
|
|
8951
8975
|
let valueHierarchicalFacetAliases = [];
|
|
8952
8976
|
if (!isSetFilter) {
|
|
8977
|
+
let isSetFilterItems = false;
|
|
8953
8978
|
allowedFilters == null ? void 0 : allowedFilters.map((filter) => {
|
|
8954
8979
|
const { active, collections, items } = filter;
|
|
8955
|
-
if (!active)
|
|
8980
|
+
if (!active || isSetFilterItems)
|
|
8956
8981
|
return;
|
|
8957
8982
|
const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => {
|
|
8958
8983
|
return {
|
|
@@ -8962,10 +8987,12 @@ const SearchResultWidget = (props) => {
|
|
|
8962
8987
|
});
|
|
8963
8988
|
if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
|
|
8964
8989
|
isSetFilter = true;
|
|
8990
|
+
isSetFilterItems = true;
|
|
8965
8991
|
valueAllowedFilter = newItems;
|
|
8966
8992
|
} else {
|
|
8967
8993
|
if (collections == null ? void 0 : collections.includes("all")) {
|
|
8968
8994
|
isSetFilter = true;
|
|
8995
|
+
isSetFilterItems = true;
|
|
8969
8996
|
valueAllowedFilter = newItems;
|
|
8970
8997
|
}
|
|
8971
8998
|
}
|
|
@@ -9109,22 +9136,26 @@ const SearchResultWidget = (props) => {
|
|
|
9109
9136
|
const { index } = tab;
|
|
9110
9137
|
let isSetFilter2 = false;
|
|
9111
9138
|
let getFacets = [];
|
|
9112
|
-
if (!isSetFilter2)
|
|
9139
|
+
if (!isSetFilter2) {
|
|
9140
|
+
let isSetFilterItems = false;
|
|
9113
9141
|
filters == null ? void 0 : filters.map((filter) => {
|
|
9114
9142
|
const { active, collections, items } = filter;
|
|
9115
|
-
if (!active)
|
|
9143
|
+
if (!active || isSetFilterItems)
|
|
9116
9144
|
return;
|
|
9117
9145
|
const newItems = items == null ? void 0 : items.map(({ value, ...otherItem }) => (otherItem == null ? void 0 : otherItem.display) === "tree" ? HIERARCHICAL_FACET_OBJECT_ALIASES[value] || value : value);
|
|
9118
9146
|
if (collectionId && (collections == null ? void 0 : collections.includes(String(collectionId)))) {
|
|
9119
9147
|
isSetFilter2 = true;
|
|
9148
|
+
isSetFilterItems = true;
|
|
9120
9149
|
getFacets = newItems;
|
|
9121
9150
|
} else {
|
|
9122
9151
|
if (collections == null ? void 0 : collections.includes("all")) {
|
|
9123
9152
|
isSetFilter2 = true;
|
|
9153
|
+
isSetFilterItems = true;
|
|
9124
9154
|
getFacets = newItems;
|
|
9125
9155
|
}
|
|
9126
9156
|
}
|
|
9127
9157
|
});
|
|
9158
|
+
}
|
|
9128
9159
|
let isProductIndex = index.includes(index_product);
|
|
9129
9160
|
let isHasProductFacets = isProductIndex && getFacets.length;
|
|
9130
9161
|
if (isHasProductFacets)
|
|
@@ -10242,6 +10273,7 @@ const ResultProduct = React__default.memo((props) => {
|
|
|
10242
10273
|
var _a2, _b2;
|
|
10243
10274
|
const { value, display, indexFilter } = filter;
|
|
10244
10275
|
const isDisplaySlider = ["slider", "input_range", "slider_with_input_range"].includes(display.toLowerCase());
|
|
10276
|
+
const isDisplayColorSwatch = ["swatch", "swatch_with_label"].includes(display.toLowerCase());
|
|
10245
10277
|
let items = display.toLowerCase() === "tree" ? createHierarchicalFacet({
|
|
10246
10278
|
indexValue: value,
|
|
10247
10279
|
filter,
|
|
@@ -10326,8 +10358,10 @@ const ResultProduct = React__default.memo((props) => {
|
|
|
10326
10358
|
}
|
|
10327
10359
|
);
|
|
10328
10360
|
};
|
|
10329
|
-
if (
|
|
10330
|
-
classesUlElement.push(
|
|
10361
|
+
if (isDisplayColorSwatch && (items == null ? void 0 : items.length))
|
|
10362
|
+
classesUlElement.push(
|
|
10363
|
+
display.toLowerCase() === "swatch" ? "sledge-instant-search__result-filter-item-color-swatches" : "sledge-instant-search__result-filter-item-color-swatches-with-label"
|
|
10364
|
+
);
|
|
10331
10365
|
if (display.toLowerCase() === "tree")
|
|
10332
10366
|
classesUlElement.push("sledge-instant-search__result-filter-item-tree");
|
|
10333
10367
|
if (((_b2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b2.layout) === "vertical" && (allowedFilter == null ? void 0 : allowedFilter.length) === 1)
|