@sledge-app/react-instant-search 1.0.27 → 1.0.29
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/SearchResultWidget.d.ts.map +1 -1
- package/dist/components/SearchWidget/SearchWidget.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 +42 -15
- package/dist/sledge-react-instant-search.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1212,7 +1212,7 @@ const Trigger = (props) => {
|
|
|
1212
1212
|
const [isFirstTime, setIsFirstTime] = React__default.useState(true);
|
|
1213
1213
|
const { is_required_login } = ((_b = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _b.global) || {};
|
|
1214
1214
|
const { show: show_notification, location: location_notification } = ((_c = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _c.notification) || {};
|
|
1215
|
-
const { title_added_to_wishlist, text_added_to_wishlist, title_removed_to_wishlist, text_removed_to_wishlist } = ((_d = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _d.notification) || {};
|
|
1215
|
+
const { title_added_to_wishlist, text_added_to_wishlist, title_removed_to_wishlist, text_removed_to_wishlist, title_fail_add_to_wishlist, text_fail_add_to_wishlist } = ((_d = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _d.notification) || {};
|
|
1216
1216
|
const handleCheckWishlist = async () => {
|
|
1217
1217
|
let response;
|
|
1218
1218
|
if (typeof wishlistChecked === "boolean" && isFirstTime) {
|
|
@@ -1274,8 +1274,8 @@ const Trigger = (props) => {
|
|
|
1274
1274
|
}
|
|
1275
1275
|
if (typeof window !== "undefined" && window.sledgeToastNotification && show_notification)
|
|
1276
1276
|
window.sledgeToastNotification({
|
|
1277
|
-
title: "Failed",
|
|
1278
|
-
message: "failed add to wishlist",
|
|
1277
|
+
title: title_fail_add_to_wishlist || "Failed",
|
|
1278
|
+
message: text_fail_add_to_wishlist || "failed add to wishlist",
|
|
1279
1279
|
location: location_notification,
|
|
1280
1280
|
type: "failed",
|
|
1281
1281
|
icon: /* @__PURE__ */ jsxRuntimeExports.jsx(HeartIcon, { width: 40, height: 40, color: "black", type: "outline" })
|
|
@@ -1627,10 +1627,11 @@ const WidgetHeaderLimit = ({ limitOptions, selectedLimit, setSelectedLimit, setI
|
|
|
1627
1627
|
}
|
|
1628
1628
|
) }) }) : null });
|
|
1629
1629
|
};
|
|
1630
|
-
const WidgetHeaderSort$1 = ({ wishlistSort, selectedSort, setSelectedSort, setIsRefreshWidgetList, dataSettings }) => {
|
|
1630
|
+
const WidgetHeaderSort$1 = ({ wishlistSort, selectedSort, setSelectedSort, setIsRefreshWidgetList, dataSettings, generalDataSettings }) => {
|
|
1631
1631
|
var _a;
|
|
1632
1632
|
const { sledgeAnonymId } = React__default.useContext(SledgeContext);
|
|
1633
1633
|
const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
|
|
1634
|
+
const { sort_placeholder } = (generalDataSettings == null ? void 0 : generalDataSettings.languages) || {};
|
|
1634
1635
|
const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
|
|
1635
1636
|
const handleChangeSort = (value) => {
|
|
1636
1637
|
setSelectedSort && setSelectedSort(value);
|
|
@@ -1652,7 +1653,7 @@ const WidgetHeaderSort$1 = ({ wishlistSort, selectedSort, setSelectedSort, setIs
|
|
|
1652
1653
|
}),
|
|
1653
1654
|
value: selectedSort,
|
|
1654
1655
|
onChange: ({ value }) => handleChangeSort(value),
|
|
1655
|
-
placeholder: "- Select -"
|
|
1656
|
+
placeholder: sort_placeholder || "- Select -"
|
|
1656
1657
|
}
|
|
1657
1658
|
) }) }) : null });
|
|
1658
1659
|
};
|
|
@@ -2031,21 +2032,22 @@ const WidgetHeaderAddTrigger = ({ isFirstLoadingHeader, text, dataSettings, para
|
|
|
2031
2032
|
) });
|
|
2032
2033
|
};
|
|
2033
2034
|
const WidgetHeaderSort = ({ isFirstLoadingHeader, productReviewSort, dataSettings, setSelectedSort, setIsRefreshWidgetList }) => {
|
|
2034
|
-
var _a, _b;
|
|
2035
|
+
var _a, _b, _c;
|
|
2035
2036
|
const { default_sort, show_sorting_options } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.widget) || {};
|
|
2037
|
+
const { sort_by: language_sort_by } = ((_b = dataSettings == null ? void 0 : dataSettings.languages) == null ? void 0 : _b.widget) || {};
|
|
2036
2038
|
const [clickedSortId, setClickedSortId] = React__default.useState(default_sort || null);
|
|
2037
2039
|
const handleChangeSort = (value) => {
|
|
2038
2040
|
setClickedSortId(value);
|
|
2039
2041
|
setIsRefreshWidgetList && setIsRefreshWidgetList(true);
|
|
2040
2042
|
setSelectedSort && setSelectedSort(value);
|
|
2041
2043
|
};
|
|
2042
|
-
const getSelectedSort = clickedSortId || ((
|
|
2044
|
+
const getSelectedSort = clickedSortId || ((_c = productReviewSort[0]) == null ? void 0 : _c.value);
|
|
2043
2045
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: !show_sorting_options ? null : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-product-review__widget-header-item", children: isFirstLoadingHeader ? /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "134px", height: "42px", rounded: "lg", color: "lighten" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
2044
2046
|
SelectField,
|
|
2045
2047
|
{
|
|
2046
2048
|
align: "end",
|
|
2047
2049
|
prefixLabel: /* @__PURE__ */ jsxRuntimeExports.jsx(SwapIcon, { width: 16, height: 16, color: "currentColor" }),
|
|
2048
|
-
prefixSelectedLabel: "Sort by",
|
|
2050
|
+
prefixSelectedLabel: language_sort_by || "Sort by",
|
|
2049
2051
|
options: productReviewSort.map((item) => {
|
|
2050
2052
|
const { name, value } = item;
|
|
2051
2053
|
return {
|
|
@@ -2625,6 +2627,7 @@ ${selectedOption === item2 ? "sledge__product-variant-size-swatch-active" : ""}
|
|
|
2625
2627
|
{
|
|
2626
2628
|
type: "button",
|
|
2627
2629
|
colorType: "light",
|
|
2630
|
+
className: "sledge__product-grid-button-add-to-cart",
|
|
2628
2631
|
style: {
|
|
2629
2632
|
...display_button_add_to_cart_style,
|
|
2630
2633
|
...isLoadingAddToCart && {
|
|
@@ -3503,6 +3506,14 @@ const SearchIconWidgetPopup = () => {
|
|
|
3503
3506
|
value: keyword,
|
|
3504
3507
|
fieldRef: searchFieldRef,
|
|
3505
3508
|
onChange: ({ value }) => setKeyword(value),
|
|
3509
|
+
onKeyDown: (event) => {
|
|
3510
|
+
if (event.key === "Enter") {
|
|
3511
|
+
const query = handleFunctions.query;
|
|
3512
|
+
const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
|
|
3513
|
+
const urlToSearchResult = `${urlSearchResult || DEFAULT_SEARCH_RESULT_URL}?${queryKeyword}=${keyword}`;
|
|
3514
|
+
window.location.href = urlToSearchResult;
|
|
3515
|
+
}
|
|
3516
|
+
},
|
|
3506
3517
|
className: "sledge-instant-search__icon-widget-search-form-field",
|
|
3507
3518
|
withClearField: true
|
|
3508
3519
|
}
|
|
@@ -4082,7 +4093,7 @@ const SearchResultWidget = (props) => {
|
|
|
4082
4093
|
)
|
|
4083
4094
|
] }) : null;
|
|
4084
4095
|
const productGridSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
4085
|
-
((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.show_total_products) && ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4096
|
+
((_p = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _p.show_total_products) && ((_q = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _q.layout) === "vertical" ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge__hide-element-lg-on-mobile", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4086
4097
|
SkeletonLoading.Item,
|
|
4087
4098
|
{
|
|
4088
4099
|
width: "117px",
|
|
@@ -4093,7 +4104,7 @@ const SearchResultWidget = (props) => {
|
|
|
4093
4104
|
marginBottom: "21px"
|
|
4094
4105
|
}
|
|
4095
4106
|
}
|
|
4096
|
-
) : null,
|
|
4107
|
+
) }) : null,
|
|
4097
4108
|
/* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.ProductGrid, { count: 12, type: "large" })
|
|
4098
4109
|
] });
|
|
4099
4110
|
const summaryTextSkeleton = /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-data-summary sledge-instant-search__result-data-summary-filter-horizontal", children: /* @__PURE__ */ jsxRuntimeExports.jsx(SkeletonLoading.Item, { width: "117px", height: "28px", color: "lighten", rounded: "md" }) });
|
|
@@ -4762,13 +4773,22 @@ const ResultProduct = (props) => {
|
|
|
4762
4773
|
if (display.toLowerCase() === "swatch" && (items == null ? void 0 : items.length)) {
|
|
4763
4774
|
classesUlElement.push("sledge-instant-search__result-filter-item-color-swatches");
|
|
4764
4775
|
}
|
|
4776
|
+
let isLastIndex = allowedFilter.length - 1 === indexFilter;
|
|
4765
4777
|
return isRender ? /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4766
4778
|
Popover,
|
|
4767
4779
|
{
|
|
4768
|
-
trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4780
|
+
trigger: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4781
|
+
Button,
|
|
4782
|
+
{
|
|
4783
|
+
type: "button",
|
|
4784
|
+
onClick: () => setClickedOpenFilterId(value),
|
|
4785
|
+
className: `${isLastIndex ? allowedFilter.length % 2 ? "sledge-instant-search__result-filter-trigger-odd" : "sledge-instant-search__result-filter-trigger-even" : ""}`,
|
|
4786
|
+
children: [
|
|
4787
|
+
label,
|
|
4788
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(motion.div, { initial: "closed", animate: isActive ? "open" : "closed", variants: ROTATE_FILTER_ARROW_ANIMATION, className: "sort-trigger-icon", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronArrowDownIcon, { width: 20, height: 20, color: "#000000" }) })
|
|
4789
|
+
]
|
|
4790
|
+
}
|
|
4791
|
+
),
|
|
4772
4792
|
content: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal-facet", children: isActive && /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { className: classesUlElement.join(" "), children: isNotRerender ? getFacetComponent : !isFilterChanged ? getFacetComponent : null }) }),
|
|
4773
4793
|
withOpenState: false,
|
|
4774
4794
|
setIsOpen: (open) => setClickedOpenFilterId(!open ? "" : value),
|
|
@@ -4810,7 +4830,7 @@ const ResultProduct = (props) => {
|
|
|
4810
4830
|
});
|
|
4811
4831
|
const paginationComponent = /* @__PURE__ */ jsxRuntimeExports.jsx(Pagination, { currentPage, totalPage, totalResult: totalSearchResult, onChange: (page) => handlePageChange(page), pageInfo: language_pagination_info });
|
|
4812
4832
|
const filterHorizontalBlockComponent = ((_l = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _l.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: [
|
|
4813
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal", children: filterHorizontalComponents }),
|
|
4833
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__result-filter-horizontal sledge-instant-search__result-filter-horizontal-component", children: filterHorizontalComponents }),
|
|
4814
4834
|
Boolean((dataClickedFacets == null ? void 0 : dataClickedFacets.length) && ((_m = displaySettings == null ? void 0 : displaySettings.filter) == null ? void 0 : _m.show_refine_by_block)) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "sledge-instant-search__result-filter-horizontal", children: [
|
|
4815
4835
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
4816
4836
|
"div",
|
|
@@ -5260,6 +5280,13 @@ const SearchWidget = (props) => {
|
|
|
5260
5280
|
placeholder: "Search anything",
|
|
5261
5281
|
value: keyword,
|
|
5262
5282
|
onChange: ({ value }) => setKeyword(value),
|
|
5283
|
+
onKeyDown: (event) => {
|
|
5284
|
+
if (event.key === "Enter") {
|
|
5285
|
+
const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
|
|
5286
|
+
const urlToSearchResult = `${urlSearchResult || DEFAULT_SEARCH_RESULT_URL}?${queryKeyword}=${keyword}`;
|
|
5287
|
+
window.location.href = urlToSearchResult;
|
|
5288
|
+
}
|
|
5289
|
+
},
|
|
5263
5290
|
onResetField: () => setKeyword(""),
|
|
5264
5291
|
onFocus: () => {
|
|
5265
5292
|
if (keyword)
|