@nuskin/react-search-components 1.0.0-comx-3067.2 → 1.0.0-comx-3067.3
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/package-dist/index.d.mts +268 -0
- package/package-dist/index.d.ts +268 -0
- package/package-dist/index.js +14557 -0
- package/package-dist/index.js.map +1 -0
- package/package-dist/index.mjs +14535 -0
- package/package-dist/index.mjs.map +1 -0
- package/package.json +2 -2
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
import { CatalogSuggestionItem, SearchService } from '@nuskin/react-search-sdk';
|
|
4
|
+
export { CatalogSuggestionItem, DidYouMeanItem, SearchService, createSearchService } from '@nuskin/react-search-sdk';
|
|
5
|
+
import { Environment } from '@ns/ns-contentstack-lib';
|
|
6
|
+
|
|
7
|
+
declare const SEARCH_MESSAGE_SENDERS: {
|
|
8
|
+
readonly AGENT: "agent";
|
|
9
|
+
readonly USER: "user";
|
|
10
|
+
};
|
|
11
|
+
type SearchMessageSender = (typeof SEARCH_MESSAGE_SENDERS)[keyof typeof SEARCH_MESSAGE_SENDERS];
|
|
12
|
+
|
|
13
|
+
interface SearchMessageProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
14
|
+
sender: SearchMessageSender;
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
declare function SearchMessage({ sender, text, ...props }: SearchMessageProps): React.JSX.Element;
|
|
18
|
+
|
|
19
|
+
interface SearchMessageInputBaseProps extends Omit<ComponentPropsWithoutRef<'form'>, 'children' | 'onSubmit' | 'onChange'> {
|
|
20
|
+
inputLabel: string;
|
|
21
|
+
/** Called on every keystroke — use for typeahead/debounced search */
|
|
22
|
+
onChange?: (value: string) => void;
|
|
23
|
+
onSubmit: (message: string) => void;
|
|
24
|
+
placeholder: string;
|
|
25
|
+
submitLabel: string;
|
|
26
|
+
/** When false, input value is preserved after submit (search mode). Defaults to true (chat mode). */
|
|
27
|
+
clearOnSubmit?: boolean;
|
|
28
|
+
value?: string;
|
|
29
|
+
}
|
|
30
|
+
type SearchMessageInputVoiceProps = {
|
|
31
|
+
onVoiceInput: () => void;
|
|
32
|
+
showVoiceInput: true;
|
|
33
|
+
voiceListening?: boolean;
|
|
34
|
+
voiceInputLabel: string;
|
|
35
|
+
voiceListeningLabel?: string;
|
|
36
|
+
} | {
|
|
37
|
+
onVoiceInput?: never;
|
|
38
|
+
showVoiceInput?: false;
|
|
39
|
+
voiceListening?: never;
|
|
40
|
+
voiceInputLabel?: never;
|
|
41
|
+
voiceListeningLabel?: never;
|
|
42
|
+
};
|
|
43
|
+
type SearchMessageInputProps = SearchMessageInputBaseProps & SearchMessageInputVoiceProps;
|
|
44
|
+
declare function SearchMessageInput({ clearOnSubmit, inputLabel, onChange, onSubmit, onVoiceInput, placeholder, showVoiceInput, submitLabel, value, voiceInputLabel, voiceListening, voiceListeningLabel, ...props }: SearchMessageInputProps): React.JSX.Element;
|
|
45
|
+
|
|
46
|
+
interface SearchPanelProps extends Omit<ComponentPropsWithoutRef<'section'>, 'aria-label' | 'children'> {
|
|
47
|
+
'aria-label': string;
|
|
48
|
+
children: ReactNode;
|
|
49
|
+
closeLabel: string;
|
|
50
|
+
onClose: () => void;
|
|
51
|
+
initialPrompt?: string;
|
|
52
|
+
messageInputProps?: SearchMessageInputProps;
|
|
53
|
+
inputSlot?: ReactNode;
|
|
54
|
+
logoSlot?: ReactNode;
|
|
55
|
+
/** When true: content scrolls, input fixed at bottom (AI chat layout) */
|
|
56
|
+
chatMode?: boolean;
|
|
57
|
+
}
|
|
58
|
+
declare function SearchPanel({ 'aria-label': ariaLabel, children, chatMode, closeLabel, initialPrompt, inputSlot, logoSlot, messageInputProps, onClose, ...props }: Readonly<SearchPanelProps>): React.JSX.Element;
|
|
59
|
+
|
|
60
|
+
interface AIChatConfig {
|
|
61
|
+
/** The user's search term */
|
|
62
|
+
searchTerm: string;
|
|
63
|
+
/** Market code (e.g., "US", "JP") for scope_context in message requests. */
|
|
64
|
+
market?: string;
|
|
65
|
+
/** Language code (e.g., "en", "ja") for scope_context in message requests. */
|
|
66
|
+
language?: string;
|
|
67
|
+
/** X-Sales-AI-App-Key header value (from CS configurations). */
|
|
68
|
+
salesAiAppKey?: string;
|
|
69
|
+
/** X-Sales-AI-Parent-Origin header value (from CS configurations). */
|
|
70
|
+
salesAiParentOrigin?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Raw product shape returned by the AI chat SSE stream */
|
|
73
|
+
interface AIChatProduct {
|
|
74
|
+
sku: string;
|
|
75
|
+
name?: string;
|
|
76
|
+
image_url?: string;
|
|
77
|
+
pv?: number;
|
|
78
|
+
[key: string]: unknown;
|
|
79
|
+
}
|
|
80
|
+
/** Parsed result from the AI commerce chat SSE stream */
|
|
81
|
+
interface AIChatParsedResponse {
|
|
82
|
+
products: AIChatProduct[];
|
|
83
|
+
summary: string;
|
|
84
|
+
}
|
|
85
|
+
/** @deprecated Use AIChatParsedResponse */
|
|
86
|
+
type AIChatResponse = AIChatParsedResponse;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* AI Commerce Chat API client.
|
|
90
|
+
* Delegates all HTTP + SSE logic to the SDK's ChatService.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Calls the NuSkin AI Commerce Chat API via the SDK's ChatService.
|
|
95
|
+
* Reuses the tab-scoped conversation id stored in sessionStorage.
|
|
96
|
+
*/
|
|
97
|
+
declare function callAICommerceChat(config: AIChatConfig): Promise<AIChatParsedResponse>;
|
|
98
|
+
|
|
99
|
+
interface SuggestionDisplayData {
|
|
100
|
+
imageSrc: string;
|
|
101
|
+
displayLabel: string;
|
|
102
|
+
isBundle: boolean;
|
|
103
|
+
isDidYouMean: boolean;
|
|
104
|
+
isOutOfStock: boolean;
|
|
105
|
+
isCartActionDisabled: boolean;
|
|
106
|
+
}
|
|
107
|
+
interface SuggestionOptionWithTracking extends Omit<CatalogSuggestionItem, 'slug' | 'productSlug' | 'url' | 'href'> {
|
|
108
|
+
slug: string | null | undefined;
|
|
109
|
+
productSlug: string | null | undefined;
|
|
110
|
+
url: string | null | undefined;
|
|
111
|
+
href: string | null | undefined;
|
|
112
|
+
trackingUrl?: string;
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
}
|
|
115
|
+
interface SuggestionRowProps {
|
|
116
|
+
inputRef: React__default.RefObject<HTMLElement | null>;
|
|
117
|
+
isHighlighted: boolean;
|
|
118
|
+
isSelected: boolean;
|
|
119
|
+
onHighlightSuggestion: (index: number) => void;
|
|
120
|
+
onRunSuggestionAction: (option: SuggestionOptionWithTracking) => void;
|
|
121
|
+
onSelectSuggestion: (option: SuggestionOptionWithTracking) => void;
|
|
122
|
+
registerSuggestionNode: (node: HTMLElement | null) => void;
|
|
123
|
+
suggestionIndex: number;
|
|
124
|
+
suggestionOption: SuggestionOptionWithTracking;
|
|
125
|
+
suggestionOptionId: string;
|
|
126
|
+
fallbackImageUrl?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface AISearchProduct {
|
|
130
|
+
id: string;
|
|
131
|
+
sku?: string;
|
|
132
|
+
name: string;
|
|
133
|
+
imageUrl?: string;
|
|
134
|
+
image_url?: string;
|
|
135
|
+
price?: string;
|
|
136
|
+
pv?: number;
|
|
137
|
+
retail_price?: number;
|
|
138
|
+
description?: string;
|
|
139
|
+
badge?: string;
|
|
140
|
+
url?: string;
|
|
141
|
+
category?: string;
|
|
142
|
+
}
|
|
143
|
+
interface AISearchResult {
|
|
144
|
+
userQuery: string;
|
|
145
|
+
aiResponseText: string;
|
|
146
|
+
products?: AISearchProduct[];
|
|
147
|
+
}
|
|
148
|
+
interface SearchChatResultProps {
|
|
149
|
+
result: AISearchResult;
|
|
150
|
+
/**
|
|
151
|
+
* When false, pricing and PV/SV values are hidden in cards and stripped from summary.
|
|
152
|
+
* Controlled by the CS ai_chat_nuskin_header configurations.enablepricingpvsv flag.
|
|
153
|
+
*/
|
|
154
|
+
showPricing?: boolean;
|
|
155
|
+
productsAriaLabel?: string;
|
|
156
|
+
history?: {
|
|
157
|
+
push: (path: string) => void;
|
|
158
|
+
} | null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface SearchModalAIChatConfig {
|
|
162
|
+
market: string;
|
|
163
|
+
language: string;
|
|
164
|
+
conversationsUrl?: string;
|
|
165
|
+
messagesUrl?: string;
|
|
166
|
+
salesAiAppKey?: string;
|
|
167
|
+
salesAiParentOrigin?: string;
|
|
168
|
+
aiAutoTriggerDelayMs?: number;
|
|
169
|
+
productBasePath?: string;
|
|
170
|
+
}
|
|
171
|
+
interface SearchModalAIChatHeaderContent {
|
|
172
|
+
configurations?: {
|
|
173
|
+
enablepricingpvsv?: string;
|
|
174
|
+
[key: string]: unknown;
|
|
175
|
+
};
|
|
176
|
+
[key: string]: unknown;
|
|
177
|
+
}
|
|
178
|
+
interface SearchModalProps {
|
|
179
|
+
isOpen: boolean;
|
|
180
|
+
onClose: () => void;
|
|
181
|
+
service: SearchService;
|
|
182
|
+
copy?: Partial<{
|
|
183
|
+
extended_search_textbox_desktop?: string;
|
|
184
|
+
extended_search_box_aria_label?: string;
|
|
185
|
+
clear_all_label?: string;
|
|
186
|
+
no_suggestions_text?: string;
|
|
187
|
+
see_more_results_text?: string;
|
|
188
|
+
did_you_mean_text?: string;
|
|
189
|
+
analyzing_label?: string;
|
|
190
|
+
pulling_label?: string;
|
|
191
|
+
routing_label?: string;
|
|
192
|
+
thinking_label?: string;
|
|
193
|
+
listening_label?: string;
|
|
194
|
+
}>;
|
|
195
|
+
logo?: React__default.ReactNode;
|
|
196
|
+
cancelLabel?: string;
|
|
197
|
+
fallbackImageUrl?: string;
|
|
198
|
+
/** When true, the modal triggers AI Commerce Chat after search. */
|
|
199
|
+
enableAIChat?: boolean;
|
|
200
|
+
/** When false, pricing/PV/SV is hidden in AI chat results. Driven by CS enablepricingpvsv flag. */
|
|
201
|
+
showPricing?: boolean;
|
|
202
|
+
/** Full CS singleton payload fetched by the consuming app. */
|
|
203
|
+
aiChatHeaderContent?: SearchModalAIChatHeaderContent | null;
|
|
204
|
+
/** API configuration for AI Commerce Chat. Required when enableAIChat is true. */
|
|
205
|
+
aiChatConfig?: SearchModalAIChatConfig;
|
|
206
|
+
history?: {
|
|
207
|
+
push: (path: string) => void;
|
|
208
|
+
} | null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
declare function SearchModal({ isOpen, onClose, service, history, copy, logo, cancelLabel, fallbackImageUrl, enableAIChat, aiChatConfig, showPricing, aiChatHeaderContent, }: Readonly<SearchModalProps>): React__default.ReactElement | null;
|
|
212
|
+
|
|
213
|
+
interface AIChatHeaderContentConfig {
|
|
214
|
+
/** Contentstack environment consumed by getStack, e.g. prod/test/stage */
|
|
215
|
+
environment?: Environment;
|
|
216
|
+
/** Market country code, e.g. US */
|
|
217
|
+
country: string;
|
|
218
|
+
/** Language code, e.g. en */
|
|
219
|
+
language: string;
|
|
220
|
+
}
|
|
221
|
+
interface AIChatHeaderContent {
|
|
222
|
+
[key: string]: unknown;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Fetches `ai_chat_nuskin_header` singleton content from Contentstack.
|
|
226
|
+
* Mirrors the pattern used in personal-offer-mfe for singleton lookups.
|
|
227
|
+
*/
|
|
228
|
+
declare function fetchAIChatHeaderContent(config: AIChatHeaderContentConfig): Promise<AIChatHeaderContent | null>;
|
|
229
|
+
|
|
230
|
+
interface UseAIChatHeaderContentResult {
|
|
231
|
+
content: AIChatHeaderContent | null;
|
|
232
|
+
loading: boolean;
|
|
233
|
+
error: Error | null;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Fetches `ai_chat_nuskin_header` singleton content from Contentstack
|
|
237
|
+
* when a valid config is supplied. Returns null content when config is absent.
|
|
238
|
+
*/
|
|
239
|
+
declare function useAIChatHeaderContent(config: AIChatHeaderContentConfig | null | undefined): UseAIChatHeaderContentResult;
|
|
240
|
+
|
|
241
|
+
declare function SearchChatResult({ result, showPricing, history, productsAriaLabel, }: Readonly<SearchChatResultProps>): React__default.JSX.Element;
|
|
242
|
+
|
|
243
|
+
interface ChatLoadingProps extends ComponentPropsWithoutRef<'div'> {
|
|
244
|
+
/** Accessible label for screen readers */
|
|
245
|
+
label?: string;
|
|
246
|
+
}
|
|
247
|
+
declare function ChatLoading({ label, ...props }: Readonly<ChatLoadingProps>): React.JSX.Element;
|
|
248
|
+
|
|
249
|
+
declare function SuggestionRow({ inputRef, isHighlighted, isSelected, onHighlightSuggestion, onRunSuggestionAction, onSelectSuggestion, registerSuggestionNode, suggestionIndex, suggestionOption, suggestionOptionId, fallbackImageUrl, }: Readonly<SuggestionRowProps>): React__default.ReactElement;
|
|
250
|
+
|
|
251
|
+
declare function getSuggestionDisplayData(option: SuggestionOptionWithTracking): SuggestionDisplayData;
|
|
252
|
+
|
|
253
|
+
interface SeeMoreLinkProps {
|
|
254
|
+
seeMoreLinkRef: React__default.RefObject<HTMLButtonElement | null>;
|
|
255
|
+
seeMoreLinkFocused: boolean;
|
|
256
|
+
inputRef: React__default.RefObject<HTMLElement | null>;
|
|
257
|
+
onBlurSeeMoreLink: () => void;
|
|
258
|
+
onFocusSeeMoreLink: () => void;
|
|
259
|
+
onSeeMoreResults: () => void;
|
|
260
|
+
resetSeeMoreLinkFocus: () => void;
|
|
261
|
+
restoreLastSuggestion: () => void;
|
|
262
|
+
seeMoreResultsText: string;
|
|
263
|
+
searchQuery?: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
declare function SeeMoreLink({ seeMoreLinkRef, seeMoreLinkFocused, inputRef, onBlurSeeMoreLink, onFocusSeeMoreLink, onSeeMoreResults, resetSeeMoreLinkFocus, restoreLastSuggestion, seeMoreResultsText, searchQuery, }: Readonly<SeeMoreLinkProps>): React__default.ReactElement;
|
|
267
|
+
|
|
268
|
+
export { type AIChatConfig, type AIChatHeaderContent, type AIChatHeaderContentConfig, type AIChatProduct, type AIChatResponse, type AISearchProduct, type AISearchResult, ChatLoading, type ChatLoadingProps, SEARCH_MESSAGE_SENDERS, SearchChatResult, SearchMessage, SearchMessageInput, type SearchMessageInputProps, type SearchMessageProps, type SearchMessageSender, SearchModal, type SearchModalAIChatConfig, type SearchModalProps, SearchPanel, type SearchPanelProps, SeeMoreLink, type SeeMoreLinkProps, type SuggestionDisplayData, type SuggestionOptionWithTracking, SuggestionRow, type SuggestionRowProps, type UseAIChatHeaderContentResult, callAICommerceChat, fetchAIChatHeaderContent, getSuggestionDisplayData, useAIChatHeaderContent };
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
3
|
+
import { CatalogSuggestionItem, SearchService } from '@nuskin/react-search-sdk';
|
|
4
|
+
export { CatalogSuggestionItem, DidYouMeanItem, SearchService, createSearchService } from '@nuskin/react-search-sdk';
|
|
5
|
+
import { Environment } from '@ns/ns-contentstack-lib';
|
|
6
|
+
|
|
7
|
+
declare const SEARCH_MESSAGE_SENDERS: {
|
|
8
|
+
readonly AGENT: "agent";
|
|
9
|
+
readonly USER: "user";
|
|
10
|
+
};
|
|
11
|
+
type SearchMessageSender = (typeof SEARCH_MESSAGE_SENDERS)[keyof typeof SEARCH_MESSAGE_SENDERS];
|
|
12
|
+
|
|
13
|
+
interface SearchMessageProps extends Omit<ComponentPropsWithoutRef<'div'>, 'children'> {
|
|
14
|
+
sender: SearchMessageSender;
|
|
15
|
+
text: string;
|
|
16
|
+
}
|
|
17
|
+
declare function SearchMessage({ sender, text, ...props }: SearchMessageProps): React.JSX.Element;
|
|
18
|
+
|
|
19
|
+
interface SearchMessageInputBaseProps extends Omit<ComponentPropsWithoutRef<'form'>, 'children' | 'onSubmit' | 'onChange'> {
|
|
20
|
+
inputLabel: string;
|
|
21
|
+
/** Called on every keystroke — use for typeahead/debounced search */
|
|
22
|
+
onChange?: (value: string) => void;
|
|
23
|
+
onSubmit: (message: string) => void;
|
|
24
|
+
placeholder: string;
|
|
25
|
+
submitLabel: string;
|
|
26
|
+
/** When false, input value is preserved after submit (search mode). Defaults to true (chat mode). */
|
|
27
|
+
clearOnSubmit?: boolean;
|
|
28
|
+
value?: string;
|
|
29
|
+
}
|
|
30
|
+
type SearchMessageInputVoiceProps = {
|
|
31
|
+
onVoiceInput: () => void;
|
|
32
|
+
showVoiceInput: true;
|
|
33
|
+
voiceListening?: boolean;
|
|
34
|
+
voiceInputLabel: string;
|
|
35
|
+
voiceListeningLabel?: string;
|
|
36
|
+
} | {
|
|
37
|
+
onVoiceInput?: never;
|
|
38
|
+
showVoiceInput?: false;
|
|
39
|
+
voiceListening?: never;
|
|
40
|
+
voiceInputLabel?: never;
|
|
41
|
+
voiceListeningLabel?: never;
|
|
42
|
+
};
|
|
43
|
+
type SearchMessageInputProps = SearchMessageInputBaseProps & SearchMessageInputVoiceProps;
|
|
44
|
+
declare function SearchMessageInput({ clearOnSubmit, inputLabel, onChange, onSubmit, onVoiceInput, placeholder, showVoiceInput, submitLabel, value, voiceInputLabel, voiceListening, voiceListeningLabel, ...props }: SearchMessageInputProps): React.JSX.Element;
|
|
45
|
+
|
|
46
|
+
interface SearchPanelProps extends Omit<ComponentPropsWithoutRef<'section'>, 'aria-label' | 'children'> {
|
|
47
|
+
'aria-label': string;
|
|
48
|
+
children: ReactNode;
|
|
49
|
+
closeLabel: string;
|
|
50
|
+
onClose: () => void;
|
|
51
|
+
initialPrompt?: string;
|
|
52
|
+
messageInputProps?: SearchMessageInputProps;
|
|
53
|
+
inputSlot?: ReactNode;
|
|
54
|
+
logoSlot?: ReactNode;
|
|
55
|
+
/** When true: content scrolls, input fixed at bottom (AI chat layout) */
|
|
56
|
+
chatMode?: boolean;
|
|
57
|
+
}
|
|
58
|
+
declare function SearchPanel({ 'aria-label': ariaLabel, children, chatMode, closeLabel, initialPrompt, inputSlot, logoSlot, messageInputProps, onClose, ...props }: Readonly<SearchPanelProps>): React.JSX.Element;
|
|
59
|
+
|
|
60
|
+
interface AIChatConfig {
|
|
61
|
+
/** The user's search term */
|
|
62
|
+
searchTerm: string;
|
|
63
|
+
/** Market code (e.g., "US", "JP") for scope_context in message requests. */
|
|
64
|
+
market?: string;
|
|
65
|
+
/** Language code (e.g., "en", "ja") for scope_context in message requests. */
|
|
66
|
+
language?: string;
|
|
67
|
+
/** X-Sales-AI-App-Key header value (from CS configurations). */
|
|
68
|
+
salesAiAppKey?: string;
|
|
69
|
+
/** X-Sales-AI-Parent-Origin header value (from CS configurations). */
|
|
70
|
+
salesAiParentOrigin?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Raw product shape returned by the AI chat SSE stream */
|
|
73
|
+
interface AIChatProduct {
|
|
74
|
+
sku: string;
|
|
75
|
+
name?: string;
|
|
76
|
+
image_url?: string;
|
|
77
|
+
pv?: number;
|
|
78
|
+
[key: string]: unknown;
|
|
79
|
+
}
|
|
80
|
+
/** Parsed result from the AI commerce chat SSE stream */
|
|
81
|
+
interface AIChatParsedResponse {
|
|
82
|
+
products: AIChatProduct[];
|
|
83
|
+
summary: string;
|
|
84
|
+
}
|
|
85
|
+
/** @deprecated Use AIChatParsedResponse */
|
|
86
|
+
type AIChatResponse = AIChatParsedResponse;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* AI Commerce Chat API client.
|
|
90
|
+
* Delegates all HTTP + SSE logic to the SDK's ChatService.
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Calls the NuSkin AI Commerce Chat API via the SDK's ChatService.
|
|
95
|
+
* Reuses the tab-scoped conversation id stored in sessionStorage.
|
|
96
|
+
*/
|
|
97
|
+
declare function callAICommerceChat(config: AIChatConfig): Promise<AIChatParsedResponse>;
|
|
98
|
+
|
|
99
|
+
interface SuggestionDisplayData {
|
|
100
|
+
imageSrc: string;
|
|
101
|
+
displayLabel: string;
|
|
102
|
+
isBundle: boolean;
|
|
103
|
+
isDidYouMean: boolean;
|
|
104
|
+
isOutOfStock: boolean;
|
|
105
|
+
isCartActionDisabled: boolean;
|
|
106
|
+
}
|
|
107
|
+
interface SuggestionOptionWithTracking extends Omit<CatalogSuggestionItem, 'slug' | 'productSlug' | 'url' | 'href'> {
|
|
108
|
+
slug: string | null | undefined;
|
|
109
|
+
productSlug: string | null | undefined;
|
|
110
|
+
url: string | null | undefined;
|
|
111
|
+
href: string | null | undefined;
|
|
112
|
+
trackingUrl?: string;
|
|
113
|
+
[key: string]: unknown;
|
|
114
|
+
}
|
|
115
|
+
interface SuggestionRowProps {
|
|
116
|
+
inputRef: React__default.RefObject<HTMLElement | null>;
|
|
117
|
+
isHighlighted: boolean;
|
|
118
|
+
isSelected: boolean;
|
|
119
|
+
onHighlightSuggestion: (index: number) => void;
|
|
120
|
+
onRunSuggestionAction: (option: SuggestionOptionWithTracking) => void;
|
|
121
|
+
onSelectSuggestion: (option: SuggestionOptionWithTracking) => void;
|
|
122
|
+
registerSuggestionNode: (node: HTMLElement | null) => void;
|
|
123
|
+
suggestionIndex: number;
|
|
124
|
+
suggestionOption: SuggestionOptionWithTracking;
|
|
125
|
+
suggestionOptionId: string;
|
|
126
|
+
fallbackImageUrl?: string;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
interface AISearchProduct {
|
|
130
|
+
id: string;
|
|
131
|
+
sku?: string;
|
|
132
|
+
name: string;
|
|
133
|
+
imageUrl?: string;
|
|
134
|
+
image_url?: string;
|
|
135
|
+
price?: string;
|
|
136
|
+
pv?: number;
|
|
137
|
+
retail_price?: number;
|
|
138
|
+
description?: string;
|
|
139
|
+
badge?: string;
|
|
140
|
+
url?: string;
|
|
141
|
+
category?: string;
|
|
142
|
+
}
|
|
143
|
+
interface AISearchResult {
|
|
144
|
+
userQuery: string;
|
|
145
|
+
aiResponseText: string;
|
|
146
|
+
products?: AISearchProduct[];
|
|
147
|
+
}
|
|
148
|
+
interface SearchChatResultProps {
|
|
149
|
+
result: AISearchResult;
|
|
150
|
+
/**
|
|
151
|
+
* When false, pricing and PV/SV values are hidden in cards and stripped from summary.
|
|
152
|
+
* Controlled by the CS ai_chat_nuskin_header configurations.enablepricingpvsv flag.
|
|
153
|
+
*/
|
|
154
|
+
showPricing?: boolean;
|
|
155
|
+
productsAriaLabel?: string;
|
|
156
|
+
history?: {
|
|
157
|
+
push: (path: string) => void;
|
|
158
|
+
} | null;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
interface SearchModalAIChatConfig {
|
|
162
|
+
market: string;
|
|
163
|
+
language: string;
|
|
164
|
+
conversationsUrl?: string;
|
|
165
|
+
messagesUrl?: string;
|
|
166
|
+
salesAiAppKey?: string;
|
|
167
|
+
salesAiParentOrigin?: string;
|
|
168
|
+
aiAutoTriggerDelayMs?: number;
|
|
169
|
+
productBasePath?: string;
|
|
170
|
+
}
|
|
171
|
+
interface SearchModalAIChatHeaderContent {
|
|
172
|
+
configurations?: {
|
|
173
|
+
enablepricingpvsv?: string;
|
|
174
|
+
[key: string]: unknown;
|
|
175
|
+
};
|
|
176
|
+
[key: string]: unknown;
|
|
177
|
+
}
|
|
178
|
+
interface SearchModalProps {
|
|
179
|
+
isOpen: boolean;
|
|
180
|
+
onClose: () => void;
|
|
181
|
+
service: SearchService;
|
|
182
|
+
copy?: Partial<{
|
|
183
|
+
extended_search_textbox_desktop?: string;
|
|
184
|
+
extended_search_box_aria_label?: string;
|
|
185
|
+
clear_all_label?: string;
|
|
186
|
+
no_suggestions_text?: string;
|
|
187
|
+
see_more_results_text?: string;
|
|
188
|
+
did_you_mean_text?: string;
|
|
189
|
+
analyzing_label?: string;
|
|
190
|
+
pulling_label?: string;
|
|
191
|
+
routing_label?: string;
|
|
192
|
+
thinking_label?: string;
|
|
193
|
+
listening_label?: string;
|
|
194
|
+
}>;
|
|
195
|
+
logo?: React__default.ReactNode;
|
|
196
|
+
cancelLabel?: string;
|
|
197
|
+
fallbackImageUrl?: string;
|
|
198
|
+
/** When true, the modal triggers AI Commerce Chat after search. */
|
|
199
|
+
enableAIChat?: boolean;
|
|
200
|
+
/** When false, pricing/PV/SV is hidden in AI chat results. Driven by CS enablepricingpvsv flag. */
|
|
201
|
+
showPricing?: boolean;
|
|
202
|
+
/** Full CS singleton payload fetched by the consuming app. */
|
|
203
|
+
aiChatHeaderContent?: SearchModalAIChatHeaderContent | null;
|
|
204
|
+
/** API configuration for AI Commerce Chat. Required when enableAIChat is true. */
|
|
205
|
+
aiChatConfig?: SearchModalAIChatConfig;
|
|
206
|
+
history?: {
|
|
207
|
+
push: (path: string) => void;
|
|
208
|
+
} | null;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
declare function SearchModal({ isOpen, onClose, service, history, copy, logo, cancelLabel, fallbackImageUrl, enableAIChat, aiChatConfig, showPricing, aiChatHeaderContent, }: Readonly<SearchModalProps>): React__default.ReactElement | null;
|
|
212
|
+
|
|
213
|
+
interface AIChatHeaderContentConfig {
|
|
214
|
+
/** Contentstack environment consumed by getStack, e.g. prod/test/stage */
|
|
215
|
+
environment?: Environment;
|
|
216
|
+
/** Market country code, e.g. US */
|
|
217
|
+
country: string;
|
|
218
|
+
/** Language code, e.g. en */
|
|
219
|
+
language: string;
|
|
220
|
+
}
|
|
221
|
+
interface AIChatHeaderContent {
|
|
222
|
+
[key: string]: unknown;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Fetches `ai_chat_nuskin_header` singleton content from Contentstack.
|
|
226
|
+
* Mirrors the pattern used in personal-offer-mfe for singleton lookups.
|
|
227
|
+
*/
|
|
228
|
+
declare function fetchAIChatHeaderContent(config: AIChatHeaderContentConfig): Promise<AIChatHeaderContent | null>;
|
|
229
|
+
|
|
230
|
+
interface UseAIChatHeaderContentResult {
|
|
231
|
+
content: AIChatHeaderContent | null;
|
|
232
|
+
loading: boolean;
|
|
233
|
+
error: Error | null;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Fetches `ai_chat_nuskin_header` singleton content from Contentstack
|
|
237
|
+
* when a valid config is supplied. Returns null content when config is absent.
|
|
238
|
+
*/
|
|
239
|
+
declare function useAIChatHeaderContent(config: AIChatHeaderContentConfig | null | undefined): UseAIChatHeaderContentResult;
|
|
240
|
+
|
|
241
|
+
declare function SearchChatResult({ result, showPricing, history, productsAriaLabel, }: Readonly<SearchChatResultProps>): React__default.JSX.Element;
|
|
242
|
+
|
|
243
|
+
interface ChatLoadingProps extends ComponentPropsWithoutRef<'div'> {
|
|
244
|
+
/** Accessible label for screen readers */
|
|
245
|
+
label?: string;
|
|
246
|
+
}
|
|
247
|
+
declare function ChatLoading({ label, ...props }: Readonly<ChatLoadingProps>): React.JSX.Element;
|
|
248
|
+
|
|
249
|
+
declare function SuggestionRow({ inputRef, isHighlighted, isSelected, onHighlightSuggestion, onRunSuggestionAction, onSelectSuggestion, registerSuggestionNode, suggestionIndex, suggestionOption, suggestionOptionId, fallbackImageUrl, }: Readonly<SuggestionRowProps>): React__default.ReactElement;
|
|
250
|
+
|
|
251
|
+
declare function getSuggestionDisplayData(option: SuggestionOptionWithTracking): SuggestionDisplayData;
|
|
252
|
+
|
|
253
|
+
interface SeeMoreLinkProps {
|
|
254
|
+
seeMoreLinkRef: React__default.RefObject<HTMLButtonElement | null>;
|
|
255
|
+
seeMoreLinkFocused: boolean;
|
|
256
|
+
inputRef: React__default.RefObject<HTMLElement | null>;
|
|
257
|
+
onBlurSeeMoreLink: () => void;
|
|
258
|
+
onFocusSeeMoreLink: () => void;
|
|
259
|
+
onSeeMoreResults: () => void;
|
|
260
|
+
resetSeeMoreLinkFocus: () => void;
|
|
261
|
+
restoreLastSuggestion: () => void;
|
|
262
|
+
seeMoreResultsText: string;
|
|
263
|
+
searchQuery?: string;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
declare function SeeMoreLink({ seeMoreLinkRef, seeMoreLinkFocused, inputRef, onBlurSeeMoreLink, onFocusSeeMoreLink, onSeeMoreResults, resetSeeMoreLinkFocus, restoreLastSuggestion, seeMoreResultsText, searchQuery, }: Readonly<SeeMoreLinkProps>): React__default.ReactElement;
|
|
267
|
+
|
|
268
|
+
export { type AIChatConfig, type AIChatHeaderContent, type AIChatHeaderContentConfig, type AIChatProduct, type AIChatResponse, type AISearchProduct, type AISearchResult, ChatLoading, type ChatLoadingProps, SEARCH_MESSAGE_SENDERS, SearchChatResult, SearchMessage, SearchMessageInput, type SearchMessageInputProps, type SearchMessageProps, type SearchMessageSender, SearchModal, type SearchModalAIChatConfig, type SearchModalProps, SearchPanel, type SearchPanelProps, SeeMoreLink, type SeeMoreLinkProps, type SuggestionDisplayData, type SuggestionOptionWithTracking, SuggestionRow, type SuggestionRowProps, type UseAIChatHeaderContentResult, callAICommerceChat, fetchAIChatHeaderContent, getSuggestionDisplayData, useAIChatHeaderContent };
|