@sledge-app/react-instant-search 2.0.12 → 2.0.13
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 +62 -74
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1106,7 +1106,7 @@ const Pagination = (props) => {
|
|
|
1106
1106
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__pagination", "data-pagination-type": type, children: renderPaginationLayout() });
|
|
1107
1107
|
};
|
|
1108
1108
|
const RadioGroup$1 = "";
|
|
1109
|
-
const rowRenderer
|
|
1109
|
+
const rowRenderer = ({ virtualized, item, id, labelStyle }) => {
|
|
1110
1110
|
const { index, key = "" } = virtualized || {};
|
|
1111
1111
|
const { label, value } = item;
|
|
1112
1112
|
const content = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
@@ -1120,7 +1120,7 @@ const RadioGroup = ({ id, name, required, value, items, labelStyle = {}, onValue
|
|
|
1120
1120
|
VirtualizedList,
|
|
1121
1121
|
{
|
|
1122
1122
|
rowCount: items == null ? void 0 : items.length,
|
|
1123
|
-
rowRenderer: ({ index, key }) => rowRenderer
|
|
1123
|
+
rowRenderer: ({ index, key }) => rowRenderer({
|
|
1124
1124
|
virtualized: {
|
|
1125
1125
|
index,
|
|
1126
1126
|
key
|
|
@@ -1134,7 +1134,7 @@ const RadioGroup = ({ id, name, required, value, items, labelStyle = {}, onValue
|
|
|
1134
1134
|
parentRef
|
|
1135
1135
|
}
|
|
1136
1136
|
) : items.map(
|
|
1137
|
-
(item, index) => rowRenderer
|
|
1137
|
+
(item, index) => rowRenderer({
|
|
1138
1138
|
virtualized: {
|
|
1139
1139
|
index
|
|
1140
1140
|
},
|
|
@@ -1177,25 +1177,32 @@ const ColorSwatch = ({ id, name, value, rgb, image, required, checked, onClick }
|
|
|
1177
1177
|
);
|
|
1178
1178
|
};
|
|
1179
1179
|
const Select$1 = "";
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
const
|
|
1183
|
-
|
|
1184
|
-
};
|
|
1185
|
-
const Select = ({ name, placeholder, required, defaultValue, items: itemsProp, labelStyle = {}, onValueChange, useVirtualized = false }) => {
|
|
1180
|
+
const Select = ({ name, placeholder, required, defaultValue, items, labelStyle = {}, onValueChange, useLoadMore = false, loadMoreText = "Load More" }) => {
|
|
1181
|
+
var _a;
|
|
1182
|
+
const maxItemPerPage = 30;
|
|
1183
|
+
const defaultVisibleItemsLoadMore = (items == null ? void 0 : items.length) ? items.slice(0, maxItemPerPage) : [];
|
|
1186
1184
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
1187
|
-
const [
|
|
1188
|
-
const
|
|
1189
|
-
const
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1185
|
+
const [visibleItems, setVisibleItems] = React__default.useState((items == null ? void 0 : items.length) ? useLoadMore ? defaultVisibleItemsLoadMore : items : []);
|
|
1186
|
+
const [page, setPage] = React__default.useState(1);
|
|
1187
|
+
const handleLoadMore = () => {
|
|
1188
|
+
var _a2;
|
|
1189
|
+
const nextItems = (_a2 = items == null ? void 0 : items.slice) == null ? void 0 : _a2.call(items, 0, (page + 1) * maxItemPerPage);
|
|
1190
|
+
setVisibleItems(nextItems);
|
|
1191
|
+
setPage(page + 1);
|
|
1192
|
+
setTimeout(() => {
|
|
1193
|
+
var _a3, _b, _c, _d;
|
|
1194
|
+
const selectRootElement = document.querySelector(".sledge__select-root");
|
|
1195
|
+
if (selectRootElement) {
|
|
1196
|
+
const currentHeight = (_b = (_a3 = window == null ? void 0 : window.getComputedStyle) == null ? void 0 : _a3.call(window, selectRootElement)) == null ? void 0 : _b.height;
|
|
1197
|
+
const currentMaxHeight = (_d = (_c = window == null ? void 0 : window.getComputedStyle) == null ? void 0 : _c.call(window, selectRootElement)) == null ? void 0 : _d.maxHeight;
|
|
1198
|
+
if (currentHeight)
|
|
1199
|
+
selectRootElement.style.height = currentHeight;
|
|
1200
|
+
if (currentMaxHeight)
|
|
1201
|
+
selectRootElement.style.height = currentMaxHeight;
|
|
1202
|
+
}
|
|
1203
|
+
}, 0);
|
|
1198
1204
|
};
|
|
1205
|
+
const hasMore = visibleItems.length < items.length;
|
|
1199
1206
|
React__default.useEffect(() => {
|
|
1200
1207
|
setIsLoading(true);
|
|
1201
1208
|
setTimeout(() => {
|
|
@@ -1212,25 +1219,19 @@ const Select = ({ name, placeholder, required, defaultValue, items: itemsProp, l
|
|
|
1212
1219
|
selectRootElement.classList.toggle("sledge__select-root");
|
|
1213
1220
|
}
|
|
1214
1221
|
};
|
|
1215
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__select-wrapper", "data-use-
|
|
1222
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__select-wrapper", "data-use-load-more": useLoadMore, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1216
1223
|
$cc7e05a45900e73f$export$be92b6f5f03c0fe9,
|
|
1217
1224
|
{
|
|
1218
1225
|
name,
|
|
1219
1226
|
required,
|
|
1220
1227
|
onValueChange,
|
|
1221
|
-
onOpenChange: (open) =>
|
|
1222
|
-
handleClassNameRoot(open);
|
|
1223
|
-
setItems(open && (itemsProp == null ? void 0 : itemsProp.length) ? [itemsProp == null ? void 0 : itemsProp[0]] : []);
|
|
1224
|
-
setTimeout(() => {
|
|
1225
|
-
setItems(open && (itemsProp == null ? void 0 : itemsProp.length) ? itemsProp : []);
|
|
1226
|
-
}, 0);
|
|
1227
|
-
},
|
|
1228
|
+
onOpenChange: (open) => handleClassNameRoot(open),
|
|
1228
1229
|
...defaultValue ? {
|
|
1229
1230
|
defaultValue
|
|
1230
1231
|
} : {},
|
|
1231
1232
|
children: [
|
|
1232
1233
|
/* @__PURE__ */ jsxRuntimeExports.jsxs($cc7e05a45900e73f$export$41fb9f06171c75f4, { className: "sledge__select-trigger", style: labelStyle, children: [
|
|
1233
|
-
|
|
1234
|
+
useLoadMore && defaultValue ? /* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$4c8d1a57a761ef94, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: defaultValue }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$4c8d1a57a761ef94, { placeholder }),
|
|
1234
1235
|
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$f04a61298a47a40f, { className: "sledge__select-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1235
1236
|
"path",
|
|
1236
1237
|
{
|
|
@@ -1241,15 +1242,18 @@ const Select = ({ name, placeholder, required, defaultValue, items: itemsProp, l
|
|
|
1241
1242
|
}
|
|
1242
1243
|
) }) })
|
|
1243
1244
|
] }),
|
|
1244
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$602eac185826482c, { className: "sledge__select-portal", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1245
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$602eac185826482c, { className: "sledge__select-portal", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1246
|
+
$cc7e05a45900e73f$export$7c6e2c02157bb7d2,
|
|
1247
|
+
{
|
|
1248
|
+
className: "sledge__select-content",
|
|
1249
|
+
onCloseAutoFocus: () => {
|
|
1250
|
+
if (!useLoadMore)
|
|
1251
|
+
return;
|
|
1252
|
+
setVisibleItems(defaultVisibleItemsLoadMore);
|
|
1253
|
+
setPage(1);
|
|
1254
|
+
},
|
|
1255
|
+
children: [
|
|
1256
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$2f60d3ec9ad468f2, { className: "sledge__select-scroll-button", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1253
1257
|
"path",
|
|
1254
1258
|
{
|
|
1255
1259
|
d: "M3.13523 8.84197C3.3241 9.04343 3.64052 9.05363 3.84197 8.86477L7.5 5.43536L11.158 8.86477C11.3595 9.05363 11.6759 9.04343 11.8648 8.84197C12.0536 8.64051 12.0434 8.32409 11.842 8.13523L7.84197 4.38523C7.64964 4.20492 7.35036 4.20492 7.15803 4.38523L3.15803 8.13523C2.95657 8.32409 2.94637 8.64051 3.13523 8.84197Z",
|
|
@@ -1257,37 +1261,20 @@ const Select = ({ name, placeholder, required, defaultValue, items: itemsProp, l
|
|
|
1257
1261
|
fillRule: "evenodd",
|
|
1258
1262
|
clipRule: "evenodd"
|
|
1259
1263
|
}
|
|
1260
|
-
) })
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
}
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
}),
|
|
1275
|
-
parentRef: selectViewportRef
|
|
1276
|
-
}
|
|
1277
|
-
) : items.map(
|
|
1278
|
-
(item, index) => {
|
|
1279
|
-
const { label, value } = item;
|
|
1280
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItemComponent, { value, children: label }, index);
|
|
1281
|
-
}
|
|
1282
|
-
) }),
|
|
1283
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1284
|
-
$cc7e05a45900e73f$export$bf1aedc3039c8d63,
|
|
1285
|
-
{
|
|
1286
|
-
className: "sledge__select-scroll-button",
|
|
1287
|
-
...useVirtualized ? {
|
|
1288
|
-
onClick: () => scrollToPosition("down")
|
|
1289
|
-
} : {},
|
|
1290
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1264
|
+
) }) }),
|
|
1265
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$d5c6c08dc2d3ca7, { className: "sledge__select-viewport", children: useLoadMore ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1266
|
+
(_a = visibleItems == null ? void 0 : visibleItems.map) == null ? void 0 : _a.call(visibleItems, (item, index) => {
|
|
1267
|
+
const { label, value } = item;
|
|
1268
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItemComponent, { value, children: label }, index);
|
|
1269
|
+
}),
|
|
1270
|
+
hasMore && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__select-load-more", onClick: handleLoadMore, children: loadMoreText })
|
|
1271
|
+
] }) : items.map(
|
|
1272
|
+
(item, index) => {
|
|
1273
|
+
const { label, value } = item;
|
|
1274
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SelectItemComponent, { value, children: label }, index);
|
|
1275
|
+
}
|
|
1276
|
+
) }),
|
|
1277
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx($cc7e05a45900e73f$export$bf1aedc3039c8d63, { className: "sledge__select-scroll-button", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width: 15, height: 15, viewBox: "0 0 15 15", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1291
1278
|
"path",
|
|
1292
1279
|
{
|
|
1293
1280
|
d: "M3.13523 6.15803C3.3241 5.95657 3.64052 5.94637 3.84197 6.13523L7.5 9.56464L11.158 6.13523C11.3595 5.94637 11.6759 5.95657 11.8648 6.15803C12.0536 6.35949 12.0434 6.67591 11.842 6.86477L7.84197 10.6148C7.64964 10.7951 7.35036 10.7951 7.15803 10.6148L3.15803 6.86477C2.95657 6.67591 2.94637 6.35949 3.13523 6.15803Z",
|
|
@@ -1295,10 +1282,10 @@ const Select = ({ name, placeholder, required, defaultValue, items: itemsProp, l
|
|
|
1295
1282
|
fillRule: "evenodd",
|
|
1296
1283
|
clipRule: "evenodd"
|
|
1297
1284
|
}
|
|
1298
|
-
) })
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1285
|
+
) }) })
|
|
1286
|
+
]
|
|
1287
|
+
}
|
|
1288
|
+
) })
|
|
1302
1289
|
]
|
|
1303
1290
|
}
|
|
1304
1291
|
) }) });
|
|
@@ -7841,7 +7828,8 @@ const Facet = (props) => {
|
|
|
7841
7828
|
}),
|
|
7842
7829
|
defaultValue: clickedFacets && ((_e = clickedFacets[value]) == null ? void 0 : _e.length) ? clickedFacets[value][0] : "",
|
|
7843
7830
|
labelStyle: filter_option_style,
|
|
7844
|
-
|
|
7831
|
+
loadMoreText: button_load_more || "Load More",
|
|
7832
|
+
useLoadMore: true
|
|
7845
7833
|
}
|
|
7846
7834
|
) });
|
|
7847
7835
|
} else if (display.toLowerCase() === "swatch" && (currentItems == null ? void 0 : currentItems.length)) {
|