@sledge-app/react-instant-search 1.0.12 → 1.0.13

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.
@@ -39,7 +39,6 @@ const DATASET_ATTRIBUTE_KEY = {
39
39
  WISHLIST: {
40
40
  SHARE_ID: "data-share-id",
41
41
  QUERY_SHARE_ID: "data-query-share-id",
42
- CUSTOM_ROUTE_PAGE: "data-custom-route-page",
43
42
  RENDER_WISHLIST_WIDGET_ALERT: "data-render-wishlist-widget-alert",
44
43
  USE_PROXY_URL: "data-use-proxy-url",
45
44
  LIMIT_OPTIONS: "data-limit-options"
@@ -55,6 +54,7 @@ const DATASET_ATTRIBUTE_KEY = {
55
54
  ON_AFTER_RENDER_BLOG: "data-on-after-render-blog",
56
55
  ON_AFTER_RENDER_ARTICLE: "data-on-after-render-article",
57
56
  QUERY_KEYWORD: "data-query-keyword",
57
+ URL_SEARCH_RESULT: "data-url-search-result",
58
58
  RENDER_SUGGESTION_KEYWORD_LIST: "data-render-suggestion-keyword-list",
59
59
  RENDER_OTHER_INDEX_LIST: "data-render-other-index-list",
60
60
  RENDER_SEARCH_VIEW_MORE_RESULT: "data-render-search-view-more-result",
@@ -116,7 +116,11 @@ const SELECTOR = {
116
116
  ELEMENT_PLP_WIDGET: `[${SELECTOR_ATTRIBUTE_KEY}="instant-search-product-filter-widget"]`
117
117
  }
118
118
  };
119
- const SEARCH_RESULT_URL = "/pages/search-result";
119
+ const DEFAULT_SEARCH_RESULT_URL = "/apps/sledge/search";
120
+ const DEFAULT_WISHLIST_URL = "/apps/sledge/wishlist";
121
+ const DEFAULT_QUERY_PARAM = {
122
+ KEYWORD: "q"
123
+ };
120
124
  const ELEMENT_ID = {
121
125
  PRODUCT_REVIEW: {
122
126
  ELEMENT_WIDGET: "product-review-widget"
@@ -843,7 +847,7 @@ const BadgeHeaderMenu = (props) => {
843
847
  const { sledgeAnonymId } = React__default.useContext(SledgeContext);
844
848
  const { isFirstLoading, isLoading, totalWishlist, isMaximizeTotalWishlist, proxyUrl, dataSettings, useProxyUrl } = props || {};
845
849
  const { is_required_login } = ((_a = dataSettings == null ? void 0 : dataSettings.display) == null ? void 0 : _a.global) || {};
846
- const defaultColorIcon = "#000000";
850
+ const defaultColorIcon = "currentColor";
847
851
  const [colorIcon, setColorIcon] = React__default.useState(defaultColorIcon);
848
852
  const [isRequiredLogin, setIsRequiredLogin] = React__default.useState(false);
849
853
  React__default.useEffect(() => {
@@ -1002,7 +1006,7 @@ const BadgeRoot = (props) => {
1002
1006
  const [proxyUrl, setProxyUrl] = React__default.useState((propsData == null ? void 0 : propsData.proxy_url) || "");
1003
1007
  const [dataSettings, setDataSettings] = React__default.useState({});
1004
1008
  const handleGetWishlistInfo = async () => {
1005
- var _a2, _b, _c;
1009
+ var _a2, _b;
1006
1010
  let response;
1007
1011
  let run = false;
1008
1012
  let valueTotalWishlist;
@@ -1010,7 +1014,7 @@ const BadgeRoot = (props) => {
1010
1014
  response = await getWishlistInfo();
1011
1015
  run = ((_a2 = response == null ? void 0 : response.status) == null ? void 0 : _a2.code) === 200 || false;
1012
1016
  valueTotalWishlist = !((_b = response == null ? void 0 : response.data) == null ? void 0 : _b.total_data) ? 0 : response.data.total_data;
1013
- valueProxyUrl = ((_c = response == null ? void 0 : response.data) == null ? void 0 : _c.proxy_url) || "";
1017
+ valueProxyUrl = DEFAULT_WISHLIST_URL;
1014
1018
  if (run) {
1015
1019
  setTotalWishlist(valueTotalWishlist);
1016
1020
  setIsMaximizeTotalWishlist(valueTotalWishlist > 99);
@@ -2401,6 +2405,7 @@ const ProductCard = (props) => {
2401
2405
  onClick: () => sourceApp === "instant-search" && productClickTrigger({
2402
2406
  productId: id
2403
2407
  }),
2408
+ className: "sledge__product-grid-card-image-link",
2404
2409
  children: [
2405
2410
  /* @__PURE__ */ jsxRuntimeExports.jsx(
2406
2411
  Trigger,
@@ -2970,7 +2975,7 @@ const LoadingDots = () => {
2970
2975
  const SearchIconWidget = (props) => {
2971
2976
  const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
2972
2977
  const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
2973
- const { size = "sm", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props || {};
2978
+ const { size = "sm", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct, urlSearchResult, query } = props || {};
2974
2979
  let productCardsComponent = null;
2975
2980
  let suggestionKeywordListsComponent = null;
2976
2981
  let otherIndexListsComponent = null;
@@ -3023,7 +3028,9 @@ const SearchIconWidget = (props) => {
3023
3028
  productCardsComponent,
3024
3029
  suggestionKeywordListsComponent,
3025
3030
  otherIndexListsComponent,
3026
- searchViewMoreResultComponent
3031
+ searchViewMoreResultComponent,
3032
+ urlSearchResult,
3033
+ query
3027
3034
  });
3028
3035
  };
3029
3036
  return /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sledge-instant-search__icon-widget", onClick: handleShowWidget, children: /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { ...sizing, color: "currentColor" }) });
@@ -3077,7 +3084,7 @@ const SuggestionKeywordLists = ({
3077
3084
  return /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
3078
3085
  "a",
3079
3086
  {
3080
- href: `${SEARCH_RESULT_URL}?q=${keyword}`,
3087
+ href: `${DEFAULT_SEARCH_RESULT_URL}?q=${keyword}`,
3081
3088
  className: "sledge-instant-search__icon-widget-search-form-result-list-link sledge-instant-search__icon-widget-search-form-result-list-link-suggestion",
3082
3089
  children: [
3083
3090
  /* @__PURE__ */ jsxRuntimeExports.jsx(SearchIcon, { width: 12, height: 12, color: "#677487" }),
@@ -3095,7 +3102,9 @@ const SearchViewMoreResult = ({
3095
3102
  keyword,
3096
3103
  isComponentJsVersion = false,
3097
3104
  showPopupComponent,
3098
- setShowPopupComponent
3105
+ setShowPopupComponent,
3106
+ urlSearchResult = DEFAULT_SEARCH_RESULT_URL,
3107
+ query
3099
3108
  }) => {
3100
3109
  var _a;
3101
3110
  if (Component) {
@@ -3108,7 +3117,8 @@ const SearchViewMoreResult = ({
3108
3117
  const ComponentProps = { keyword, showPopupComponent, setShowPopupComponent, setRenderSearchResult };
3109
3118
  return /* @__PURE__ */ jsxRuntimeExports.jsx(React__default.Fragment, { children: isComponentJsVersion ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: Component({ ...ComponentProps }) } }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Component, { ...ComponentProps }) });
3110
3119
  } else {
3111
- return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: `${SEARCH_RESULT_URL}?q=${keyword}`, className: "sledge-instant-search__icon-widget-button-more", children: "View More Result" });
3120
+ const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
3121
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("a", { href: `${urlSearchResult}?${queryKeyword}=${keyword}`, className: "sledge-instant-search__icon-widget-button-more", children: "View More Result" });
3112
3122
  }
3113
3123
  };
3114
3124
  const Global = {
@@ -3129,6 +3139,7 @@ const SearchIconWidgetPopup = () => {
3129
3139
  const [displaySettings, setDisplaySettings] = React__default.useState({});
3130
3140
  const [suggestionSettings, setSuggestionSettings] = React__default.useState({});
3131
3141
  const [suggestionIndex, setSuggestionIndex] = React__default.useState("");
3142
+ const [urlSearchResult, setUrlSearchResult] = React__default.useState("");
3132
3143
  const [handleFunctions, setHandleFunctions] = React__default.useState({
3133
3144
  onAfterAddToCart: (state) => {
3134
3145
  },
@@ -3142,7 +3153,8 @@ const SearchIconWidgetPopup = () => {
3142
3153
  productCardsComponent: null,
3143
3154
  suggestionKeywordListsComponent: null,
3144
3155
  otherIndexListsComponent: null,
3145
- searchViewMoreResultComponent: null
3156
+ searchViewMoreResultComponent: null,
3157
+ query: {}
3146
3158
  });
3147
3159
  const searchFieldRef = React__default.useRef(null);
3148
3160
  const previousState = usePrevious({ keyword });
@@ -3245,7 +3257,9 @@ const SearchIconWidgetPopup = () => {
3245
3257
  otherIndexListsComponent = () => {
3246
3258
  },
3247
3259
  searchViewMoreResultComponent = () => {
3248
- }
3260
+ },
3261
+ urlSearchResult: urlSearchResult2 = "",
3262
+ query = {}
3249
3263
  }) => {
3250
3264
  setShowInfo(true);
3251
3265
  setHandleFunctions({
@@ -3257,8 +3271,10 @@ const SearchIconWidgetPopup = () => {
3257
3271
  productCardsComponent,
3258
3272
  suggestionKeywordListsComponent,
3259
3273
  otherIndexListsComponent,
3260
- searchViewMoreResultComponent
3274
+ searchViewMoreResultComponent,
3275
+ query
3261
3276
  });
3277
+ setUrlSearchResult(urlSearchResult2);
3262
3278
  };
3263
3279
  }
3264
3280
  handleSettings(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || null);
@@ -3439,7 +3455,9 @@ const SearchIconWidgetPopup = () => {
3439
3455
  keyword,
3440
3456
  isComponentJsVersion: handleFunctions.isJsVersion,
3441
3457
  showPopupComponent: showInfo,
3442
- setShowPopupComponent: setShowInfo
3458
+ setShowPopupComponent: setShowInfo,
3459
+ urlSearchResult,
3460
+ query: handleFunctions.query
3443
3461
  }
3444
3462
  ) }) : null
3445
3463
  ] })
@@ -3465,7 +3483,7 @@ const SearchResultWidget = (props) => {
3465
3483
  data: propsData,
3466
3484
  sledgeSettings
3467
3485
  } = props;
3468
- const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : "q";
3486
+ const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
3469
3487
  const { collectionId } = params || {};
3470
3488
  const searchParams = typeof document !== "undefined" ? new URLSearchParams((_a = document == null ? void 0 : document.location) == null ? void 0 : _a.search) : null;
3471
3489
  const [settings] = React__default.useState(typeof localStorage !== "undefined" ? JSON.parse(localStorage.getItem(LOCAL_STORAGE_KEY.INSTANT_SEARCH_SETTING) || "{}") : {});
@@ -4003,7 +4021,7 @@ const ResultProduct = (props) => {
4003
4021
  data: propsData,
4004
4022
  settings
4005
4023
  } = props || {};
4006
- const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : "q";
4024
+ const queryKeyword = (query == null ? void 0 : query.keyword) ? query.keyword : DEFAULT_QUERY_PARAM.KEYWORD;
4007
4025
  const { collectionId } = params || {};
4008
4026
  const [isFirstLoading, setIsFirstLoading] = React__default.useState(!propsData);
4009
4027
  const [isLoading, setIsLoading] = React__default.useState(!propsData);
@@ -4829,7 +4847,7 @@ const SearchWidget = (props) => {
4829
4847
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
4830
4848
  const { isRenderApp, isJsVersion } = React__default.useContext(SledgeContext);
4831
4849
  const { instantSearch: isRenderAppInstantSearch } = isRenderApp || {};
4832
- const { width = "400px", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct } = props;
4850
+ const { width = "400px", children, onAfterAddToCart, onAfterAddWishlist, onAfterRemoveWishlist, onAfterRenderProduct, urlSearchResult, query } = props;
4833
4851
  let productCardsComponent = null;
4834
4852
  let suggestionKeywordListsComponent = null;
4835
4853
  let otherIndexListsComponent = null;
@@ -5076,7 +5094,16 @@ const SearchWidget = (props) => {
5076
5094
  ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-search-form-result-product-disabled", children: "No product were found" })
5077
5095
  ] })
5078
5096
  ] }),
5079
- (searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_r = (_q = suggestionSettings[suggestionIndex]) == null ? void 0 : _q.products) == null ? void 0 : _r.active) && ((_u = (_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.list) == null ? void 0 : _u.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Global.SearchViewMoreResult, { component: searchViewMoreResultComponent, keyword, isComponentJsVersion: isJsVersion }) }) : null
5097
+ (searchResultProduct == null ? void 0 : searchResultProduct.length) || Object.keys(suggestionSettings).length && ((_r = (_q = suggestionSettings[suggestionIndex]) == null ? void 0 : _q.products) == null ? void 0 : _r.active) && ((_u = (_t = (_s = suggestionSettings[suggestionIndex]) == null ? void 0 : _s.products) == null ? void 0 : _t.list) == null ? void 0 : _u.length) ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "sledge-instant-search__widget-button-more-wrapper", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5098
+ Global.SearchViewMoreResult,
5099
+ {
5100
+ component: searchViewMoreResultComponent,
5101
+ keyword,
5102
+ isComponentJsVersion: isJsVersion,
5103
+ urlSearchResult,
5104
+ query
5105
+ }
5106
+ ) }) : null
5080
5107
  ] }) }) })
5081
5108
  ] });
5082
5109
  };