@sledge-app/react-instant-search 1.0.42 → 1.0.44
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/SearchResultWidget.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 +88 -72
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/package.json +1 -1
|
@@ -91,7 +91,8 @@ const LOCAL_STORAGE_KEY = {
|
|
|
91
91
|
PRODUCT_RECOMMENDATION_SETTING: "sledge-product-recommendation-setting",
|
|
92
92
|
ISSUED_AUTH_APP: "sledge-issued-auth-app",
|
|
93
93
|
EXPIRED_AUTH_APP: "sledge-expired-auth-app",
|
|
94
|
-
RECENTLY_VIEWED_APP: "sledge-recently-viewed"
|
|
94
|
+
RECENTLY_VIEWED_APP: "sledge-recently-viewed",
|
|
95
|
+
LIMIT_PRODUCT: "sledge-limit-product"
|
|
95
96
|
};
|
|
96
97
|
const INTERNAL_SELECTOR_VALUE = {
|
|
97
98
|
ELEMENT_TOAST_NOTIFICATION: "toast-notification",
|
|
@@ -143,6 +144,7 @@ const SELECTOR = {
|
|
|
143
144
|
ELEMENT_RELATED_PRODUCTS: `[${SELECTOR_ATTRIBUTE_KEY}="product-recommendation-related-prodcuts"]`
|
|
144
145
|
}
|
|
145
146
|
};
|
|
147
|
+
const DEFAULT_LIMIT_VALUE = [12, 24, 36, 48, 120];
|
|
146
148
|
const DEFAULT_MAX_WIDTH_COMPONENT = "1180px";
|
|
147
149
|
const DEFAULT_SEARCH_RESULT_URL = "/apps/sledge/search";
|
|
148
150
|
const DEFAULT_WISHLIST_URL = "/apps/sledge/wishlist";
|
|
@@ -157,6 +159,7 @@ const OBJECT_DATA_STRING_KEY = {
|
|
|
157
159
|
CURRENT_PAGE: "{{ current_page }}",
|
|
158
160
|
TOTAL_PAGE: "{{ total_page }}",
|
|
159
161
|
TOTAL_RESULT: "{{ total_result }}",
|
|
162
|
+
COLLECTION_ID: "{{ collection_id }}",
|
|
160
163
|
COLLECTION_NAME: "{{ collection_name }}",
|
|
161
164
|
TOTAL_WISHLIST: "{{ total_wishlist }}",
|
|
162
165
|
ACCEPTED_FILETYPE_MEDIA: "{{ accepted_filetype_media }}",
|
|
@@ -3892,6 +3895,7 @@ const SearchResultWidget = (props) => {
|
|
|
3892
3895
|
const [displaySettings, setDisplaySettings] = React__default.useState(((_f = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _f.display) || {});
|
|
3893
3896
|
const [colorSwatches, setColorSwatches] = React__default.useState(((_g = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _g.colors) || []);
|
|
3894
3897
|
const [defaultSort, setDefaultSort] = React__default.useState(((_h = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _h.default_sort) || "");
|
|
3898
|
+
const [defaultLimit, setDefaultLimit] = React__default.useState(DEFAULT_LIMIT_VALUE[0]);
|
|
3895
3899
|
const [showOutOfStock, setShowOutOfStock] = React__default.useState((_i = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _i.show_out_of_stock);
|
|
3896
3900
|
const [languageSettings, setLanguageSettings] = React__default.useState(((_j = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _j.languages) || {});
|
|
3897
3901
|
const [hierarchicalProductTypeSettings, setHierarchicalProductTypeSettings] = React__default.useState(((_k = sledgeSettings == null ? void 0 : sledgeSettings.instantsearch) == null ? void 0 : _k.hierarchical_product_type) || {});
|
|
@@ -3932,7 +3936,7 @@ const SearchResultWidget = (props) => {
|
|
|
3932
3936
|
setClickedTabIndexType(type);
|
|
3933
3937
|
setResultComponent(id.includes(indexProduct) ? /* @__PURE__ */ jsxRuntimeExports.jsx(ResultProduct, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(ResultCategory, {}));
|
|
3934
3938
|
};
|
|
3935
|
-
const handleInitStates = async (data
|
|
3939
|
+
const handleInitStates = async (data) => {
|
|
3936
3940
|
var _a2;
|
|
3937
3941
|
const { filters, index_product, tabs, hidden_tags, show_out_of_stock, display } = data;
|
|
3938
3942
|
let getTabs = layoutType === "product-filter" ? tabs.filter(({ index }) => index == null ? void 0 : index.includes(index_product)) : tabs;
|
|
@@ -3967,7 +3971,7 @@ const SearchResultWidget = (props) => {
|
|
|
3967
3971
|
setFacets(getFacets[0]);
|
|
3968
3972
|
return {
|
|
3969
3973
|
indexUid: index,
|
|
3970
|
-
q:
|
|
3974
|
+
q: keyword || "",
|
|
3971
3975
|
hitsPerPage: 1,
|
|
3972
3976
|
facets: isHasProductFacets ? getFacets[0] : [],
|
|
3973
3977
|
filter: isProductIndex ? additionalFilter.join(" AND ") : ""
|
|
@@ -3985,7 +3989,7 @@ const SearchResultWidget = (props) => {
|
|
|
3985
3989
|
setIsFirstLoading(false);
|
|
3986
3990
|
setIsLoadingSetting(false);
|
|
3987
3991
|
setIsLoading(false);
|
|
3988
|
-
const { facetDistribution } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(index_product))) || {};
|
|
3992
|
+
const { facetStats, totalHits, facetDistribution } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(index_product))) || {};
|
|
3989
3993
|
setSearchResultFacets(
|
|
3990
3994
|
facetDistribution ? Object.fromEntries(
|
|
3991
3995
|
Object.entries(facetDistribution).map((facet) => {
|
|
@@ -4011,26 +4015,23 @@ const SearchResultWidget = (props) => {
|
|
|
4011
4015
|
})
|
|
4012
4016
|
) : {}
|
|
4013
4017
|
);
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
}
|
|
4025
|
-
}
|
|
4026
|
-
)
|
|
4027
|
-
|
|
4028
|
-
const { facetStats, totalHits } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid.includes(index_product))) || {};
|
|
4029
|
-
setDefaultFacetStats(facetStats);
|
|
4030
|
-
setHideFilterWhenOneValue(((_a2 = display == null ? void 0 : display.filter) == null ? void 0 : _a2.hide_when_one_value) && totalHits <= 1);
|
|
4031
|
-
}
|
|
4018
|
+
setDefaultFacetStats(facetStats);
|
|
4019
|
+
setHideFilterWhenOneValue(((_a2 = display == null ? void 0 : display.filter) == null ? void 0 : _a2.hide_when_one_value) && totalHits <= 1);
|
|
4020
|
+
setAllowedTabs(
|
|
4021
|
+
tabs == null ? void 0 : tabs.map((tab) => {
|
|
4022
|
+
const { index } = tab;
|
|
4023
|
+
const { totalHits: totalHits2 } = (results == null ? void 0 : results.find(({ indexUid }) => indexUid === index)) || {};
|
|
4024
|
+
return {
|
|
4025
|
+
...tab,
|
|
4026
|
+
...{
|
|
4027
|
+
total: totalHits2
|
|
4028
|
+
}
|
|
4029
|
+
};
|
|
4030
|
+
})
|
|
4031
|
+
);
|
|
4032
4032
|
};
|
|
4033
4033
|
const handleSettings = async (LOCAL_STORAGE_INSTANT_SEARCH_SETTING) => {
|
|
4034
|
+
var _a2;
|
|
4034
4035
|
setIsLoadingSetting(true);
|
|
4035
4036
|
let response;
|
|
4036
4037
|
let getFirstIndex;
|
|
@@ -4038,13 +4039,28 @@ const SearchResultWidget = (props) => {
|
|
|
4038
4039
|
if (!response)
|
|
4039
4040
|
return;
|
|
4040
4041
|
const { allowed_sorts, default_sort, filters, index_product, tabs, hidden_tags, display, colors, show_out_of_stock, languages, hierarchical_product_type } = response;
|
|
4041
|
-
|
|
4042
|
+
const { limit } = (display == null ? void 0 : display.search) || {};
|
|
4043
|
+
let valueAllowedSorts = (allowed_sorts == null ? void 0 : allowed_sorts.length) ? collectionId ? allowed_sorts.map((allowed_sort) => {
|
|
4044
|
+
const { value, ...other_allowed_sort } = allowed_sort;
|
|
4045
|
+
return {
|
|
4046
|
+
...other_allowed_sort,
|
|
4047
|
+
value: String(value).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collectionId))
|
|
4048
|
+
};
|
|
4049
|
+
}) : allowed_sorts.filter((allowed_sort) => {
|
|
4050
|
+
const { value } = allowed_sort;
|
|
4051
|
+
if (!String(value).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID))
|
|
4052
|
+
return allowed_sort;
|
|
4053
|
+
}) : [];
|
|
4054
|
+
setAllowedSorts(valueAllowedSorts);
|
|
4042
4055
|
setAllowedFilters((filters == null ? void 0 : filters.length) ? filters : []);
|
|
4043
4056
|
setIndexProduct(index_product);
|
|
4044
4057
|
setHiddenTags(hidden_tags);
|
|
4045
4058
|
setDisplaySettings(display);
|
|
4046
4059
|
setColorSwatches(colors);
|
|
4047
|
-
setDefaultSort(
|
|
4060
|
+
setDefaultSort(
|
|
4061
|
+
collectionId ? String(default_sort).replaceAll(OBJECT_DATA_STRING_KEY.COLLECTION_ID, String(collectionId)) : String(default_sort).includes(OBJECT_DATA_STRING_KEY.COLLECTION_ID) ? (_a2 = valueAllowedSorts[0]) == null ? void 0 : _a2.value : default_sort
|
|
4062
|
+
);
|
|
4063
|
+
setDefaultLimit((localStorage == null ? void 0 : localStorage.getItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT)) || limit);
|
|
4048
4064
|
setShowOutOfStock(show_out_of_stock);
|
|
4049
4065
|
setLanguageSettings(languages);
|
|
4050
4066
|
setHierarchicalProductTypeSettings(hierarchical_product_type);
|
|
@@ -4054,9 +4070,13 @@ const SearchResultWidget = (props) => {
|
|
|
4054
4070
|
setClickedTabIndexName(getFirstIndex.name);
|
|
4055
4071
|
setClickedTabIndexType(getFirstIndex.type);
|
|
4056
4072
|
}
|
|
4057
|
-
await handleInitStates(response
|
|
4058
|
-
|
|
4059
|
-
|
|
4073
|
+
await handleInitStates(response);
|
|
4074
|
+
};
|
|
4075
|
+
const handleChangeKeyword = (value) => {
|
|
4076
|
+
const searchParams2 = new URLSearchParams(document.location.search);
|
|
4077
|
+
searchParams2.set(queryKeyword, value);
|
|
4078
|
+
setKeyword(value);
|
|
4079
|
+
window.history.pushState(null, "", `${document.location.pathname}?${searchParams2.toString()}`);
|
|
4060
4080
|
};
|
|
4061
4081
|
React__default.useEffect(() => {
|
|
4062
4082
|
if (!isRenderAppInstantSearch)
|
|
@@ -4073,11 +4093,11 @@ const SearchResultWidget = (props) => {
|
|
|
4073
4093
|
setKeyword(valueRenderInstantSearchResult);
|
|
4074
4094
|
}, [valueRenderInstantSearchResult]);
|
|
4075
4095
|
React__default.useEffect(() => {
|
|
4076
|
-
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)
|
|
4096
|
+
if (Boolean(previousState && (previousState == null ? void 0 : previousState.keyword) !== keyword)) {
|
|
4077
4097
|
const INSTANT_SEARCH_SETTING = JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "");
|
|
4078
4098
|
const delayDebounceFn = setTimeout(() => {
|
|
4079
4099
|
if (INSTANT_SEARCH_SETTING)
|
|
4080
|
-
handleInitStates(INSTANT_SEARCH_SETTING
|
|
4100
|
+
handleInitStates(INSTANT_SEARCH_SETTING);
|
|
4081
4101
|
}, 500);
|
|
4082
4102
|
return () => clearTimeout(delayDebounceFn);
|
|
4083
4103
|
}
|
|
@@ -4383,6 +4403,7 @@ const SearchResultWidget = (props) => {
|
|
|
4383
4403
|
displaySettings,
|
|
4384
4404
|
colorSwatches,
|
|
4385
4405
|
defaultSort,
|
|
4406
|
+
defaultLimit,
|
|
4386
4407
|
showOutOfStock,
|
|
4387
4408
|
languageSettings,
|
|
4388
4409
|
hierarchicalProductTypeSettings,
|
|
@@ -4417,12 +4438,13 @@ const SearchResultWidget = (props) => {
|
|
|
4417
4438
|
settings,
|
|
4418
4439
|
isReplaceWidgetList,
|
|
4419
4440
|
setIsReplaceWidgetList,
|
|
4420
|
-
searchResultFacets
|
|
4441
|
+
searchResultFacets,
|
|
4442
|
+
handleChangeKeyword
|
|
4421
4443
|
})
|
|
4422
4444
|
] });
|
|
4423
4445
|
};
|
|
4424
4446
|
const ResultProduct = (props) => {
|
|
4425
|
-
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, _y, _z
|
|
4447
|
+
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, _y, _z;
|
|
4426
4448
|
const {
|
|
4427
4449
|
layoutType,
|
|
4428
4450
|
keyword,
|
|
@@ -4437,6 +4459,7 @@ const ResultProduct = (props) => {
|
|
|
4437
4459
|
displaySettings,
|
|
4438
4460
|
colorSwatches,
|
|
4439
4461
|
defaultSort,
|
|
4462
|
+
defaultLimit,
|
|
4440
4463
|
showOutOfStock,
|
|
4441
4464
|
languageSettings,
|
|
4442
4465
|
hierarchicalProductTypeSettings,
|
|
@@ -4444,7 +4467,6 @@ const ResultProduct = (props) => {
|
|
|
4444
4467
|
params,
|
|
4445
4468
|
isJsVersion,
|
|
4446
4469
|
productCardsComponent,
|
|
4447
|
-
setKeyword,
|
|
4448
4470
|
filterHorizontalSkeleton,
|
|
4449
4471
|
filterHorizontalSkeletonComponent,
|
|
4450
4472
|
filterVerticalSkeleton,
|
|
@@ -4462,14 +4484,14 @@ const ResultProduct = (props) => {
|
|
|
4462
4484
|
settings,
|
|
4463
4485
|
isReplaceWidgetList,
|
|
4464
4486
|
setIsReplaceWidgetList,
|
|
4465
|
-
searchResultFacets
|
|
4487
|
+
searchResultFacets,
|
|
4488
|
+
handleChangeKeyword
|
|
4466
4489
|
} = props || {};
|
|
4467
|
-
const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
|
|
4468
4490
|
const { collectionId, collectionName } = params || {};
|
|
4469
4491
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
|
|
4470
4492
|
const [isLoading, setIsLoading] = React__default.useState(!propsData);
|
|
4471
4493
|
const [clickedSortId, setClickedSortId] = React__default.useState(defaultSort || "");
|
|
4472
|
-
const [clickedLimitId, setClickedLimitId] = React__default.useState((
|
|
4494
|
+
const [clickedLimitId, setClickedLimitId] = React__default.useState(Number(defaultLimit || DEFAULT_LIMIT_VALUE[0]));
|
|
4473
4495
|
const [clickedOpenFilterId, setClickedOpenFilterId] = React__default.useState(null);
|
|
4474
4496
|
const [clickedOpenFilters, setClickedOpenFilters] = React__default.useState([]);
|
|
4475
4497
|
const [clickedFacets, setClickedFacets] = React__default.useState({
|
|
@@ -4478,11 +4500,11 @@ const ResultProduct = (props) => {
|
|
|
4478
4500
|
} : {}
|
|
4479
4501
|
});
|
|
4480
4502
|
const [triggerClickedFacets, setTriggerClickedFacets] = React__default.useState(false);
|
|
4481
|
-
const [searchResult, setSearchResult] = React__default.useState(((
|
|
4503
|
+
const [searchResult, setSearchResult] = React__default.useState(((_c = (_b = (_a = propsData == null ? void 0 : propsData.result) == null ? void 0 : _a.results) == null ? void 0 : _b[0]) == null ? void 0 : _c.hits) || []);
|
|
4482
4504
|
const [searchProcessingTimeMs, setSearchProcessingTimeMs] = React__default.useState(0);
|
|
4483
4505
|
const [currentPage, setCurrentPage] = React__default.useState(1);
|
|
4484
4506
|
const [totalPage, setTotalPage] = React__default.useState(0);
|
|
4485
|
-
const [totalSearchResult, setTotalSearchResult] = React__default.useState(((
|
|
4507
|
+
const [totalSearchResult, setTotalSearchResult] = React__default.useState(((_f = (_e = (_d = propsData == null ? void 0 : propsData.result) == null ? void 0 : _d.results) == null ? void 0 : _e[0]) == null ? void 0 : _f.totalHits) || 0);
|
|
4486
4508
|
const [valueFilterPriceChange, setValueFilterPriceChange] = React__default.useState([]);
|
|
4487
4509
|
const [allowedFilter, setAllowedFilter] = React__default.useState([]);
|
|
4488
4510
|
const [handleSearchResultFirstTime, setHandleSearchResultFirstTime] = React__default.useState(true);
|
|
@@ -4526,13 +4548,13 @@ const ResultProduct = (props) => {
|
|
|
4526
4548
|
};
|
|
4527
4549
|
const [summaryText, setSummaryText] = React__default.useState(propsData ? summaryTextGenerator(totalSearchResult) : null);
|
|
4528
4550
|
const previousState = usePrevious({ keyword, clickedLimitId, clickedFacets, clickedTabIndexId });
|
|
4529
|
-
const { color: filter_title_color, font_size: filter_title_font_size, font_weight: filter_title_font_weight, text_transform: filter_title_text_transform } = ((
|
|
4551
|
+
const { color: filter_title_color, font_size: filter_title_font_size, font_weight: filter_title_font_weight, text_transform: filter_title_text_transform } = ((_g = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _g.title) || {};
|
|
4530
4552
|
const {
|
|
4531
4553
|
color: filter_option_color,
|
|
4532
4554
|
font_size: filter_option_font_size,
|
|
4533
4555
|
font_weight: filter_option_font_weight,
|
|
4534
4556
|
text_transform: filter_option_text_transform
|
|
4535
|
-
} = ((
|
|
4557
|
+
} = ((_h = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _h.option) || {};
|
|
4536
4558
|
const {
|
|
4537
4559
|
text_color: filter_button_text_color,
|
|
4538
4560
|
border_color: filter_button_border_color,
|
|
@@ -4545,7 +4567,7 @@ const ResultProduct = (props) => {
|
|
|
4545
4567
|
font_size: filter_button_font_size,
|
|
4546
4568
|
font_weight: filter_button_font_weight,
|
|
4547
4569
|
text_transform: filter_button_text_transform
|
|
4548
|
-
} = ((
|
|
4570
|
+
} = ((_i = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _i.button) || {};
|
|
4549
4571
|
const filter_title_style = {
|
|
4550
4572
|
...filter_title_color && { color: filter_title_color },
|
|
4551
4573
|
...filter_title_font_size && { fontSize: filter_title_font_size },
|
|
@@ -4607,11 +4629,12 @@ const ResultProduct = (props) => {
|
|
|
4607
4629
|
}).toString();
|
|
4608
4630
|
window.history.pushState(null, "", `${document.location.pathname}${(newQueryString == null ? void 0 : newQueryString.length) ? `?${newQueryString}` : ""}`);
|
|
4609
4631
|
};
|
|
4610
|
-
const handleChangeSort = (
|
|
4632
|
+
const handleChangeSort = (value) => {
|
|
4611
4633
|
setClickedSortId(value);
|
|
4612
4634
|
};
|
|
4613
4635
|
const handleChangeLimit = (value) => {
|
|
4614
|
-
setClickedLimitId(value);
|
|
4636
|
+
setClickedLimitId(Number(value));
|
|
4637
|
+
localStorage == null ? void 0 : localStorage.setItem(LOCAL_STORAGE_KEY.LIMIT_PRODUCT, value);
|
|
4615
4638
|
};
|
|
4616
4639
|
const handleOpenFilterVertical = (id) => {
|
|
4617
4640
|
setClickedOpenFilterId(id === clickedOpenFilterId ? "" : id);
|
|
@@ -4802,12 +4825,6 @@ const ResultProduct = (props) => {
|
|
|
4802
4825
|
});
|
|
4803
4826
|
}, 200);
|
|
4804
4827
|
};
|
|
4805
|
-
const handleChangeKeyword = (value) => {
|
|
4806
|
-
const searchParams = new URLSearchParams(document.location.search);
|
|
4807
|
-
searchParams.set(queryKeyword, value);
|
|
4808
|
-
setKeyword && setKeyword(value);
|
|
4809
|
-
window.history.pushState(null, "", `${document.location.pathname}?${searchParams.toString()}`);
|
|
4810
|
-
};
|
|
4811
4828
|
React__default.useEffect(() => {
|
|
4812
4829
|
let isRefreshSearchResult = Boolean(
|
|
4813
4830
|
previousState && ((previousState == null ? void 0 : previousState.keyword) !== keyword || (previousState == null ? void 0 : previousState.clickedLimitId) !== clickedLimitId || (previousState == null ? void 0 : previousState.clickedFacets) !== clickedFacets)
|
|
@@ -5155,9 +5172,9 @@ const ResultProduct = (props) => {
|
|
|
5155
5172
|
) }, indexFilter) : null;
|
|
5156
5173
|
});
|
|
5157
5174
|
const paginationComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Pagination, { currentPage, totalPage, totalResult: totalSearchResult, onChange: (page) => handlePageChange(page), pageInfo: language_pagination_info });
|
|
5158
|
-
const filterHorizontalBlockComponent = ((
|
|
5175
|
+
const filterHorizontalBlockComponent = ((_j = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _j.enable_on_search) && allowedFilter.length ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isFirstLoading && !propsData ? filterHorizontalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isLoadingSetting && !propsData ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-loading", children: filterHorizontalSkeleton }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal-wrapper", children: [
|
|
5159
5176
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal sledge-instant-search__result-filter-horizontal-component", children: filterHorizontalComponents }),
|
|
5160
|
-
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((
|
|
5177
|
+
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_k = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _k.show_refine_by_block)) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal", children: [
|
|
5161
5178
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5162
5179
|
"div",
|
|
5163
5180
|
{
|
|
@@ -5178,10 +5195,10 @@ const ResultProduct = (props) => {
|
|
|
5178
5195
|
] }) : null
|
|
5179
5196
|
] }) }) }) : null;
|
|
5180
5197
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5181
|
-
((
|
|
5182
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", "data-filter-layout": (
|
|
5183
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: ((
|
|
5184
|
-
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((
|
|
5198
|
+
((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.enable_on_search) && ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.layout) === "horizontal" && allowedFilter.length ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-lg-on-mobile", children: filterHorizontalBlockComponent }) : null,
|
|
5199
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-wrapper", "data-filter-layout": (_n = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _n.layout, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5200
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: ((_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" && allowedFilter.length ? isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter sledge__hide-element-lg-on-mobile", children: filterVerticalSkeleton }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter sledge__hide-element-lg-on-mobile", children: isLoadingSetting ? filterVerticalSkeleton : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5201
|
+
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.show_refine_by_block)) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item", children: [
|
|
5185
5202
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-item-title-refine", children: [
|
|
5186
5203
|
/* @__PURE__ */ jsxRuntimeExports.jsx("strong", { className: "sledge-instant-search__result-filter-item-title-refine-heading", children: language_filter || "Filter" }),
|
|
5187
5204
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__result-filter-item-title-refine-clear", onClick: handleFilterReset, children: language_clear_filter || "Clear All" })
|
|
@@ -5201,7 +5218,7 @@ const ResultProduct = (props) => {
|
|
|
5201
5218
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data", children: [
|
|
5202
5219
|
isFirstLoading ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5203
5220
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-mobile-on-lg", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-data-keyword", children: [
|
|
5204
|
-
((
|
|
5221
|
+
((_r = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _r.show_total_products) ? summaryTextSkeleton : null,
|
|
5205
5222
|
searchFieldSkeletonComponent,
|
|
5206
5223
|
filterHorizontalSkeletonComponent,
|
|
5207
5224
|
selectOptionSkeletonComponent
|
|
@@ -5211,7 +5228,7 @@ const ResultProduct = (props) => {
|
|
|
5211
5228
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5212
5229
|
"div",
|
|
5213
5230
|
{
|
|
5214
|
-
className: `sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal ${((
|
|
5231
|
+
className: `sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal ${((_s = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _s.layout) === "horizontal" ? "" : "sledge__hide-element-mobile-on-lg"}`,
|
|
5215
5232
|
children: summaryText
|
|
5216
5233
|
}
|
|
5217
5234
|
),
|
|
@@ -5222,8 +5239,8 @@ const ResultProduct = (props) => {
|
|
|
5222
5239
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
5223
5240
|
placeholder: (language_search_form_placeholder == null ? void 0 : language_search_form_placeholder.product) || "Search products...",
|
|
5224
5241
|
value: keyword,
|
|
5225
|
-
onChange: ({ value }) => handleChangeKeyword(value),
|
|
5226
|
-
onResetField: () => handleChangeKeyword(""),
|
|
5242
|
+
onChange: ({ value }) => handleChangeKeyword == null ? void 0 : handleChangeKeyword(value),
|
|
5243
|
+
onResetField: () => handleChangeKeyword == null ? void 0 : handleChangeKeyword(""),
|
|
5227
5244
|
className: "sledge-instant-search__result-data-keyword-form",
|
|
5228
5245
|
withClearField: true
|
|
5229
5246
|
}
|
|
@@ -5253,8 +5270,8 @@ const ResultProduct = (props) => {
|
|
|
5253
5270
|
value
|
|
5254
5271
|
};
|
|
5255
5272
|
}),
|
|
5256
|
-
value: clickedSortId
|
|
5257
|
-
onChange: ({
|
|
5273
|
+
value: clickedSortId,
|
|
5274
|
+
onChange: ({ value }) => handleChangeSort(value)
|
|
5258
5275
|
}
|
|
5259
5276
|
)
|
|
5260
5277
|
] }),
|
|
@@ -5263,7 +5280,7 @@ const ResultProduct = (props) => {
|
|
|
5263
5280
|
language_limit || "Limit",
|
|
5264
5281
|
":"
|
|
5265
5282
|
] }),
|
|
5266
|
-
((
|
|
5283
|
+
((_t = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _t.allowed_limit) && Boolean((_v = (_u = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _u.allowed_limit) == null ? void 0 : _v.length) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5267
5284
|
SelectField,
|
|
5268
5285
|
{
|
|
5269
5286
|
align: "end",
|
|
@@ -5284,7 +5301,7 @@ const ResultProduct = (props) => {
|
|
|
5284
5301
|
productGridSkeleton,
|
|
5285
5302
|
(searchResult == null ? void 0 : searchResult.length) ? paginationComponent : null
|
|
5286
5303
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5287
|
-
((
|
|
5304
|
+
((_w = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _w.layout) === "vertical" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-lg-on-mobile", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-vertical", children: summaryText }) }),
|
|
5288
5305
|
(searchResult == null ? void 0 : searchResult.length) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5289
5306
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5290
5307
|
ProductGrid,
|
|
@@ -5299,9 +5316,9 @@ const ResultProduct = (props) => {
|
|
|
5299
5316
|
};
|
|
5300
5317
|
}),
|
|
5301
5318
|
setting: {
|
|
5302
|
-
show_vendor: (
|
|
5303
|
-
show_sku: (
|
|
5304
|
-
show_price: (
|
|
5319
|
+
show_vendor: (_x = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _x.show_vendor,
|
|
5320
|
+
show_sku: (_y = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _y.show_sku,
|
|
5321
|
+
show_price: (_z = displaySettings == null ? void 0 : displaySettings.search) == null ? void 0 : _z.show_price,
|
|
5305
5322
|
language_button_add_to_cart: language_add_to_cart,
|
|
5306
5323
|
language_button_out_of_stock: languageSettings && languageSettings["out of stock"] ? languageSettings["out of stock"] : ""
|
|
5307
5324
|
},
|
|
@@ -5335,7 +5352,6 @@ const ResultCategory = (props) => {
|
|
|
5335
5352
|
pageCardsComponent,
|
|
5336
5353
|
blogCardsComponent,
|
|
5337
5354
|
articleCardsComponent,
|
|
5338
|
-
setKeyword,
|
|
5339
5355
|
searchResultContainerRef,
|
|
5340
5356
|
onAfterRenderCollection,
|
|
5341
5357
|
onAfterRenderPage,
|
|
@@ -5343,11 +5359,11 @@ const ResultCategory = (props) => {
|
|
|
5343
5359
|
onAfterRenderArticle,
|
|
5344
5360
|
languageSettings,
|
|
5345
5361
|
isReplaceWidgetList,
|
|
5346
|
-
setIsReplaceWidgetList
|
|
5362
|
+
setIsReplaceWidgetList,
|
|
5363
|
+
handleChangeKeyword
|
|
5347
5364
|
} = props || {};
|
|
5348
5365
|
const [isFirstLoading, setIsFirstLoading] = React__default.useState(true);
|
|
5349
5366
|
const [isLoading, setIsLoading] = React__default.useState(true);
|
|
5350
|
-
const [clickedSortId, setClickedSortId] = React__default.useState("");
|
|
5351
5367
|
const [searchResult, setSearchResult] = React__default.useState([]);
|
|
5352
5368
|
const [searchProcessingTimeMs, setSearchProcessingTimeMs] = React__default.useState(0);
|
|
5353
5369
|
const [currentPage, setCurrentPage] = React__default.useState(1);
|
|
@@ -5405,7 +5421,7 @@ const ResultCategory = (props) => {
|
|
|
5405
5421
|
let response;
|
|
5406
5422
|
let body = {
|
|
5407
5423
|
q: keyword,
|
|
5408
|
-
sort:
|
|
5424
|
+
sort: [],
|
|
5409
5425
|
page: isRefreshPage ? 1 : currentPage,
|
|
5410
5426
|
hitsPerPage: 12
|
|
5411
5427
|
};
|
|
@@ -5431,7 +5447,7 @@ const ResultCategory = (props) => {
|
|
|
5431
5447
|
} else {
|
|
5432
5448
|
handleSearchResult();
|
|
5433
5449
|
}
|
|
5434
|
-
}, [
|
|
5450
|
+
}, [keyword]);
|
|
5435
5451
|
React__default.useEffect(() => {
|
|
5436
5452
|
let isRefreshSearchResult = Boolean(previousState && (previousState == null ? void 0 : previousState.clickedTabIndexId) !== clickedTabIndexId);
|
|
5437
5453
|
if (isReplaceWidgetList || isRefreshSearchResult) {
|
|
@@ -5445,8 +5461,8 @@ const ResultCategory = (props) => {
|
|
|
5445
5461
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 18, height: 18, color: "#868686" }),
|
|
5446
5462
|
placeholder: clickedTabIndexType && language_search_form_placeholder[clickedTabIndexType] ? language_search_form_placeholder[clickedTabIndexType] : `Search ${clickedTabIndexName ? clickedTabIndexName.toLowerCase() : ""}...`,
|
|
5447
5463
|
value: keyword,
|
|
5448
|
-
onChange: ({ value }) =>
|
|
5449
|
-
onResetField: () =>
|
|
5464
|
+
onChange: ({ value }) => handleChangeKeyword == null ? void 0 : handleChangeKeyword(value),
|
|
5465
|
+
onResetField: () => handleChangeKeyword == null ? void 0 : handleChangeKeyword(""),
|
|
5450
5466
|
className: "sledge-instant-search__result-data-keyword-form",
|
|
5451
5467
|
withClearField: true
|
|
5452
5468
|
}
|