@sledge-app/react-instant-search 1.0.90 → 1.0.91
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.map +1 -1
- package/dist/components/SearchIconWidget/SearchIconWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/Atoms.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/SearchResultWidgetInitSelector.d.ts.map +1 -1
- package/dist/components/SearchResultWidget/utils.d.ts +9 -0
- package/dist/components/SearchResultWidget/utils.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidgetInitSelector.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 +85 -58
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -11,11 +11,6 @@ const CDN_URL = "https://sledgeassets.nyc3.cdn.digitaloceanspaces.com";
|
|
|
11
11
|
const SELECTOR_ATTRIBUTE_KEY = "data-component";
|
|
12
12
|
const DATASET_ATTRIBUTE_KEY = {
|
|
13
13
|
GLOBAL: {
|
|
14
|
-
ON_AFTER_ADD_WISHLIST: "data-on-after-add-wishlist",
|
|
15
|
-
ON_AFTER_REMOVE_WISHLIST: "data-on-after-remove-wishlist",
|
|
16
|
-
ON_AFTER_ADD_TO_CART: "data-on-after-add-to-cart",
|
|
17
|
-
ON_AFTER_ADD_REVIEW: "data-on-after-add-review",
|
|
18
|
-
ON_AFTER_RENDER_PRODUCT: "data-on-after-render-product",
|
|
19
14
|
PRODUCT_ID: "data-product-id",
|
|
20
15
|
PRODUCT_VARIANT_ID: "data-product-variant-id",
|
|
21
16
|
PRODUCT_NAME: "data-product-name",
|
|
@@ -59,10 +54,6 @@ const DATASET_ATTRIBUTE_KEY = {
|
|
|
59
54
|
SHOW_RATING_AVERAGE: "data-show-rating-average"
|
|
60
55
|
},
|
|
61
56
|
INSTANT_SEARCH: {
|
|
62
|
-
ON_AFTER_RENDER_COLLECTION: "data-on-after-render-collection",
|
|
63
|
-
ON_AFTER_RENDER_PAGE: "data-on-after-render-page",
|
|
64
|
-
ON_AFTER_RENDER_BLOG: "data-on-after-render-blog",
|
|
65
|
-
ON_AFTER_RENDER_ARTICLE: "data-on-after-render-article",
|
|
66
57
|
QUERY_KEYWORD: "data-query-keyword",
|
|
67
58
|
QUERY_SORT_BY: "data-query-sort-by",
|
|
68
59
|
QUERY_PAGE: "data-query-page",
|
|
@@ -4629,8 +4620,60 @@ const handleConditionNotUpdateFacetDistribution = ({ value, clickedFacets }) =>
|
|
|
4629
4620
|
let isPriorityFacet = isHasFacetSelected && !isOnFacetSelectedOne && arrPriorityFacet.includes(value) && !isSelectedFacetWithPrice;
|
|
4630
4621
|
return isNoneFacetSelected || isOnFacetSelectedOne || isPriorityFacet;
|
|
4631
4622
|
};
|
|
4623
|
+
const handleFacetValues = ({
|
|
4624
|
+
filter,
|
|
4625
|
+
items,
|
|
4626
|
+
languageSettings,
|
|
4627
|
+
clickedFacets,
|
|
4628
|
+
searchFacetDistribution,
|
|
4629
|
+
displaySettings,
|
|
4630
|
+
settings
|
|
4631
|
+
}) => {
|
|
4632
|
+
var _a, _b;
|
|
4633
|
+
const { value, settings: filterSettings } = filter;
|
|
4634
|
+
let aliases = {};
|
|
4635
|
+
if (filter.value === "hierarchicalProductType")
|
|
4636
|
+
aliases = settings.productTypeAliases || {};
|
|
4637
|
+
if (filter.value === "hierarchicalCollections")
|
|
4638
|
+
aliases = settings.collectionAliases || {};
|
|
4639
|
+
const isHideFacetWhenZeroValue = (_a = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _a.hide_when_zero_value;
|
|
4640
|
+
const { prefix, filter_list, delete_prefix, selected_filter } = filterSettings || {};
|
|
4641
|
+
let facetValues = [];
|
|
4642
|
+
if (!(items == null ? void 0 : items.length))
|
|
4643
|
+
return facetValues;
|
|
4644
|
+
for (const item of items) {
|
|
4645
|
+
const isManualFilter = item && filter_list === "manual" && !(selected_filter == null ? void 0 : selected_filter.includes(item == null ? void 0 : item.value));
|
|
4646
|
+
const isPrefixFilter = item && filter_list === "prefix" && !(prefix == null ? void 0 : prefix.find((prefixItem) => {
|
|
4647
|
+
var _a2;
|
|
4648
|
+
return (_a2 = item == null ? void 0 : item.value) == null ? void 0 : _a2.startsWith(prefixItem);
|
|
4649
|
+
}));
|
|
4650
|
+
if (!item || isManualFilter || isPrefixFilter)
|
|
4651
|
+
continue;
|
|
4652
|
+
const isFacetHierarchical = Object.hasOwn(item, "children");
|
|
4653
|
+
let labelName = item.name;
|
|
4654
|
+
let getValue = isFacetHierarchical ? `${value}.lvl${item.level}` : value;
|
|
4655
|
+
if (languageSettings && (languageSettings[item.value] || languageSettings[item.name]))
|
|
4656
|
+
labelName = languageSettings[item.value] || languageSettings[item.name];
|
|
4657
|
+
let counter = handleConditionNotUpdateFacetDistribution({
|
|
4658
|
+
value: getValue,
|
|
4659
|
+
clickedFacets
|
|
4660
|
+
}) ? (item == null ? void 0 : item.total) || 0 : (searchFacetDistribution == null ? void 0 : searchFacetDistribution[getValue]) && ((_b = searchFacetDistribution == null ? void 0 : searchFacetDistribution[getValue]) == null ? void 0 : _b[item.value]) ? searchFacetDistribution[getValue][item.value] : 0;
|
|
4661
|
+
let getLabelName = aliases[labelName] || labelName;
|
|
4662
|
+
delete_prefix == null ? void 0 : delete_prefix.map((deletePrefix) => {
|
|
4663
|
+
if (String(getLabelName).startsWith(deletePrefix))
|
|
4664
|
+
getLabelName = String(getLabelName).replace(deletePrefix, "");
|
|
4665
|
+
});
|
|
4666
|
+
if (!(isHideFacetWhenZeroValue && !counter))
|
|
4667
|
+
facetValues.push({
|
|
4668
|
+
...item,
|
|
4669
|
+
labelName: getLabelName,
|
|
4670
|
+
counter
|
|
4671
|
+
});
|
|
4672
|
+
}
|
|
4673
|
+
return facetValues;
|
|
4674
|
+
};
|
|
4632
4675
|
const FacetComponent = (props) => {
|
|
4633
|
-
var _a, _b, _c
|
|
4676
|
+
var _a, _b, _c;
|
|
4634
4677
|
const {
|
|
4635
4678
|
filter,
|
|
4636
4679
|
isFirstLoading,
|
|
@@ -4663,11 +4706,6 @@ const FacetComponent = (props) => {
|
|
|
4663
4706
|
const [showFacet, setShowFacet] = React__default.useState(false);
|
|
4664
4707
|
const searchFacetRef = React__default.useRef(null);
|
|
4665
4708
|
const previousState = usePrevious({ keywordFacet });
|
|
4666
|
-
let aliases = {};
|
|
4667
|
-
if (filter.value === "hierarchicalProductType")
|
|
4668
|
-
aliases = settings.productTypeAliases || {};
|
|
4669
|
-
if (filter.value === "hierarchicalCollections")
|
|
4670
|
-
aliases = settings.collectionAliases || {};
|
|
4671
4709
|
const { button_load_more } = (generalDataSettings == null ? void 0 : generalDataSettings.languages) || {};
|
|
4672
4710
|
const { search_filter_placeholder, search_filter_show_more_result, search_filter_no_result } = languageSettings || {};
|
|
4673
4711
|
const {
|
|
@@ -4684,13 +4722,12 @@ const FacetComponent = (props) => {
|
|
|
4684
4722
|
...filter_option_text_transform && { textTransform: filter_option_text_transform }
|
|
4685
4723
|
};
|
|
4686
4724
|
let { value, label, display, indexFilter, items, settings: filterSettings } = filter;
|
|
4687
|
-
const {
|
|
4725
|
+
const { show_search, auto_select_search, hide_filter_list } = filterSettings || {};
|
|
4688
4726
|
const show_filter_list_when_search = !hide_filter_list;
|
|
4689
4727
|
if (isFirstLoading)
|
|
4690
4728
|
return null;
|
|
4691
4729
|
let blockComponent = null;
|
|
4692
4730
|
const isShowNumberMatchingProduct = (_b = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b.show_number_matching_product;
|
|
4693
|
-
const isHideFacetWhenZeroValue = (_c = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _c.hide_when_zero_value;
|
|
4694
4731
|
const isDisplaySlider = display.toLowerCase() === "slider";
|
|
4695
4732
|
const getValue = `${value}-${indexFilter}`;
|
|
4696
4733
|
if (show_search && keywordFacet && !isDisplaySlider)
|
|
@@ -4698,44 +4735,19 @@ const FacetComponent = (props) => {
|
|
|
4698
4735
|
var _a2, _b2;
|
|
4699
4736
|
return (_b2 = (_a2 = String(name)) == null ? void 0 : _a2.toLowerCase()) == null ? void 0 : _b2.includes(keywordFacet == null ? void 0 : keywordFacet.toLowerCase());
|
|
4700
4737
|
});
|
|
4701
|
-
const
|
|
4702
|
-
|
|
4703
|
-
|
|
4704
|
-
|
|
4705
|
-
|
|
4706
|
-
|
|
4707
|
-
|
|
4708
|
-
const isPrefixFilter = item && filter_list === "prefix" && !(prefix == null ? void 0 : prefix.find((prefixItem) => {
|
|
4709
|
-
var _a3;
|
|
4710
|
-
return (_a3 = item == null ? void 0 : item.value) == null ? void 0 : _a3.startsWith(prefixItem);
|
|
4711
|
-
}));
|
|
4712
|
-
if (!item || isManualFilter || isPrefixFilter)
|
|
4713
|
-
continue;
|
|
4714
|
-
const isFacetHierarchical = Object.hasOwn(item, "children");
|
|
4715
|
-
let labelName = item.name;
|
|
4716
|
-
let getValue2 = isFacetHierarchical ? `${value}.lvl${item.level}` : value;
|
|
4717
|
-
if (languageSettings && (languageSettings[item.value] || languageSettings[item.name]))
|
|
4718
|
-
labelName = languageSettings[item.value] || languageSettings[item.name];
|
|
4719
|
-
let counter = handleConditionNotUpdateFacetDistribution({
|
|
4720
|
-
value: getValue2,
|
|
4721
|
-
clickedFacets
|
|
4722
|
-
}) ? (item == null ? void 0 : item.total) || 0 : (searchFacetDistribution == null ? void 0 : searchFacetDistribution[getValue2]) && ((_a2 = searchFacetDistribution == null ? void 0 : searchFacetDistribution[getValue2]) == null ? void 0 : _a2[item.value]) ? searchFacetDistribution[getValue2][item.value] : 0;
|
|
4723
|
-
let getLabelName = aliases[labelName] || labelName;
|
|
4724
|
-
delete_prefix == null ? void 0 : delete_prefix.map((deletePrefix) => {
|
|
4725
|
-
if (String(getLabelName).startsWith(deletePrefix))
|
|
4726
|
-
getLabelName = String(getLabelName).replace(deletePrefix, "");
|
|
4727
|
-
});
|
|
4728
|
-
if (!(isHideFacetWhenZeroValue && !counter))
|
|
4729
|
-
facetValues.push({
|
|
4730
|
-
...item,
|
|
4731
|
-
labelName: getLabelName,
|
|
4732
|
-
counter
|
|
4733
|
-
});
|
|
4734
|
-
}
|
|
4735
|
-
return facetValues;
|
|
4738
|
+
const handleFacetValuesProps = {
|
|
4739
|
+
filter,
|
|
4740
|
+
languageSettings,
|
|
4741
|
+
clickedFacets,
|
|
4742
|
+
searchFacetDistribution,
|
|
4743
|
+
displaySettings,
|
|
4744
|
+
settings
|
|
4736
4745
|
};
|
|
4737
4746
|
const handleFacetLoadMore = ({ facetItems }) => {
|
|
4738
|
-
const arrFacetValues = isDisplaySlider ? facetItems : handleFacetValues(
|
|
4747
|
+
const arrFacetValues = isDisplaySlider ? facetItems : handleFacetValues({
|
|
4748
|
+
...handleFacetValuesProps,
|
|
4749
|
+
items: facetItems
|
|
4750
|
+
});
|
|
4739
4751
|
if (!is_item_pagination || isDisplaySlider) {
|
|
4740
4752
|
return {
|
|
4741
4753
|
haveNextPage: false,
|
|
@@ -4821,7 +4833,10 @@ const FacetComponent = (props) => {
|
|
|
4821
4833
|
var _a2, _b2;
|
|
4822
4834
|
const { facetValues, virtualized } = props2;
|
|
4823
4835
|
const { index, key } = virtualized || {};
|
|
4824
|
-
return (_b2 = handleFacetValues(
|
|
4836
|
+
return (_b2 = handleFacetValues({
|
|
4837
|
+
...handleFacetValuesProps,
|
|
4838
|
+
items: virtualized && ((_a2 = Object.keys(virtualized)) == null ? void 0 : _a2.length) ? [facetValues[index]] : facetValues
|
|
4839
|
+
})) == null ? void 0 : _b2.map((facetValue) => {
|
|
4825
4840
|
var _a3;
|
|
4826
4841
|
const { labelName, value: itemValue, counter, children, level } = facetValue;
|
|
4827
4842
|
const isFacetHierarchical = Object.hasOwn(facetValue, "children");
|
|
@@ -4981,7 +4996,7 @@ const FacetComponent = (props) => {
|
|
|
4981
4996
|
value: value2
|
|
4982
4997
|
};
|
|
4983
4998
|
}),
|
|
4984
|
-
defaultValue: clickedFacets && ((
|
|
4999
|
+
defaultValue: clickedFacets && ((_c = clickedFacets[value]) == null ? void 0 : _c.length) ? clickedFacets[value][0] : "",
|
|
4985
5000
|
labelStyle: filter_option_style,
|
|
4986
5001
|
useVirtualized: true,
|
|
4987
5002
|
selector: scrollElementSelector,
|
|
@@ -6389,7 +6404,7 @@ const ResultProduct = (props) => {
|
|
|
6389
6404
|
filter,
|
|
6390
6405
|
scrollElementSelector
|
|
6391
6406
|
}) => {
|
|
6392
|
-
var _a2;
|
|
6407
|
+
var _a2, _b2;
|
|
6393
6408
|
const { value, display, indexFilter } = filter;
|
|
6394
6409
|
let items = display.toLowerCase() === "tree" ? createHierarchicalFacet({
|
|
6395
6410
|
indexValue: value,
|
|
@@ -6403,7 +6418,19 @@ const ResultProduct = (props) => {
|
|
|
6403
6418
|
displaySettings,
|
|
6404
6419
|
searchFacetDistribution
|
|
6405
6420
|
}) : searchResultFacets[value];
|
|
6406
|
-
let isRender = Boolean(
|
|
6421
|
+
let isRender = Boolean(
|
|
6422
|
+
display.toLowerCase() === "slider" ? items : Number(
|
|
6423
|
+
(_a2 = handleFacetValues({
|
|
6424
|
+
filter,
|
|
6425
|
+
languageSettings,
|
|
6426
|
+
clickedFacets,
|
|
6427
|
+
searchFacetDistribution,
|
|
6428
|
+
displaySettings,
|
|
6429
|
+
settings,
|
|
6430
|
+
items
|
|
6431
|
+
})) == null ? void 0 : _a2.length
|
|
6432
|
+
)
|
|
6433
|
+
);
|
|
6407
6434
|
if (display.toLowerCase() === "slider") {
|
|
6408
6435
|
let defaultItemSlider = (defaultFacetStats == null ? void 0 : defaultFacetStats[value]) && Object.keys(defaultFacetStats[value]).length ? defaultFacetStats[value] : {};
|
|
6409
6436
|
let valueFilterSliderChange = [];
|
|
@@ -6458,7 +6485,7 @@ const ResultProduct = (props) => {
|
|
|
6458
6485
|
classesUlElement.push("sledge-instant-search__result-filter-item-color-swatches");
|
|
6459
6486
|
if (display.toLowerCase() === "tree")
|
|
6460
6487
|
classesUlElement.push("sledge-instant-search__result-filter-item-tree");
|
|
6461
|
-
if (((
|
|
6488
|
+
if (((_b2 = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _b2.layout) === "vertical" && (allowedFilter == null ? void 0 : allowedFilter.length) === 1)
|
|
6462
6489
|
classesUlElement == null ? void 0 : classesUlElement.push("sledge-instant-search__result-filter-item-list-just-one");
|
|
6463
6490
|
let isLastIndex = allowedFilter ? (allowedFilter == null ? void 0 : allowedFilter.length) - 1 === indexFilter : false;
|
|
6464
6491
|
return { isRender, classesUlElement, getFacetComponent, isLastIndex };
|