@sledge-app/react-instant-search 1.0.99 → 1.0.101
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/Atoms.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/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 -7
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1016,6 +1016,15 @@ const FilterIcon = ({ width, height, color }) => {
|
|
|
1016
1016
|
)
|
|
1017
1017
|
] }) });
|
|
1018
1018
|
};
|
|
1019
|
+
const InfoCircleIcon = ({ width, height, color }) => {
|
|
1020
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-icon__info-circle", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { width, height, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1021
|
+
"path",
|
|
1022
|
+
{
|
|
1023
|
+
d: "M12 2.00293C6.49 2.00293 2 6.49293 2 12.0029C2 17.5129 6.49 22.0029 12 22.0029C17.51 22.0029 22 17.5129 22 12.0029C22 6.49293 17.51 2.00293 12 2.00293ZM11.25 8.00293C11.25 7.59293 11.59 7.25293 12 7.25293C12.41 7.25293 12.75 7.59293 12.75 8.00293V13.0029C12.75 13.4129 12.41 13.7529 12 13.7529C11.59 13.7529 11.25 13.4129 11.25 13.0029V8.00293ZM12.92 16.3829C12.87 16.5129 12.8 16.6129 12.71 16.7129C12.61 16.8029 12.5 16.8729 12.38 16.9229C12.26 16.9729 12.13 17.0029 12 17.0029C11.87 17.0029 11.74 16.9729 11.62 16.9229C11.5 16.8729 11.39 16.8029 11.29 16.7129C11.2 16.6129 11.13 16.5129 11.08 16.3829C11.03 16.2629 11 16.1329 11 16.0029C11 15.8729 11.03 15.7429 11.08 15.6229C11.13 15.5029 11.2 15.3929 11.29 15.2929C11.39 15.2029 11.5 15.1329 11.62 15.0829C11.86 14.9829 12.14 14.9829 12.38 15.0829C12.5 15.1329 12.61 15.2029 12.71 15.2929C12.8 15.3929 12.87 15.5029 12.92 15.6229C12.97 15.7429 13 15.8729 13 16.0029C13 16.1329 12.97 16.2629 12.92 16.3829Z",
|
|
1024
|
+
fill: color
|
|
1025
|
+
}
|
|
1026
|
+
) }) });
|
|
1027
|
+
};
|
|
1019
1028
|
const Button$1 = "";
|
|
1020
1029
|
const Button = React__default.forwardRef((props, buttonRef) => {
|
|
1021
1030
|
const { className = "", children, colorType = "light", fullWidth = false, elementType = "button", link = "", isActive, ...otherProps } = props;
|
|
@@ -1129,6 +1138,14 @@ const SelectField = (props) => {
|
|
|
1129
1138
|
) });
|
|
1130
1139
|
};
|
|
1131
1140
|
const ProductGrid$1 = "";
|
|
1141
|
+
if (!Object.hasOwn) {
|
|
1142
|
+
console.log("Defining Object.hasOwn");
|
|
1143
|
+
Object.hasOwn = function(obj, prop) {
|
|
1144
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
1145
|
+
};
|
|
1146
|
+
} else {
|
|
1147
|
+
console.log("Object.hasOwn is already defined");
|
|
1148
|
+
}
|
|
1132
1149
|
const addToCart = async (data) => {
|
|
1133
1150
|
var _a, _b;
|
|
1134
1151
|
let items = [];
|
|
@@ -3935,6 +3952,13 @@ const VirtualizedList = ({ scrollElement, rowCount, rowRenderer: rowRenderer2, s
|
|
|
3935
3952
|
}
|
|
3936
3953
|
);
|
|
3937
3954
|
};
|
|
3955
|
+
const Alert$1 = "";
|
|
3956
|
+
const Alert = ({ children, className = "", type, icon = null }) => {
|
|
3957
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `sledge__alert ${className}`, "data-alert-type": type, children: [
|
|
3958
|
+
icon && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: icon }),
|
|
3959
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children })
|
|
3960
|
+
] });
|
|
3961
|
+
};
|
|
3938
3962
|
const SearchIconWidget = (props) => {
|
|
3939
3963
|
const { isRenderApp, isJsVersion, componentRef } = React__default.useContext(SledgeContext);
|
|
3940
3964
|
const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
|
|
@@ -4134,11 +4158,13 @@ const SearchIconWidgetPopup = () => {
|
|
|
4134
4158
|
searchViewMoreResultComponent: null,
|
|
4135
4159
|
query: {}
|
|
4136
4160
|
});
|
|
4161
|
+
const [totalHitsProduct, setTotalHitsProduct] = React__default.useState(0);
|
|
4162
|
+
const [instantSearchSettings, setInstantSearchSettings] = React__default.useState({});
|
|
4137
4163
|
const searchFieldRef = React__default.useRef(null);
|
|
4138
4164
|
const previousState = usePrevious({ keyword });
|
|
4139
4165
|
const { direction: redirectObjectDirection } = redirectObject || {};
|
|
4140
4166
|
const handleMultiSearch = async (params) => {
|
|
4141
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2;
|
|
4167
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2;
|
|
4142
4168
|
const { data, onSearch = false, withFetchReviewInfo = false } = params;
|
|
4143
4169
|
const valueRedirectObject = redirectsSettings.find(({ keyword: redirectKeyword }) => {
|
|
4144
4170
|
var _a3;
|
|
@@ -4174,13 +4200,14 @@ const SearchIconWidgetPopup = () => {
|
|
|
4174
4200
|
return;
|
|
4175
4201
|
const { results } = response;
|
|
4176
4202
|
let valueSearchResultProduct = results == null ? void 0 : results.filter(({ indexUid }) => indexUid == null ? void 0 : indexUid.includes(index_product));
|
|
4203
|
+
setTotalHitsProduct(((_c2 = valueSearchResultProduct[0]) == null ? void 0 : _c2.totalHits) || 0);
|
|
4177
4204
|
if (onSearch && (keyword == null ? void 0 : keyword.length)) {
|
|
4178
4205
|
searchTrigger({
|
|
4179
4206
|
keyword,
|
|
4180
|
-
resultCount: ((
|
|
4207
|
+
resultCount: ((_d2 = valueSearchResultProduct[0]) == null ? void 0 : _d2.totalHits) || 0
|
|
4181
4208
|
});
|
|
4182
4209
|
}
|
|
4183
|
-
let valueSearchResultOther = ((
|
|
4210
|
+
let valueSearchResultOther = ((_e2 = results == null ? void 0 : results.filter(({ indexUid }) => !(indexUid == null ? void 0 : indexUid.includes(index_product)))) == null ? void 0 : _e2.map((result) => {
|
|
4184
4211
|
const { indexUid } = result;
|
|
4185
4212
|
const { name, type } = tabs == null ? void 0 : tabs.find(({ index }) => index.includes(indexUid));
|
|
4186
4213
|
return {
|
|
@@ -4191,16 +4218,16 @@ const SearchIconWidgetPopup = () => {
|
|
|
4191
4218
|
}
|
|
4192
4219
|
};
|
|
4193
4220
|
})) || [];
|
|
4194
|
-
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (
|
|
4221
|
+
let getValueSearchResultProduct = (valueSearchResultProduct == null ? void 0 : valueSearchResultProduct.length) ? (_f2 = valueSearchResultProduct[0]) == null ? void 0 : _f2.hits : [];
|
|
4195
4222
|
let valueSuggestionIndex = !keyword.length ? "zero_character" : !(getValueSearchResultProduct == null ? void 0 : getValueSearchResultProduct.length) ? "no_result" : "";
|
|
4196
4223
|
let isPriorityZeroCharacter = Boolean(
|
|
4197
|
-
!keyword.length && Object.keys(suggestion).length && ((
|
|
4224
|
+
!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)
|
|
4198
4225
|
);
|
|
4199
|
-
let dataSearchResultProduct = isPriorityZeroCharacter ? (
|
|
4226
|
+
let dataSearchResultProduct = isPriorityZeroCharacter ? (_m2 = (_l2 = suggestion[valueSuggestionIndex]) == null ? void 0 : _l2.products) == null ? void 0 : _m2.list : getValueSearchResultProduct;
|
|
4200
4227
|
if (withFetchReviewInfo) {
|
|
4201
4228
|
let searchResultProductIds = dataSearchResultProduct.map(({ id }) => id);
|
|
4202
4229
|
let valueDataReviews = await getProductsReviewInfo(searchResultProductIds);
|
|
4203
|
-
if (((
|
|
4230
|
+
if (((_n2 = valueDataReviews == null ? void 0 : valueDataReviews.status) == null ? void 0 : _n2.code) === 200)
|
|
4204
4231
|
setDataReviews(valueDataReviews == null ? void 0 : valueDataReviews.data);
|
|
4205
4232
|
} else {
|
|
4206
4233
|
setDataReviews({});
|
|
@@ -4216,6 +4243,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
4216
4243
|
response = JSON.parse(LOCAL_STORAGE_INSTANT_SEARCH_SETTING);
|
|
4217
4244
|
if (!response)
|
|
4218
4245
|
return;
|
|
4246
|
+
setInstantSearchSettings(response);
|
|
4219
4247
|
const { display, languages, redirects } = response;
|
|
4220
4248
|
setDisplaySettings(display);
|
|
4221
4249
|
setSuggestionSettings((_a2 = display == null ? void 0 : display.search) == null ? void 0 : _a2.suggestion);
|
|
@@ -4285,10 +4313,16 @@ const SearchIconWidgetPopup = () => {
|
|
|
4285
4313
|
return () => clearTimeout(delayDebounceFn);
|
|
4286
4314
|
}
|
|
4287
4315
|
}, [keyword]);
|
|
4316
|
+
const alertFirstSyncComponent = !isLoading && !totalHitsProduct && (instantSearchSettings == null ? void 0 : instantSearchSettings.first_sync) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Alert, { className: "sledge-instant-search__icon-widget-popup-alert-first-sync", type: "info", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircleIcon, { width: 24, height: 24, color: "#003a5a" }), children: [
|
|
4317
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Products and Collections indexing is in progress. Product Filter and Instant Search widgets may appear empty during this process." }),
|
|
4318
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", {}),
|
|
4319
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "The products and collections will become visible in the widgets once indexing is complete." })
|
|
4320
|
+
] }) : null;
|
|
4288
4321
|
return /* @__PURE__ */ jsxRuntimeExports.jsx($5d3850c4d0b4e6c7$export$be92b6f5f03c0fe9, { open: showInfo, onOpenChange: setShowInfo, children: /* @__PURE__ */ jsxRuntimeExports.jsxs($5d3850c4d0b4e6c7$export$602eac185826482c, { children: [
|
|
4289
4322
|
/* @__PURE__ */ jsxRuntimeExports.jsx($5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, { className: "sledge__popup-overlay" }),
|
|
4290
4323
|
/* @__PURE__ */ jsxRuntimeExports.jsx($5d3850c4d0b4e6c7$export$c6fdb837b070b4ff, { className: "sledge__popup-overlay-blur" }),
|
|
4291
4324
|
/* @__PURE__ */ jsxRuntimeExports.jsxs($5d3850c4d0b4e6c7$export$7c6e2c02157bb7d2, { className: "sledge-instant-search__icon-widget-popup-detail-content", "data-layout-type": ((_a = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _a.layout) || "", children: [
|
|
4325
|
+
alertFirstSyncComponent,
|
|
4292
4326
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4293
4327
|
SearchInputField,
|
|
4294
4328
|
{
|
|
@@ -5307,6 +5341,7 @@ const SearchResultWidget = (props) => {
|
|
|
5307
5341
|
const [isReplaceWidgetList, setIsReplaceWidgetList] = React__default.useState(false);
|
|
5308
5342
|
const [searchResultFacets, setSearchResultFacets] = React__default.useState({});
|
|
5309
5343
|
const [generalDataSettings, setGeneralDataSettings] = React__default.useState((sledgeSettings == null ? void 0 : sledgeSettings.general) || {});
|
|
5344
|
+
const [instantSearchSettings, setInstantSearchSettings] = React__default.useState((sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) || {});
|
|
5310
5345
|
const [clickedFacets, setClickedFacets] = React__default.useState({});
|
|
5311
5346
|
const [clickedOpenFilterHorizontalId, setClickedOpenFilterHorizontalId] = React__default.useState(null);
|
|
5312
5347
|
const [clickedOpenFilterHorizontalMobileId, setClickedOpenFilterHorizontalMobileId] = React__default.useState(null);
|
|
@@ -5315,6 +5350,7 @@ const SearchResultWidget = (props) => {
|
|
|
5315
5350
|
const [mobileShowSelectedSort, setMobileShowSelectedSort] = React__default.useState(true);
|
|
5316
5351
|
const [soldProductAtEnd, setSoldProductAtEnd] = React__default.useState(false);
|
|
5317
5352
|
const [attributesToRetrieve, setAttributesToRetrieve] = React__default.useState(((_k = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _k.attributes_to_retrieve) || []);
|
|
5353
|
+
const [totalHitsProduct, setTotalHitsProduct] = React__default.useState(0);
|
|
5318
5354
|
const debouncedKeyword = useDebounce(keyword, 500);
|
|
5319
5355
|
let productCardsComponent = null;
|
|
5320
5356
|
let collectionCardsComponent = null;
|
|
@@ -5408,6 +5444,7 @@ const SearchResultWidget = (props) => {
|
|
|
5408
5444
|
setIsFirstLoading(false);
|
|
5409
5445
|
setIsLoading(false);
|
|
5410
5446
|
const { facetStats, totalHits, facetDistribution } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(index_product))) || {};
|
|
5447
|
+
setTotalHitsProduct(totalHits || 0);
|
|
5411
5448
|
let valueHideFilterWhenOneValue = ((_a2 = display == null ? void 0 : display.filter) == null ? void 0 : _a2.hide_when_one_value) && totalHits <= 1;
|
|
5412
5449
|
let valueSearchResultFacets = facetDistribution ? Object.fromEntries(
|
|
5413
5450
|
Object.entries(facetDistribution).map((facet) => {
|
|
@@ -5519,6 +5556,7 @@ const SearchResultWidget = (props) => {
|
|
|
5519
5556
|
responseGeneral = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.GENERAL_SETTING) || null);
|
|
5520
5557
|
if (!response)
|
|
5521
5558
|
return;
|
|
5559
|
+
setInstantSearchSettings(response);
|
|
5522
5560
|
if (responseGeneral)
|
|
5523
5561
|
setGeneralDataSettings(responseGeneral);
|
|
5524
5562
|
const {
|
|
@@ -5856,7 +5894,13 @@ const SearchResultWidget = (props) => {
|
|
|
5856
5894
|
const containerStyle = {
|
|
5857
5895
|
maxWidth: width
|
|
5858
5896
|
};
|
|
5897
|
+
const alertFirstSyncComponent = !isFirstLoading && !totalHitsProduct && (instantSearchSettings == null ? void 0 : instantSearchSettings.first_sync) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Alert, { className: "sledge-instant-search__alert-first-sync-product", type: "info", icon: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircleIcon, { width: 24, height: 24, color: "#003a5a" }), children: [
|
|
5898
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Products and Collections indexing is in progress. Product Filter and Instant Search widgets may appear empty during this process." }),
|
|
5899
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", {}),
|
|
5900
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "The products and collections will become visible in the widgets once indexing is complete." })
|
|
5901
|
+
] }) : null;
|
|
5859
5902
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-container", ref: searchResultContainerRef, style: containerStyle, children: [
|
|
5903
|
+
alertFirstSyncComponent,
|
|
5860
5904
|
isFirstLoading ? tabSkeleton : layoutType === "default" && (allowedTabs == null ? void 0 : allowedTabs.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `${layoutType === "default" && (allowedTabs == null ? void 0 : allowedTabs.length) ? "sledge-instant-search__result-tab" : "sledge-instant-search__result-tab-no-index"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: "sledge-instant-search__result-tab-list", children: allowedTabs.map((item) => {
|
|
5861
5905
|
const { name, index, type, total } = item;
|
|
5862
5906
|
let isActive = clickedTabIndexId === index;
|