@sledge-app/react-instant-search 2.0.18 → 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/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 +51 -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,30 @@ const Facet = (props) => {
|
|
|
7732
7725
|
] });
|
|
7733
7726
|
});
|
|
7734
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
|
+
};
|
|
7735
7752
|
let scrollElement = document.querySelector(
|
|
7736
7753
|
scrollElementSelector || `#filter-${indexFilter}-${layoutType}-${collectionId || "all"}-standard-${stringToSlug(value)} .sledge-instant-search__result-filter-item-list`
|
|
7737
7754
|
);
|
|
@@ -7898,26 +7915,19 @@ const Facet = (props) => {
|
|
|
7898
7915
|
useLoadMore: true
|
|
7899
7916
|
}
|
|
7900
7917
|
) });
|
|
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
|
-
}) });
|
|
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 })) });
|
|
7921
7931
|
} else {
|
|
7922
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..." });
|
|
7923
7933
|
}
|
|
@@ -10263,6 +10273,7 @@ const ResultProduct = React__default.memo((props) => {
|
|
|
10263
10273
|
var _a2, _b2;
|
|
10264
10274
|
const { value, display, indexFilter } = filter;
|
|
10265
10275
|
const isDisplaySlider = ["slider", "input_range", "slider_with_input_range"].includes(display.toLowerCase());
|
|
10276
|
+
const isDisplayColorSwatch = ["swatch", "swatch_with_label"].includes(display.toLowerCase());
|
|
10266
10277
|
let items = display.toLowerCase() === "tree" ? createHierarchicalFacet({
|
|
10267
10278
|
indexValue: value,
|
|
10268
10279
|
filter,
|
|
@@ -10347,8 +10358,10 @@ const ResultProduct = React__default.memo((props) => {
|
|
|
10347
10358
|
}
|
|
10348
10359
|
);
|
|
10349
10360
|
};
|
|
10350
|
-
if (
|
|
10351
|
-
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
|
+
);
|
|
10352
10365
|
if (display.toLowerCase() === "tree")
|
|
10353
10366
|
classesUlElement.push("sledge-instant-search__result-filter-item-tree");
|
|
10354
10367
|
if (((_b2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b2.layout) === "vertical" && (allowedFilter == null ? void 0 : allowedFilter.length) === 1)
|