@sledge-app/react-instant-search 2.0.18 → 2.0.20
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/components/Facet.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 +54 -38
- 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" }) => {
|
|
@@ -7553,6 +7545,7 @@ const Facet = (props) => {
|
|
|
7553
7545
|
let blockComponent = null;
|
|
7554
7546
|
const isShowNumberMatchingProduct = (_b = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b.show_number_matching_product;
|
|
7555
7547
|
const isDisplaySlider = ["slider", "input_range", "slider_with_input_range"].includes(display.toLowerCase());
|
|
7548
|
+
const isDisplayColorSwatch = ["swatch", "swatch_with_label"].includes(display.toLowerCase());
|
|
7556
7549
|
const isDisplayInputRange = display.toLowerCase() === "input_range";
|
|
7557
7550
|
const getValue = `${value}-${indexFilter}`;
|
|
7558
7551
|
if (show_search && keywordFacet && !isDisplaySlider)
|
|
@@ -7732,6 +7725,33 @@ const Facet = (props) => {
|
|
|
7732
7725
|
] });
|
|
7733
7726
|
});
|
|
7734
7727
|
};
|
|
7728
|
+
const colorSwatchComponent = ({ item = {}, index }) => {
|
|
7729
|
+
var _a2, _b2;
|
|
7730
|
+
let getColorSwatch = ((_a2 = colorSwatches == null ? void 0 : colorSwatches.filter(({ name }) => {
|
|
7731
|
+
var _a3;
|
|
7732
|
+
return (name == null ? void 0 : name.toLowerCase()) === ((_a3 = item == null ? void 0 : item.value) == null ? void 0 : _a3.toLowerCase());
|
|
7733
|
+
})) == null ? void 0 : _a2[0]) || {};
|
|
7734
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7735
|
+
ColorSwatch,
|
|
7736
|
+
{
|
|
7737
|
+
id: `${getValue}_${index}`,
|
|
7738
|
+
name: value,
|
|
7739
|
+
value: item == null ? void 0 : item.value,
|
|
7740
|
+
rgb: getColorSwatch == null ? void 0 : getColorSwatch.rgb,
|
|
7741
|
+
image: getColorSwatch == null ? void 0 : getColorSwatch.image,
|
|
7742
|
+
onClick: (e) => handleFilterChange({
|
|
7743
|
+
parentId: value,
|
|
7744
|
+
value: e.currentTarget.value
|
|
7745
|
+
}),
|
|
7746
|
+
checked: Boolean(clickedFacets && ((_b2 = clickedFacets[value]) == null ? void 0 : _b2.includes(item == null ? void 0 : item.value))),
|
|
7747
|
+
...display.toLowerCase() === "swatch_with_label" ? {
|
|
7748
|
+
labelType: "text",
|
|
7749
|
+
label: `${item == null ? void 0 : item.labelName} ${(item == null ? void 0 : item.counter) !== void 0 && isShowNumberMatchingProduct ? ` (${item == null ? void 0 : item.counter})` : ""}`,
|
|
7750
|
+
labelStyle: filter_option_style
|
|
7751
|
+
} : {}
|
|
7752
|
+
}
|
|
7753
|
+
) }, index);
|
|
7754
|
+
};
|
|
7735
7755
|
let scrollElement = document.querySelector(
|
|
7736
7756
|
scrollElementSelector || `#filter-${indexFilter}-${layoutType}-${collectionId || "all"}-standard-${stringToSlug(value)} .sledge-instant-search__result-filter-item-list`
|
|
7737
7757
|
);
|
|
@@ -7898,26 +7918,19 @@ const Facet = (props) => {
|
|
|
7898
7918
|
useLoadMore: true
|
|
7899
7919
|
}
|
|
7900
7920
|
) });
|
|
7901
|
-
} else if (
|
|
7902
|
-
blockComponent =
|
|
7903
|
-
|
|
7904
|
-
|
|
7905
|
-
|
|
7906
|
-
|
|
7907
|
-
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
parentId: value,
|
|
7915
|
-
value: e.currentTarget.value
|
|
7916
|
-
}),
|
|
7917
|
-
checked: Boolean(clickedFacets && ((_a2 = clickedFacets[value]) == null ? void 0 : _a2.includes(item.value)))
|
|
7918
|
-
}
|
|
7919
|
-
) }, index);
|
|
7920
|
-
}) });
|
|
7921
|
+
} else if (isDisplayColorSwatch && (currentItems == null ? void 0 : currentItems.length)) {
|
|
7922
|
+
blockComponent = display.toLowerCase() === "swatch_with_label" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7923
|
+
VirtualizedList,
|
|
7924
|
+
{
|
|
7925
|
+
selector: scrollElementSelector,
|
|
7926
|
+
...scrollElement && {
|
|
7927
|
+
scrollElement
|
|
7928
|
+
},
|
|
7929
|
+
rowCount: currentItems == null ? void 0 : currentItems.length,
|
|
7930
|
+
rowRenderer: ({ index }) => colorSwatchComponent({ item: currentItems == null ? void 0 : currentItems[index], index }),
|
|
7931
|
+
parentRef: ulListRef
|
|
7932
|
+
}
|
|
7933
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: currentItems == null ? void 0 : currentItems.map((item, index) => colorSwatchComponent({ item, index })) });
|
|
7921
7934
|
} else {
|
|
7922
7935
|
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..." });
|
|
7923
7936
|
}
|
|
@@ -10263,6 +10276,7 @@ const ResultProduct = React__default.memo((props) => {
|
|
|
10263
10276
|
var _a2, _b2;
|
|
10264
10277
|
const { value, display, indexFilter } = filter;
|
|
10265
10278
|
const isDisplaySlider = ["slider", "input_range", "slider_with_input_range"].includes(display.toLowerCase());
|
|
10279
|
+
const isDisplayColorSwatch = ["swatch", "swatch_with_label"].includes(display.toLowerCase());
|
|
10266
10280
|
let items = display.toLowerCase() === "tree" ? createHierarchicalFacet({
|
|
10267
10281
|
indexValue: value,
|
|
10268
10282
|
filter,
|
|
@@ -10347,8 +10361,10 @@ const ResultProduct = React__default.memo((props) => {
|
|
|
10347
10361
|
}
|
|
10348
10362
|
);
|
|
10349
10363
|
};
|
|
10350
|
-
if (
|
|
10351
|
-
classesUlElement.push(
|
|
10364
|
+
if (isDisplayColorSwatch && (items == null ? void 0 : items.length))
|
|
10365
|
+
classesUlElement.push(
|
|
10366
|
+
display.toLowerCase() === "swatch" ? "sledge-instant-search__result-filter-item-color-swatches" : "sledge-instant-search__result-filter-item-color-swatches-with-label"
|
|
10367
|
+
);
|
|
10352
10368
|
if (display.toLowerCase() === "tree")
|
|
10353
10369
|
classesUlElement.push("sledge-instant-search__result-filter-item-tree");
|
|
10354
10370
|
if (((_b2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b2.layout) === "vertical" && (allowedFilter == null ? void 0 : allowedFilter.length) === 1)
|