@nuskin/react-search-components 1.0.0-comx-3067.4 → 1.0.0-comx-3067.6

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/index.mjs CHANGED
@@ -12669,7 +12669,7 @@ var SearchPanelRoot = styled6.section`
12669
12669
  ${({ $chatMode }) => $chatMode && `
12670
12670
  display: flex;
12671
12671
  flex-direction: column;
12672
- max-block-size: 92dvh;
12672
+ max-height: 805px;
12673
12673
  overflow: hidden;
12674
12674
  `}
12675
12675
  `;
@@ -13617,14 +13617,11 @@ function toCarouselItem(product, index2, showPricing, history) {
13617
13617
  price: showPricing ? priceText : void 0,
13618
13618
  addToCartLabel: "View Product",
13619
13619
  addToCartAriaLabel: `View ${productName}`,
13620
- onProductClick: () => {
13620
+ onProductClick: ({ event } = {}) => {
13621
13621
  if (href === "#") return;
13622
+ event == null ? void 0 : event.preventDefault();
13622
13623
  if (history && typeof history.push === "function") {
13623
13624
  history.push(href);
13624
- return;
13625
- }
13626
- if (typeof window !== "undefined") {
13627
- window.location.href = href;
13628
13625
  }
13629
13626
  }
13630
13627
  }
@@ -13802,6 +13799,11 @@ function SearchModalChatContent({
13802
13799
  /* @__PURE__ */ jsx("div", { ref: chatEndRef })
13803
13800
  ] });
13804
13801
  }
13802
+ function pushSearchPath(history, path2) {
13803
+ if (path2 && path2 !== "action-handled" && path2 !== "action-pending" && history && typeof history.push === "function") {
13804
+ history.push(path2);
13805
+ }
13806
+ }
13805
13807
  function SearchModalSuggestionsContent({
13806
13808
  listboxId,
13807
13809
  ariaLabel,
@@ -14180,14 +14182,13 @@ function SearchModal({
14180
14182
  }, [enableAIChat, isOpen, isInChatMode, hasQuery, query]);
14181
14183
  const sendAIMessage = useCallback(
14182
14184
  (queryText) => {
14183
- var _a2;
14184
14185
  const config = aiChatConfigRef.current;
14185
14186
  if (!config || !queryText.trim()) return;
14186
14187
  setSearchInput("");
14187
14188
  setPendingQuery(queryText.trim());
14188
14189
  setAiStatus(aiStatusLabels.analyzing);
14189
14190
  const requestId = aiRequestCounterRef.current;
14190
- const basePath = (_a2 = config.productBasePath) != null ? _a2 : `/${config.market.toLowerCase()}/${config.language.toLowerCase()}/product`;
14191
+ const productBasePath = `/${config.market.toLowerCase()}/${config.language.toLowerCase()}/product`;
14191
14192
  const chatService = createChatService({
14192
14193
  conversationsUrl: config.conversationsUrl,
14193
14194
  messagesUrl: config.messagesUrl,
@@ -14213,8 +14214,8 @@ function SearchModal({
14213
14214
  ).then((result) => {
14214
14215
  if (!result || requestId !== aiRequestCounterRef.current) return;
14215
14216
  const products = result.products.map((p, i) => {
14216
- var _a3, _b2;
14217
- const productId = getProductId((_b2 = (_a3 = p.id) != null ? _a3 : p.sku) != null ? _b2 : i);
14217
+ var _a2, _b2;
14218
+ const productId = getProductId((_b2 = (_a2 = p.id) != null ? _a2 : p.sku) != null ? _b2 : i);
14218
14219
  const productName = getProductName(p, productId);
14219
14220
  return {
14220
14221
  id: productId,
@@ -14225,7 +14226,10 @@ function SearchModal({
14225
14226
  ...p.retail_price != null ? { retail_price: p.retail_price } : {},
14226
14227
  ...p.description ? { description: p.description } : {},
14227
14228
  ...p.badge ? { badge: p.badge } : {},
14228
- ...p.sku != null ? { url: `${basePath}/${p.sku}` } : {}
14229
+ ...p.sku != null ? {
14230
+ url: `${productBasePath}/${p.sku}`,
14231
+ routeUrl: `/product/${p.sku}`
14232
+ } : {}
14229
14233
  };
14230
14234
  });
14231
14235
  setAiStatus("");
@@ -14259,7 +14263,10 @@ function SearchModal({
14259
14263
  onClose();
14260
14264
  return;
14261
14265
  }
14262
- service.submitProductSearch(term, option);
14266
+ pushSearchPath(
14267
+ history,
14268
+ service.submitProductSearch(term, option)
14269
+ );
14263
14270
  if (!enableAIChat) setLegacyRecentSearches((_d2 = (_c2 = service.getRecentSearches) == null ? void 0 : _c2.call(service)) != null ? _d2 : []);
14264
14271
  onClose();
14265
14272
  },
@@ -14268,9 +14275,11 @@ function SearchModal({
14268
14275
  const runSuggestionAction = useCallback(
14269
14276
  (option) => {
14270
14277
  if (isSuggestionDisabled(option)) return;
14271
- service.activateSuggestionAction(option);
14278
+ const result = service.activateSuggestionAction(option);
14279
+ void Promise.resolve(result).then((path2) => pushSearchPath(history, path2)).catch(() => {
14280
+ });
14272
14281
  },
14273
- [service]
14282
+ [history, service]
14274
14283
  );
14275
14284
  const handleRecentSearchSelect = useCallback(
14276
14285
  (entry) => {
@@ -14295,16 +14304,16 @@ function SearchModal({
14295
14304
  clearRecentSearches();
14296
14305
  }, [clearRecentSearches]);
14297
14306
  const handleSeeMore = useCallback(() => {
14298
- if (query.trim()) service.viewMoreResults({ query: query.trim() });
14299
- }, [service, query]);
14307
+ if (query.trim()) {
14308
+ pushSearchPath(history, service.viewMoreResults({ query: query.trim() }));
14309
+ }
14310
+ }, [history, service, query]);
14300
14311
  const handleSearchSubmit = useCallback(
14301
14312
  (value) => {
14302
14313
  var _a2, _b2;
14303
14314
  historyAddEntry({ query: value, isAI: false });
14304
14315
  const url = service.submitProductSearch(value);
14305
- if (url && history && typeof history.push === "function") {
14306
- history.push(url);
14307
- }
14316
+ pushSearchPath(history, url);
14308
14317
  if (!enableAIChat) setLegacyRecentSearches((_b2 = (_a2 = service.getRecentSearches) == null ? void 0 : _a2.call(service)) != null ? _b2 : []);
14309
14318
  onClose();
14310
14319
  },