@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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +28 -19
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +28 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12675,7 +12675,7 @@ var SearchPanelRoot = styled6__default.default.section`
|
|
|
12675
12675
|
${({ $chatMode }) => $chatMode && `
|
|
12676
12676
|
display: flex;
|
|
12677
12677
|
flex-direction: column;
|
|
12678
|
-
max-
|
|
12678
|
+
max-height: 805px;
|
|
12679
12679
|
overflow: hidden;
|
|
12680
12680
|
`}
|
|
12681
12681
|
`;
|
|
@@ -13623,14 +13623,11 @@ function toCarouselItem(product, index2, showPricing, history) {
|
|
|
13623
13623
|
price: showPricing ? priceText : void 0,
|
|
13624
13624
|
addToCartLabel: "View Product",
|
|
13625
13625
|
addToCartAriaLabel: `View ${productName}`,
|
|
13626
|
-
onProductClick: () => {
|
|
13626
|
+
onProductClick: ({ event } = {}) => {
|
|
13627
13627
|
if (href === "#") return;
|
|
13628
|
+
event == null ? void 0 : event.preventDefault();
|
|
13628
13629
|
if (history && typeof history.push === "function") {
|
|
13629
13630
|
history.push(href);
|
|
13630
|
-
return;
|
|
13631
|
-
}
|
|
13632
|
-
if (typeof window !== "undefined") {
|
|
13633
|
-
window.location.href = href;
|
|
13634
13631
|
}
|
|
13635
13632
|
}
|
|
13636
13633
|
}
|
|
@@ -13808,6 +13805,11 @@ function SearchModalChatContent({
|
|
|
13808
13805
|
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: chatEndRef })
|
|
13809
13806
|
] });
|
|
13810
13807
|
}
|
|
13808
|
+
function pushSearchPath(history, path2) {
|
|
13809
|
+
if (path2 && path2 !== "action-handled" && path2 !== "action-pending" && history && typeof history.push === "function") {
|
|
13810
|
+
history.push(path2);
|
|
13811
|
+
}
|
|
13812
|
+
}
|
|
13811
13813
|
function SearchModalSuggestionsContent({
|
|
13812
13814
|
listboxId,
|
|
13813
13815
|
ariaLabel,
|
|
@@ -14186,14 +14188,13 @@ function SearchModal({
|
|
|
14186
14188
|
}, [enableAIChat, isOpen, isInChatMode, hasQuery, query]);
|
|
14187
14189
|
const sendAIMessage = React.useCallback(
|
|
14188
14190
|
(queryText) => {
|
|
14189
|
-
var _a2;
|
|
14190
14191
|
const config = aiChatConfigRef.current;
|
|
14191
14192
|
if (!config || !queryText.trim()) return;
|
|
14192
14193
|
setSearchInput("");
|
|
14193
14194
|
setPendingQuery(queryText.trim());
|
|
14194
14195
|
setAiStatus(aiStatusLabels.analyzing);
|
|
14195
14196
|
const requestId = aiRequestCounterRef.current;
|
|
14196
|
-
const
|
|
14197
|
+
const productBasePath = `/${config.market.toLowerCase()}/${config.language.toLowerCase()}/product`;
|
|
14197
14198
|
const chatService = reactSearchSdk.createChatService({
|
|
14198
14199
|
conversationsUrl: config.conversationsUrl,
|
|
14199
14200
|
messagesUrl: config.messagesUrl,
|
|
@@ -14219,8 +14220,8 @@ function SearchModal({
|
|
|
14219
14220
|
).then((result) => {
|
|
14220
14221
|
if (!result || requestId !== aiRequestCounterRef.current) return;
|
|
14221
14222
|
const products = result.products.map((p, i) => {
|
|
14222
|
-
var
|
|
14223
|
-
const productId = getProductId((_b2 = (
|
|
14223
|
+
var _a2, _b2;
|
|
14224
|
+
const productId = getProductId((_b2 = (_a2 = p.id) != null ? _a2 : p.sku) != null ? _b2 : i);
|
|
14224
14225
|
const productName = getProductName(p, productId);
|
|
14225
14226
|
return {
|
|
14226
14227
|
id: productId,
|
|
@@ -14231,7 +14232,10 @@ function SearchModal({
|
|
|
14231
14232
|
...p.retail_price != null ? { retail_price: p.retail_price } : {},
|
|
14232
14233
|
...p.description ? { description: p.description } : {},
|
|
14233
14234
|
...p.badge ? { badge: p.badge } : {},
|
|
14234
|
-
...p.sku != null ? {
|
|
14235
|
+
...p.sku != null ? {
|
|
14236
|
+
url: `${productBasePath}/${p.sku}`,
|
|
14237
|
+
routeUrl: `/product/${p.sku}`
|
|
14238
|
+
} : {}
|
|
14235
14239
|
};
|
|
14236
14240
|
});
|
|
14237
14241
|
setAiStatus("");
|
|
@@ -14265,7 +14269,10 @@ function SearchModal({
|
|
|
14265
14269
|
onClose();
|
|
14266
14270
|
return;
|
|
14267
14271
|
}
|
|
14268
|
-
|
|
14272
|
+
pushSearchPath(
|
|
14273
|
+
history,
|
|
14274
|
+
service.submitProductSearch(term, option)
|
|
14275
|
+
);
|
|
14269
14276
|
if (!enableAIChat) setLegacyRecentSearches((_d2 = (_c2 = service.getRecentSearches) == null ? void 0 : _c2.call(service)) != null ? _d2 : []);
|
|
14270
14277
|
onClose();
|
|
14271
14278
|
},
|
|
@@ -14274,9 +14281,11 @@ function SearchModal({
|
|
|
14274
14281
|
const runSuggestionAction = React.useCallback(
|
|
14275
14282
|
(option) => {
|
|
14276
14283
|
if (reactSearchSdk.isSuggestionDisabled(option)) return;
|
|
14277
|
-
service.activateSuggestionAction(option);
|
|
14284
|
+
const result = service.activateSuggestionAction(option);
|
|
14285
|
+
void Promise.resolve(result).then((path2) => pushSearchPath(history, path2)).catch(() => {
|
|
14286
|
+
});
|
|
14278
14287
|
},
|
|
14279
|
-
[service]
|
|
14288
|
+
[history, service]
|
|
14280
14289
|
);
|
|
14281
14290
|
const handleRecentSearchSelect = React.useCallback(
|
|
14282
14291
|
(entry) => {
|
|
@@ -14301,16 +14310,16 @@ function SearchModal({
|
|
|
14301
14310
|
clearRecentSearches();
|
|
14302
14311
|
}, [clearRecentSearches]);
|
|
14303
14312
|
const handleSeeMore = React.useCallback(() => {
|
|
14304
|
-
if (query.trim())
|
|
14305
|
-
|
|
14313
|
+
if (query.trim()) {
|
|
14314
|
+
pushSearchPath(history, service.viewMoreResults({ query: query.trim() }));
|
|
14315
|
+
}
|
|
14316
|
+
}, [history, service, query]);
|
|
14306
14317
|
const handleSearchSubmit = React.useCallback(
|
|
14307
14318
|
(value) => {
|
|
14308
14319
|
var _a2, _b2;
|
|
14309
14320
|
historyAddEntry({ query: value, isAI: false });
|
|
14310
14321
|
const url = service.submitProductSearch(value);
|
|
14311
|
-
|
|
14312
|
-
history.push(url);
|
|
14313
|
-
}
|
|
14322
|
+
pushSearchPath(history, url);
|
|
14314
14323
|
if (!enableAIChat) setLegacyRecentSearches((_b2 = (_a2 = service.getRecentSearches) == null ? void 0 : _a2.call(service)) != null ? _b2 : []);
|
|
14315
14324
|
onClose();
|
|
14316
14325
|
},
|