@sledge-app/react-instant-search 1.0.89 → 1.0.90
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/ProductFilterWidget/ProductFilterWidgetInitSelector.d.ts +4 -1
- package/dist/components/ProductFilterWidget/ProductFilterWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetInitSelector.d.ts +4 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetPopup.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidget.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidgetInitSelector.d.ts +4 -1
- package/dist/components/SearchResultWidget/SearchResultWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidget.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidgetInitSelector.d.ts +4 -1
- package/dist/components/SearchWidget/SearchWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/index.d.ts +3 -1
- package/dist/components/index.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 +76 -48
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -33,8 +33,6 @@ const DATASET_ATTRIBUTE_KEY = {
|
|
|
33
33
|
COLLECTION_NAME: "data-collection-name",
|
|
34
34
|
WIDTH_ELEMENT: "data-width-element",
|
|
35
35
|
ICON_SIZE: "data-icon-size",
|
|
36
|
-
API_KEY: "data-api-key",
|
|
37
|
-
INSTANT_SEARCH_API_KEY: "data-instant-search-api-key",
|
|
38
36
|
RENDER_PRODUCT_CARD: "data-render-product-card",
|
|
39
37
|
WITH_SKELETON_LOADING: "data-with-skeleton-loading",
|
|
40
38
|
SECTION_TITLE: "data-section-title",
|
|
@@ -86,7 +84,6 @@ const DATASET_ATTRIBUTE_KEY = {
|
|
|
86
84
|
const LOCAL_STORAGE_KEY = {
|
|
87
85
|
ANONYM_ID: "sledge-anonym-id",
|
|
88
86
|
AUTH_APP: "sledge-auth-app",
|
|
89
|
-
AUTH_APP_VERIFY: "sledge-auth-app-verify",
|
|
90
87
|
INSTANT_SEARCH_AUTH_APP: "sledge-instant-search-auth-app",
|
|
91
88
|
GENERAL_SETTING: "sledge-general-setting",
|
|
92
89
|
WISHLIST_SETTING: "sledge-wishlist-setting",
|
|
@@ -107,7 +104,8 @@ const INTERNAL_SELECTOR_VALUE = {
|
|
|
107
104
|
ELEMENT_FLOATING_LEFT_WIDGET: "floating-left-widget",
|
|
108
105
|
ELEMENT_FLOATING_RIGHT_WIDGET: "floating-right-widget",
|
|
109
106
|
WISHLIST: {
|
|
110
|
-
ELEMENT_WIDGET_POPUP: "wishlist-widget-popup"
|
|
107
|
+
ELEMENT_WIDGET_POPUP: "wishlist-widget-popup",
|
|
108
|
+
ELEMENT_BADGE_COUNTER: "wishlist-badge-counter"
|
|
111
109
|
},
|
|
112
110
|
PRODUCT_REVIEW: {
|
|
113
111
|
ELEMENT_WIDGET_POPUP_DETAIL: "product-review-widget-popup-detail",
|
|
@@ -125,7 +123,7 @@ const SELECTOR = {
|
|
|
125
123
|
},
|
|
126
124
|
WISHLIST: {
|
|
127
125
|
ELEMENT_BADGE: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-badge"]`,
|
|
128
|
-
ELEMENT_BADGE_COUNTER: `[${SELECTOR_ATTRIBUTE_KEY}="
|
|
126
|
+
ELEMENT_BADGE_COUNTER: `[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.WISHLIST.ELEMENT_BADGE_COUNTER}"]`,
|
|
129
127
|
ELEMENT_BADGE_MENU_ITEM: `[href="#sledge-wishlist-badge-menu-item"]`,
|
|
130
128
|
ELEMENT_TRIGGER: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-trigger"]`,
|
|
131
129
|
ELEMENT_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="wishlist-widget"]`,
|
|
@@ -1163,7 +1161,7 @@ const addToCart = async (data) => {
|
|
|
1163
1161
|
});
|
|
1164
1162
|
};
|
|
1165
1163
|
const addWishlist = async (data) => {
|
|
1166
|
-
const { productId, productVariantId, productName, productVendor, productSku, productVariantName, productLink, productImage, productCurrency, productPrice } = data;
|
|
1164
|
+
const { productId, productVariantId, productName, productVendor, productSku, productVariantName, productLink, productImage, productCurrency, productPrice, type = "toggle" } = data;
|
|
1167
1165
|
let sledgeAuthApp = typeof localStorage !== "undefined" ? localStorage.getItem(LOCAL_STORAGE_KEY.AUTH_APP) || "" : "";
|
|
1168
1166
|
let url = `${API_URL}/wishlist`;
|
|
1169
1167
|
let payload = {
|
|
@@ -1178,7 +1176,8 @@ const addWishlist = async (data) => {
|
|
|
1178
1176
|
image_url: productImage,
|
|
1179
1177
|
currency: productCurrency,
|
|
1180
1178
|
price: productPrice
|
|
1181
|
-
})
|
|
1179
|
+
}),
|
|
1180
|
+
type: type === "toggle" ? "" : type
|
|
1182
1181
|
};
|
|
1183
1182
|
return await fetchApi({
|
|
1184
1183
|
url,
|
|
@@ -1431,8 +1430,8 @@ const Badge = (props) => {
|
|
|
1431
1430
|
"span",
|
|
1432
1431
|
{
|
|
1433
1432
|
className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-header-menu ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`,
|
|
1434
|
-
"data-component":
|
|
1435
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component":
|
|
1433
|
+
"data-component": INTERNAL_SELECTOR_VALUE.WISHLIST.ELEMENT_BADGE_COUNTER,
|
|
1434
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component": INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1436
1435
|
BadgeCounter,
|
|
1437
1436
|
{
|
|
1438
1437
|
data: isJsVersion ? {
|
|
@@ -1456,8 +1455,8 @@ const Badge = (props) => {
|
|
|
1456
1455
|
"span",
|
|
1457
1456
|
{
|
|
1458
1457
|
className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`,
|
|
1459
|
-
"data-component":
|
|
1460
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component":
|
|
1458
|
+
"data-component": INTERNAL_SELECTOR_VALUE.WISHLIST.ELEMENT_BADGE_COUNTER,
|
|
1459
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component": INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1461
1460
|
BadgeCounter,
|
|
1462
1461
|
{
|
|
1463
1462
|
data: isJsVersion ? {
|
|
@@ -1480,8 +1479,8 @@ const Badge = (props) => {
|
|
|
1480
1479
|
"span",
|
|
1481
1480
|
{
|
|
1482
1481
|
className: `sledge-wishlist__badge-counter sledge-wishlist__badge-counter-bottom-right ${isMaximizeTotalWishlist ? "sledge-wishlist__badge-fit-content" : ""}`,
|
|
1483
|
-
"data-component":
|
|
1484
|
-
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component":
|
|
1482
|
+
"data-component": INTERNAL_SELECTOR_VALUE.WISHLIST.ELEMENT_BADGE_COUNTER,
|
|
1483
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { "data-component": INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1485
1484
|
BadgeCounter,
|
|
1486
1485
|
{
|
|
1487
1486
|
data: isJsVersion ? {
|
|
@@ -1498,15 +1497,21 @@ const Badge = (props) => {
|
|
|
1498
1497
|
};
|
|
1499
1498
|
return isFirstLoading ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: position === "none" ? /* @__PURE__ */ jsxRuntimeExports.jsx(HeaderMenu, {}) : String(position).includes("bottom") ? /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingIcon, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(FloatingFull, {}) });
|
|
1500
1499
|
};
|
|
1501
|
-
const BadgeCounterInitSelector = () => {
|
|
1502
|
-
|
|
1500
|
+
const BadgeCounterInitSelector = (props) => {
|
|
1501
|
+
const { selector = "", reload = false } = props || {};
|
|
1502
|
+
const getSelector = selector || SELECTOR.WISHLIST.ELEMENT_BADGE_COUNTER;
|
|
1503
|
+
let element = Array.from(document.querySelectorAll(getSelector));
|
|
1503
1504
|
let isElementDetected = !element || element && !element.length;
|
|
1504
1505
|
if (isElementDetected)
|
|
1505
1506
|
return;
|
|
1506
1507
|
element.map((item) => {
|
|
1507
1508
|
if (item) {
|
|
1508
|
-
if (item.
|
|
1509
|
-
|
|
1509
|
+
if ((item == null ? void 0 : item.hasAttribute("loaded")) && !reload)
|
|
1510
|
+
return;
|
|
1511
|
+
item.setAttribute("loaded", "");
|
|
1512
|
+
const getElementContainerWidgetQuery = item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`);
|
|
1513
|
+
if (getElementContainerWidgetQuery)
|
|
1514
|
+
getElementContainerWidgetQuery.remove();
|
|
1510
1515
|
let elementContainerWidget = document.createElement("div");
|
|
1511
1516
|
elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
|
|
1512
1517
|
item.appendChild(elementContainerWidget);
|
|
@@ -1530,9 +1535,11 @@ const BadgeCounterInitSelector = () => {
|
|
|
1530
1535
|
}
|
|
1531
1536
|
});
|
|
1532
1537
|
};
|
|
1533
|
-
const BadgeInitSelector = () => {
|
|
1538
|
+
const BadgeInitSelector = (props) => {
|
|
1539
|
+
const { selector = "", reload = false } = props || {};
|
|
1540
|
+
const getSelector = selector || SELECTOR.WISHLIST.ELEMENT_BADGE;
|
|
1534
1541
|
const sledgeWishlistSettings = localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.WISHLIST_SETTING) || null) : null;
|
|
1535
|
-
let element = Array.from(document.querySelectorAll(
|
|
1542
|
+
let element = Array.from(document.querySelectorAll(getSelector));
|
|
1536
1543
|
let isElementDetected = !element || element && !element.length;
|
|
1537
1544
|
if (!sledgeWishlistSettings || isElementDetected)
|
|
1538
1545
|
return;
|
|
@@ -1542,8 +1549,12 @@ const BadgeInitSelector = () => {
|
|
|
1542
1549
|
if (isBottomFloatingType) {
|
|
1543
1550
|
element.map((item, index) => {
|
|
1544
1551
|
if (item && !index) {
|
|
1545
|
-
if (item.
|
|
1546
|
-
|
|
1552
|
+
if ((item == null ? void 0 : item.hasAttribute("loaded")) && !reload)
|
|
1553
|
+
return;
|
|
1554
|
+
item.setAttribute("loaded", "");
|
|
1555
|
+
const getElementContainerWidgetQuery = item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`);
|
|
1556
|
+
if (getElementContainerWidgetQuery)
|
|
1557
|
+
getElementContainerWidgetQuery.remove();
|
|
1547
1558
|
let elementContainerWidget = document.createElement("div");
|
|
1548
1559
|
elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
|
|
1549
1560
|
item.appendChild(elementContainerWidget);
|
|
@@ -1570,8 +1581,12 @@ const BadgeInitSelector = () => {
|
|
|
1570
1581
|
} else {
|
|
1571
1582
|
element.map((item, index) => {
|
|
1572
1583
|
if (item && !index) {
|
|
1573
|
-
if (item.
|
|
1574
|
-
|
|
1584
|
+
if ((item == null ? void 0 : item.hasAttribute("loaded")) && !reload)
|
|
1585
|
+
return;
|
|
1586
|
+
item.setAttribute("loaded", "");
|
|
1587
|
+
const getElementContainerWidgetQuery = item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`);
|
|
1588
|
+
if (getElementContainerWidgetQuery)
|
|
1589
|
+
getElementContainerWidgetQuery.remove();
|
|
1575
1590
|
let elementContainerWidget = document.createElement("div");
|
|
1576
1591
|
elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
|
|
1577
1592
|
item.appendChild(elementContainerWidget);
|
|
@@ -1599,9 +1614,13 @@ const BadgeInitSelector = () => {
|
|
|
1599
1614
|
} else {
|
|
1600
1615
|
element.map((item) => {
|
|
1601
1616
|
if (item) {
|
|
1617
|
+
if ((item == null ? void 0 : item.hasAttribute("loaded")) && !reload)
|
|
1618
|
+
return;
|
|
1619
|
+
item.setAttribute("loaded", "");
|
|
1602
1620
|
const USE_PROXY_URL = item.getAttribute(DATASET_ATTRIBUTE_KEY.WISHLIST.USE_PROXY_URL);
|
|
1603
|
-
|
|
1604
|
-
|
|
1621
|
+
const getElementContainerWidgetQuery = item.querySelector(`[${SELECTOR_ATTRIBUTE_KEY}="${INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET}"]`);
|
|
1622
|
+
if (getElementContainerWidgetQuery)
|
|
1623
|
+
getElementContainerWidgetQuery.remove();
|
|
1605
1624
|
let elementContainerWidget = document.createElement("div");
|
|
1606
1625
|
elementContainerWidget.setAttribute(SELECTOR_ATTRIBUTE_KEY, INTERNAL_SELECTOR_VALUE.ELEMENT_CONTAINER_WIDGET);
|
|
1607
1626
|
item.appendChild(elementContainerWidget);
|
|
@@ -1628,7 +1647,7 @@ const BadgeInitSelector = () => {
|
|
|
1628
1647
|
};
|
|
1629
1648
|
const Trigger = (props) => {
|
|
1630
1649
|
var _a, _b, _c, _d, _e;
|
|
1631
|
-
const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked, triggerBadge = "default" } = props;
|
|
1650
|
+
const { params, forceActive = false, hidden = false, onAfterAddWishlist, onAfterRemoveWishlist, wishlistChecked, triggerBadge = "default", reload = false } = props;
|
|
1632
1651
|
const { productId, productVariantId } = params || {};
|
|
1633
1652
|
const { isRenderApp, triggerRenderMultipleComponent, sledgeAnonymId, isJsVersion } = React__default.useContext(SledgeContext);
|
|
1634
1653
|
const { wishlist: isRenderAppWishlist } = isRenderApp || {};
|
|
@@ -1651,7 +1670,7 @@ const Trigger = (props) => {
|
|
|
1651
1670
|
});
|
|
1652
1671
|
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
1653
1672
|
const [isFirstTime, setIsFirstTime] = React__default.useState(true);
|
|
1654
|
-
const [hasEntry, setHasEntry] = React__default.useState(
|
|
1673
|
+
const [hasEntry, setHasEntry] = React__default.useState(reload);
|
|
1655
1674
|
const [rootRef, rootEntry] = useIntersectionObserver({
|
|
1656
1675
|
threshold: 0,
|
|
1657
1676
|
root: null,
|
|
@@ -1700,9 +1719,9 @@ const Trigger = (props) => {
|
|
|
1700
1719
|
triggerRenderWishlistBadge(true);
|
|
1701
1720
|
if (isJsVersion) {
|
|
1702
1721
|
if (triggerBadge === "rerender") {
|
|
1703
|
-
BadgeInitSelector();
|
|
1722
|
+
BadgeInitSelector({ reload: true });
|
|
1704
1723
|
} else {
|
|
1705
|
-
BadgeCounterInitSelector();
|
|
1724
|
+
BadgeCounterInitSelector({ reload: true });
|
|
1706
1725
|
}
|
|
1707
1726
|
}
|
|
1708
1727
|
if (typeof window !== "undefined") {
|
|
@@ -1933,9 +1952,9 @@ const WidgetHeaderShareTrigger = ({ wishlistData, buttonText, showShareTrigger,
|
|
|
1933
1952
|
triggerRenderWishlistBadge(true);
|
|
1934
1953
|
if (isJsVersion) {
|
|
1935
1954
|
if (triggerBadge === "rerender") {
|
|
1936
|
-
BadgeInitSelector();
|
|
1955
|
+
BadgeInitSelector({ reload: true });
|
|
1937
1956
|
} else {
|
|
1938
|
-
BadgeCounterInitSelector();
|
|
1957
|
+
BadgeCounterInitSelector({ reload: true });
|
|
1939
1958
|
}
|
|
1940
1959
|
}
|
|
1941
1960
|
if (window.sledgeInfoPopup)
|
|
@@ -2245,7 +2264,8 @@ const Rating = (props) => {
|
|
|
2245
2264
|
outlineColor = "",
|
|
2246
2265
|
withOutlineColor = true,
|
|
2247
2266
|
customComponentId = "",
|
|
2248
|
-
numberOfIcons = 5
|
|
2267
|
+
numberOfIcons = 5,
|
|
2268
|
+
reload = false
|
|
2249
2269
|
} = props;
|
|
2250
2270
|
const { productId } = params || {};
|
|
2251
2271
|
const { isRenderApp, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
|
|
@@ -2267,7 +2287,7 @@ const Rating = (props) => {
|
|
|
2267
2287
|
const [averageReview, setAverageReview] = React__default.useState(((_b = propsData == null ? void 0 : propsData.rating) == null ? void 0 : _b.average) || average || "0");
|
|
2268
2288
|
const [dataSettings, setDataSettings] = React__default.useState((sledgeSettings == null ? void 0 : sledgeSettings.review) || {});
|
|
2269
2289
|
const [isFirstTime, setIsFirstTime] = React__default.useState(true);
|
|
2270
|
-
const [hasEntry, setHasEntry] = React__default.useState(
|
|
2290
|
+
const [hasEntry, setHasEntry] = React__default.useState(reload);
|
|
2271
2291
|
const previousState = usePrevious({ productId });
|
|
2272
2292
|
const [rootRef, rootEntry] = useIntersectionObserver({
|
|
2273
2293
|
threshold: 0,
|
|
@@ -4111,7 +4131,7 @@ const SearchIconWidgetPopup = () => {
|
|
|
4111
4131
|
setRedirectObject(valueRedirectObject);
|
|
4112
4132
|
setIsRedirect(valueIsRedirect);
|
|
4113
4133
|
setIsLoading(true);
|
|
4114
|
-
const { index_product, tabs, hidden_tags, display, show_out_of_stock } = data;
|
|
4134
|
+
const { index_product, tabs, hidden_tags, display, show_out_of_stock, attributes_to_retrieve } = data;
|
|
4115
4135
|
const suggestion = ((_b2 = display == null ? void 0 : display.search) == null ? void 0 : _b2.suggestion) || {};
|
|
4116
4136
|
let response;
|
|
4117
4137
|
let body = {
|
|
@@ -4127,7 +4147,8 @@ const SearchIconWidgetPopup = () => {
|
|
|
4127
4147
|
indexUid: index,
|
|
4128
4148
|
q: keyword,
|
|
4129
4149
|
hitsPerPage: isProductIndex ? 6 : 4,
|
|
4130
|
-
filter: isProductIndex ? [...new Set(additionalFilter)].join(" AND ") : ""
|
|
4150
|
+
filter: isProductIndex ? [...new Set(additionalFilter)].join(" AND ") : "",
|
|
4151
|
+
attributesToRetrieve: attributes_to_retrieve
|
|
4131
4152
|
};
|
|
4132
4153
|
})
|
|
4133
4154
|
};
|
|
@@ -5167,7 +5188,7 @@ const ButtonLoadMore = ({ text, onClick, isInfiniteScroll, currentPage, totalPag
|
|
|
5167
5188
|
] }) });
|
|
5168
5189
|
};
|
|
5169
5190
|
const SearchResultWidget = (props) => {
|
|
5170
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
5191
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
|
|
5171
5192
|
const {
|
|
5172
5193
|
layoutType = "default",
|
|
5173
5194
|
width = DEFAULT_MAX_WIDTH_COMPONENT,
|
|
@@ -5225,6 +5246,7 @@ const SearchResultWidget = (props) => {
|
|
|
5225
5246
|
const [defaultFilterItems, setDefaultFilterItems] = React__default.useState([]);
|
|
5226
5247
|
const [mobileShowSelectedSort, setMobileShowSelectedSort] = React__default.useState(true);
|
|
5227
5248
|
const [soldProductAtEnd, setSoldProductAtEnd] = React__default.useState(false);
|
|
5249
|
+
const [attributesToRetrieve, setAttributesToRetrieve] = React__default.useState(((_k = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _k.attributes_to_retrieve) || []);
|
|
5228
5250
|
const debouncedKeyword = useDebounce(keyword, 500);
|
|
5229
5251
|
let productCardsComponent = null;
|
|
5230
5252
|
let collectionCardsComponent = null;
|
|
@@ -5248,7 +5270,7 @@ const SearchResultWidget = (props) => {
|
|
|
5248
5270
|
});
|
|
5249
5271
|
const { isRenderApp, isJsVersion, triggerRenderMultipleComponent } = React__default.useContext(SledgeContext);
|
|
5250
5272
|
const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
|
|
5251
|
-
const { value: valueRenderInstantSearchResult, trigger: triggerRenderInstantSearchResult } = ((
|
|
5273
|
+
const { value: valueRenderInstantSearchResult, trigger: triggerRenderInstantSearchResult } = ((_l = triggerRenderMultipleComponent == null ? void 0 : triggerRenderMultipleComponent.instantSearch) == null ? void 0 : _l.searchResult) || {};
|
|
5252
5274
|
const searchResultContainerRef = React__default.useRef(null);
|
|
5253
5275
|
const previousState = usePrevious({ keyword });
|
|
5254
5276
|
const handleChangeTabIndex = (params2) => {
|
|
@@ -5438,7 +5460,8 @@ const SearchResultWidget = (props) => {
|
|
|
5438
5460
|
hierarchical_product_type,
|
|
5439
5461
|
hierarchical_collections,
|
|
5440
5462
|
mobile_show_selected_sort,
|
|
5441
|
-
sold_product_at_end
|
|
5463
|
+
sold_product_at_end,
|
|
5464
|
+
attributes_to_retrieve
|
|
5442
5465
|
} = response;
|
|
5443
5466
|
const { limit } = (display == null ? void 0 : display.search) || {};
|
|
5444
5467
|
let valueAllowedSorts = (allowed_sorts == null ? void 0 : allowed_sorts.length) ? collectionId ? allowed_sorts.map((allowed_sort) => {
|
|
@@ -5466,6 +5489,7 @@ const SearchResultWidget = (props) => {
|
|
|
5466
5489
|
setHierarchicalCollectionsSettings(hierarchical_collections);
|
|
5467
5490
|
setMobileShowSelectedSort(mobile_show_selected_sort);
|
|
5468
5491
|
setSoldProductAtEnd(sold_product_at_end);
|
|
5492
|
+
setAttributesToRetrieve(attributes_to_retrieve);
|
|
5469
5493
|
if (!show_out_of_stock)
|
|
5470
5494
|
setClickedFacets({
|
|
5471
5495
|
"variants.inventory_quantity": "> 0"
|
|
@@ -5507,8 +5531,8 @@ const SearchResultWidget = (props) => {
|
|
|
5507
5531
|
}, [debouncedKeyword, isFirstRender, isLoadingSetting]);
|
|
5508
5532
|
const filterHorizontalSkeletonComponent = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-skeleton", children: [1, 2, 3, 4, 5, 6, 7].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "106px", height: "42px", rounded: "md", color: "lighten" }, index)) });
|
|
5509
5533
|
const tabSkeleton = layoutType === "default" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-tab-list sledge-instant-search__result-tab-list-skeleton", children: [1, 2, 3, 4, 5].map((index) => /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "122px", height: "28px", rounded: "md", color: "lighten" }, index)) }) : null;
|
|
5510
|
-
const filterHorizontalSkeleton = ((
|
|
5511
|
-
const filterVerticalSkeleton = ((
|
|
5534
|
+
const filterHorizontalSkeleton = ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.enable_on_search) && ((_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.layout) === "horizontal" && !hideFilterWhenOneValue ? filterHorizontalSkeletonComponent : null;
|
|
5535
|
+
const filterVerticalSkeleton = ((_o = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _o.enable_on_search) && ((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.layout) === "vertical" && !hideFilterWhenOneValue ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5512
5536
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5513
5537
|
"div",
|
|
5514
5538
|
{
|
|
@@ -5724,7 +5748,7 @@ const SearchResultWidget = (props) => {
|
|
|
5724
5748
|
)
|
|
5725
5749
|
] }) : null;
|
|
5726
5750
|
const productGridSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5727
|
-
((
|
|
5751
|
+
((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.show_total_products) && ((_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-lg-on-mobile", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5728
5752
|
SkeletonLoading.Item,
|
|
5729
5753
|
{
|
|
5730
5754
|
width: "117px",
|
|
@@ -5745,12 +5769,12 @@ const SearchResultWidget = (props) => {
|
|
|
5745
5769
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary-select-field-item", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "150px", height: "42px", color: "lighten", rounded: "lg" }) })
|
|
5746
5770
|
] });
|
|
5747
5771
|
const searchAndSelectOptionSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
5748
|
-
((
|
|
5772
|
+
((_s = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _s.show_total_products) && ((_t = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _t.layout) === "horizontal" ? summaryTextSkeleton : null,
|
|
5749
5773
|
searchFieldSkeletonComponent,
|
|
5750
5774
|
selectOptionSkeletonComponent
|
|
5751
5775
|
] });
|
|
5752
5776
|
const mobileFilterWithSearchAndSelectOptionSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-mobile-on-lg sledge-instant-search__mobile-filter-search-skeleton", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
5753
|
-
((
|
|
5777
|
+
((_u = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _u.show_total_products) && ((_v = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _v.layout) === "horizontal" ? summaryTextSkeleton : null,
|
|
5754
5778
|
searchFieldSkeletonComponent,
|
|
5755
5779
|
filterHorizontalSkeletonComponent,
|
|
5756
5780
|
selectOptionSkeletonComponent
|
|
@@ -5783,7 +5807,7 @@ const SearchResultWidget = (props) => {
|
|
|
5783
5807
|
mobileFilterWithSearchAndSelectOptionSkeleton,
|
|
5784
5808
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-lg-on-mobile", children: filterHorizontalSkeleton }),
|
|
5785
5809
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-wrapper sledge-instant-search__result-wrapper-skeleton", children: [
|
|
5786
|
-
((
|
|
5810
|
+
((_w = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _w.enable_on_search) && ((_x = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _x.layout) === "vertical" && !hideFilterWhenOneValue ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter sledge__hide-element-lg-on-mobile", children: filterVerticalSkeleton }) : null,
|
|
5787
5811
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
|
|
5788
5812
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-lg-on-mobile", children: searchAndSelectOptionSkeleton }),
|
|
5789
5813
|
productGridSkeleton
|
|
@@ -5857,7 +5881,8 @@ const SearchResultWidget = (props) => {
|
|
|
5857
5881
|
setClickedOpenFilterHorizontalMobileId,
|
|
5858
5882
|
defaultFilterItems,
|
|
5859
5883
|
mobileShowSelectedSort,
|
|
5860
|
-
soldProductAtEnd
|
|
5884
|
+
soldProductAtEnd,
|
|
5885
|
+
attributesToRetrieve
|
|
5861
5886
|
})
|
|
5862
5887
|
] });
|
|
5863
5888
|
};
|
|
@@ -5918,7 +5943,8 @@ const ResultProduct = (props) => {
|
|
|
5918
5943
|
isFirstLoading,
|
|
5919
5944
|
defaultFilterItems,
|
|
5920
5945
|
mobileShowSelectedSort,
|
|
5921
|
-
soldProductAtEnd
|
|
5946
|
+
soldProductAtEnd,
|
|
5947
|
+
attributesToRetrieve
|
|
5922
5948
|
} = props || {};
|
|
5923
5949
|
const querySortBy = (query == null ? void 0 : query.sortBy) ? query.sortBy : DEFAULT_QUERY_PARAM.SORT_BY;
|
|
5924
5950
|
const queryPage = (query == null ? void 0 : query.page) ? query.page : DEFAULT_QUERY_PARAM.PAGE;
|
|
@@ -6200,6 +6226,7 @@ const ResultProduct = (props) => {
|
|
|
6200
6226
|
page: isReplaceData ? 1 : currentPage,
|
|
6201
6227
|
hitsPerPage: clickedLimitId,
|
|
6202
6228
|
facets,
|
|
6229
|
+
attributesToRetrieve,
|
|
6203
6230
|
filter
|
|
6204
6231
|
};
|
|
6205
6232
|
if (propsData && handleSearchResultFirstTime) {
|
|
@@ -6914,7 +6941,7 @@ const SearchWidget = (props) => {
|
|
|
6914
6941
|
setRedirectObject(valueRedirectObject);
|
|
6915
6942
|
setIsRedirect(valueIsRedirect);
|
|
6916
6943
|
setIsLoading(true);
|
|
6917
|
-
const { index_product, tabs, hidden_tags, display, show_out_of_stock } = data;
|
|
6944
|
+
const { index_product, tabs, hidden_tags, display, show_out_of_stock, attributes_to_retrieve } = data;
|
|
6918
6945
|
const suggestion = ((_b2 = display == null ? void 0 : display.search) == null ? void 0 : _b2.suggestion) || {};
|
|
6919
6946
|
let response;
|
|
6920
6947
|
let body = {
|
|
@@ -6930,7 +6957,8 @@ const SearchWidget = (props) => {
|
|
|
6930
6957
|
indexUid: index,
|
|
6931
6958
|
q: keyword,
|
|
6932
6959
|
hitsPerPage: isProductIndex ? 6 : 4,
|
|
6933
|
-
filter: isProductIndex ? [...new Set(additionalFilter)].join(" AND ") : ""
|
|
6960
|
+
filter: isProductIndex ? [...new Set(additionalFilter)].join(" AND ") : "",
|
|
6961
|
+
attributesToRetrieve: attributes_to_retrieve
|
|
6934
6962
|
};
|
|
6935
6963
|
})
|
|
6936
6964
|
};
|