react-instantsearch 7.28.1 → 7.30.0
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/cjs/components/AutocompleteSearch.js +3 -3
- package/dist/cjs/components/ChatGreeting.js +16 -0
- package/dist/cjs/components/ChatInlineLayout.js +17 -0
- package/dist/cjs/components/ChatOverlayLayout.js +17 -0
- package/dist/cjs/components/ChatSidePanelLayout.js +17 -0
- package/dist/cjs/components/index.js +4 -0
- package/dist/cjs/ui/SearchBox.js +38 -2
- package/dist/cjs/widgets/Autocomplete.js +24 -8
- package/dist/cjs/widgets/Chat.js +30 -4
- package/dist/cjs/widgets/SearchBox.js +18 -2
- package/dist/cjs/widgets/TrendingFacets.js +55 -0
- package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +7 -3
- package/dist/cjs/widgets/index.js +1 -0
- package/dist/es/components/AutocompleteSearch.d.ts +2 -2
- package/dist/es/components/AutocompleteSearch.js +3 -3
- package/dist/es/components/ChatGreeting.d.ts +1 -0
- package/dist/es/components/ChatGreeting.js +8 -0
- package/dist/es/components/ChatInlineLayout.d.ts +1 -0
- package/dist/es/components/ChatInlineLayout.js +9 -0
- package/dist/es/components/ChatOverlayLayout.d.ts +1 -0
- package/dist/es/components/ChatOverlayLayout.js +9 -0
- package/dist/es/components/ChatSidePanelLayout.d.ts +1 -0
- package/dist/es/components/ChatSidePanelLayout.js +9 -0
- package/dist/es/components/index.d.ts +4 -0
- package/dist/es/components/index.js +4 -0
- package/dist/es/index.js +5 -0
- package/dist/es/ui/SearchBox.d.ts +15 -1
- package/dist/es/ui/SearchBox.js +38 -2
- package/dist/es/widgets/Autocomplete.d.ts +6 -0
- package/dist/es/widgets/Autocomplete.js +24 -8
- package/dist/es/widgets/Chat.d.ts +15 -4
- package/dist/es/widgets/Chat.js +44 -18
- package/dist/es/widgets/RefinementList.d.ts +3 -2
- package/dist/es/widgets/SearchBox.d.ts +8 -2
- package/dist/es/widgets/SearchBox.js +19 -3
- package/dist/es/widgets/TrendingFacets.d.ts +11 -0
- package/dist/es/widgets/TrendingFacets.js +46 -0
- package/dist/es/widgets/chat/tools/SearchIndexTool.js +7 -3
- package/dist/es/widgets/index.d.ts +1 -0
- package/dist/es/widgets/index.js +1 -0
- package/dist/umd/ReactInstantSearch.js +1019 -181
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
- package/dist/cjs/widgets/index.umd.js +0 -69
- package/dist/es/widgets/index.umd.d.ts +0 -32
- package/dist/es/widgets/index.umd.js +0 -37
package/dist/es/ui/SearchBox.js
CHANGED
|
@@ -60,8 +60,30 @@ function DefaultLoadingIcon(param) {
|
|
|
60
60
|
repeatCount: "indefinite"
|
|
61
61
|
})))));
|
|
62
62
|
}
|
|
63
|
+
function DefaultAiModeIcon(param) {
|
|
64
|
+
var classNames = param.classNames;
|
|
65
|
+
return /*#__PURE__*/ React.createElement("svg", {
|
|
66
|
+
className: cx('ais-AiModeButton-icon', classNames.aiModeIcon),
|
|
67
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
68
|
+
fill: "none",
|
|
69
|
+
viewBox: "0 0 20 20",
|
|
70
|
+
width: "16",
|
|
71
|
+
height: "16",
|
|
72
|
+
"aria-hidden": "true"
|
|
73
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
74
|
+
fill: "currentColor",
|
|
75
|
+
fillRule: "evenodd",
|
|
76
|
+
d: "M10 1.875c.27 0 .51.173.594.43l1.593 4.844a1.043 1.043 0 0 0 .664.664l4.844 1.593a.625.625 0 0 1 0 1.188l-4.844 1.593a1.043 1.043 0 0 0-.664.664l-1.593 4.844a.625.625 0 0 1-1.188 0l-1.593-4.844a1.042 1.042 0 0 0-.664-.664l-4.844-1.593a.625.625 0 0 1 0-1.188l4.844-1.593a1.042 1.042 0 0 0 .664-.664l1.593-4.844a.625.625 0 0 1 .594-.43ZM9 7.539A2.292 2.292 0 0 1 7.54 9L4.5 10l3.04 1A2.292 2.292 0 0 1 9 12.46l1 3.04 1-3.04A2.293 2.293 0 0 1 12.46 11l3.04-1-3.04-1A2.292 2.292 0 0 1 11 7.54L10 4.5 9 7.54ZM4.167 1.875c.345 0 .625.28.625.625v3.333a.625.625 0 0 1-1.25 0V2.5c0-.345.28-.625.625-.625ZM15.833 13.542c.345 0 .625.28.625.625V17.5a.625.625 0 1 1-1.25 0v-3.333c0-.345.28-.625.625-.625Z",
|
|
77
|
+
clipRule: "evenodd"
|
|
78
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
79
|
+
fill: "currentColor",
|
|
80
|
+
fillRule: "evenodd",
|
|
81
|
+
d: "M1.875 4.167c0-.346.28-.625.625-.625h3.333a.625.625 0 1 1 0 1.25H2.5a.625.625 0 0 1-.625-.625ZM13.542 15.833c0-.345.28-.625.625-.625H17.5a.625.625 0 0 1 0 1.25h-3.333a.625.625 0 0 1-.625-.625Z",
|
|
82
|
+
clipRule: "evenodd"
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
63
85
|
function SearchBox(_0) {
|
|
64
|
-
var formRef = _0.formRef, inputRef = _0.inputRef, inputProps = _0.inputProps, isSearchStalled = _0.isSearchStalled, onChange = _0.onChange, onReset = _0.onReset, onSubmit = _0.onSubmit, _0_placeholder = _0.placeholder, placeholder = _0_placeholder === void 0 ? '' : _0_placeholder, value = _0.value, autoFocus = _0.autoFocus, tmp = _0.resetIconComponent, ResetIcon = tmp === void 0 ? DefaultResetIcon : tmp, tmp1 = _0.submitIconComponent, SubmitIcon = tmp1 === void 0 ? DefaultSubmitIcon : tmp1, tmp2 = _0.loadingIconComponent, LoadingIcon = tmp2 === void 0 ? DefaultLoadingIcon : tmp2, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _(_0, [
|
|
86
|
+
var formRef = _0.formRef, inputRef = _0.inputRef, inputProps = _0.inputProps, isSearchStalled = _0.isSearchStalled, onChange = _0.onChange, onReset = _0.onReset, onSubmit = _0.onSubmit, _0_placeholder = _0.placeholder, placeholder = _0_placeholder === void 0 ? '' : _0_placeholder, value = _0.value, autoFocus = _0.autoFocus, tmp = _0.resetIconComponent, ResetIcon = tmp === void 0 ? DefaultResetIcon : tmp, tmp1 = _0.submitIconComponent, SubmitIcon = tmp1 === void 0 ? DefaultSubmitIcon : tmp1, tmp2 = _0.loadingIconComponent, LoadingIcon = tmp2 === void 0 ? DefaultLoadingIcon : tmp2, tmp3 = _0.aiModeIconComponent, AiModeIcon = tmp3 === void 0 ? DefaultAiModeIcon : tmp3, onAiModeClick = _0.onAiModeClick, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _(_0, [
|
|
65
87
|
"formRef",
|
|
66
88
|
"inputRef",
|
|
67
89
|
"inputProps",
|
|
@@ -75,6 +97,8 @@ function SearchBox(_0) {
|
|
|
75
97
|
"resetIconComponent",
|
|
76
98
|
"submitIconComponent",
|
|
77
99
|
"loadingIconComponent",
|
|
100
|
+
"aiModeIconComponent",
|
|
101
|
+
"onAiModeClick",
|
|
78
102
|
"classNames",
|
|
79
103
|
"translations"
|
|
80
104
|
]);
|
|
@@ -134,7 +158,19 @@ function SearchBox(_0) {
|
|
|
134
158
|
hidden: value.length === 0 || isSearchStalled
|
|
135
159
|
}, /*#__PURE__*/ React.createElement(ResetIcon, {
|
|
136
160
|
classNames: classNames
|
|
137
|
-
})), /*#__PURE__*/ React.createElement("
|
|
161
|
+
})), onAiModeClick && /*#__PURE__*/ React.createElement("button", {
|
|
162
|
+
className: cx('ais-AiModeButton', classNames.aiModeButton),
|
|
163
|
+
type: "button",
|
|
164
|
+
title: translations.aiModeButtonTitle || 'AI Mode',
|
|
165
|
+
onClick: function onClick(e) {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
onAiModeClick();
|
|
168
|
+
}
|
|
169
|
+
}, /*#__PURE__*/ React.createElement(AiModeIcon, {
|
|
170
|
+
classNames: classNames
|
|
171
|
+
}), /*#__PURE__*/ React.createElement("span", {
|
|
172
|
+
className: "ais-AiModeButton-label"
|
|
173
|
+
}, translations.aiModeButtonTitle || 'AI Mode')), /*#__PURE__*/ React.createElement("span", {
|
|
138
174
|
className: cx('ais-SearchBox-loadingIndicator', classNames.loadingIndicator),
|
|
139
175
|
hidden: !isSearchStalled
|
|
140
176
|
}, /*#__PURE__*/ React.createElement(LoadingIcon, {
|
|
@@ -77,6 +77,12 @@ export type AutocompleteProps<TItem extends BaseHit> = ComponentProps<'div'> & {
|
|
|
77
77
|
* Translations for the Autocomplete widget.
|
|
78
78
|
*/
|
|
79
79
|
translations?: Partial<AutocompleteTranslations>;
|
|
80
|
+
/**
|
|
81
|
+
* When true, renders an AI mode button inside the search input
|
|
82
|
+
* that opens the Chat widget and sends the current query.
|
|
83
|
+
* Requires a Chat widget on the same index.
|
|
84
|
+
*/
|
|
85
|
+
aiMode?: boolean;
|
|
80
86
|
};
|
|
81
87
|
export declare function EXPERIMENTAL_Autocomplete<TItem extends BaseHit = BaseHit>({ indices, showQuerySuggestions, showPromptSuggestions, showRecent, searchParameters: userSearchParameters, detachedMediaQuery, translations: userTranslations, ...props }: AutocompleteProps<TItem>): React.JSX.Element;
|
|
82
88
|
export {};
|
|
@@ -308,7 +308,7 @@ function EXPERIMENTAL_Autocomplete(_0) {
|
|
|
308
308
|
}))));
|
|
309
309
|
}
|
|
310
310
|
function InnerAutocomplete(_0) {
|
|
311
|
-
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, autoFocus = _0.autoFocus, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _(_0, [
|
|
311
|
+
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, autoFocus = _0.autoFocus, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, aiMode = _0.aiMode, props = _(_0, [
|
|
312
312
|
"indicesConfig",
|
|
313
313
|
"refineSearchBox",
|
|
314
314
|
"isSearchStalled",
|
|
@@ -327,13 +327,18 @@ function InnerAutocomplete(_0) {
|
|
|
327
327
|
"autoFocus",
|
|
328
328
|
"detachedMediaQuery",
|
|
329
329
|
"translations",
|
|
330
|
-
"classNames"
|
|
330
|
+
"classNames",
|
|
331
|
+
"aiMode"
|
|
331
332
|
]);
|
|
332
|
-
var _ref;
|
|
333
|
+
var _indexUiState_query, _ref;
|
|
333
334
|
var _showPromptSuggestions_searchParameters;
|
|
334
335
|
var _useAutocomplete = useAutocomplete({
|
|
335
|
-
transformItems: transformItems
|
|
336
|
+
transformItems: transformItems,
|
|
337
|
+
future: {
|
|
338
|
+
undefinedEmptyQuery: true
|
|
339
|
+
}
|
|
336
340
|
}), indices = _useAutocomplete.indices, refineAutocomplete = _useAutocomplete.refine, currentRefinement = _useAutocomplete.currentRefinement;
|
|
341
|
+
var resolvedQuery = currentRefinement !== undefined ? currentRefinement : (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '';
|
|
337
342
|
var _useDetachedMode = useDetachedMode(detachedMediaQuery), isDetached = _useDetachedMode.isDetached, isModalDetached = _useDetachedMode.isModalDetached, isModalOpen = _useDetachedMode.isModalOpen, setIsModalOpen = _useDetachedMode.setIsModalOpen;
|
|
338
343
|
var previousIsDetachedRef = useRef(isDetached);
|
|
339
344
|
var _useStorage = useStorage({
|
|
@@ -537,9 +542,20 @@ function InnerAutocomplete(_0) {
|
|
|
537
542
|
onQueryChange: function onQueryChange(query) {
|
|
538
543
|
refineAutocomplete(query);
|
|
539
544
|
},
|
|
540
|
-
query:
|
|
541
|
-
|
|
542
|
-
|
|
545
|
+
query: resolvedQuery,
|
|
546
|
+
isSearchStalled: isSearchStalled,
|
|
547
|
+
onAiModeClick: aiMode ? function() {
|
|
548
|
+
if (chatRenderState) {
|
|
549
|
+
var _chatRenderState_setOpen;
|
|
550
|
+
(_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
|
|
551
|
+
if (resolvedQuery.trim()) {
|
|
552
|
+
var _chatRenderState_sendMessage;
|
|
553
|
+
(_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
|
|
554
|
+
text: resolvedQuery
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
} : undefined
|
|
543
559
|
});
|
|
544
560
|
var panelContent = /*#__PURE__*/ React.createElement(AutocompletePanel, getPanelProps(), PanelComponent ? /*#__PURE__*/ React.createElement(PanelComponent, {
|
|
545
561
|
elements: elements,
|
|
@@ -558,7 +574,7 @@ function InnerAutocomplete(_0) {
|
|
|
558
574
|
rootRef: rootRef,
|
|
559
575
|
classNames: classNames
|
|
560
576
|
}), /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
561
|
-
query:
|
|
577
|
+
query: resolvedQuery,
|
|
562
578
|
placeholder: placeholder,
|
|
563
579
|
classNames: classNames,
|
|
564
580
|
onClick: function onClick() {
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat';
|
|
2
2
|
import React from 'react';
|
|
3
3
|
export { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, };
|
|
4
|
-
import type { ChatProps as ChatUiProps, RecommendComponentProps, RecordWithObjectID, UserClientSideTool, UserClientSideTools, ChatMessageProps } from 'instantsearch-ui-components';
|
|
4
|
+
import type { ChatProps as ChatUiProps, ChatLayoutOwnProps, RecommendComponentProps, RecordWithObjectID, UserClientSideTool, UserClientSideTools, ChatMessageProps } from 'instantsearch-ui-components';
|
|
5
5
|
import type { IndexUiState } from 'instantsearch.js';
|
|
6
6
|
import type { UIMessage } from 'instantsearch.js/es/lib/chat';
|
|
7
7
|
import type { UseChatProps } from 'react-instantsearch-core';
|
|
8
8
|
export declare function createDefaultTools<TObject extends RecordWithObjectID>(itemComponent?: ItemComponent<TObject>, getSearchPageURL?: (nextUiState: IndexUiState) => string): UserClientSideTools;
|
|
9
9
|
type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent'];
|
|
10
|
-
type UiProps = Pick<ChatUiProps, 'open' | 'headerProps' | 'toggleButtonProps' | 'messagesProps' | 'promptProps' | 'suggestionsProps' | 'headerComponent' | 'promptComponent' | 'suggestionsComponent'>;
|
|
10
|
+
type UiProps = Pick<ChatUiProps, 'open' | 'headerProps' | 'toggleButtonProps' | 'messagesProps' | 'promptProps' | 'suggestionsProps' | 'headerComponent' | 'promptComponent' | 'suggestionsComponent' | 'layoutComponent' | 'sendMessage' | 'regenerate' | 'stop' | 'error'>;
|
|
11
11
|
type UserToggleButtonProps = Omit<ChatUiProps['toggleButtonProps'], 'open' | 'onClick'>;
|
|
12
12
|
type UserHeaderProps = Omit<ChatUiProps['headerProps'], 'onClose'>;
|
|
13
13
|
type UserMessagesProps = Omit<ChatUiProps['messagesProps'], 'messages' | 'tools' | 'indexUiState' | 'setIndexUiState' | 'scrollRef' | 'contentRef' | 'messageComponent' | 'leadingComponent' | 'footerComponent' | 'suggestionsComponent' | 'translations' | 'classNames'>;
|
|
14
14
|
type UserPromptProps = Omit<ChatUiProps['promptProps'], 'value' | 'onInput' | 'onSubmit' | 'headerComponent' | 'footerComponent'>;
|
|
15
15
|
export type Tool = UserClientSideTool;
|
|
16
16
|
export type Tools = UserClientSideTools;
|
|
17
|
-
export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<ChatUiProps, keyof UiProps> & UseChatProps<TUiMessage> & {
|
|
17
|
+
export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<ChatUiProps, keyof UiProps | 'ref'> & UseChatProps<TUiMessage> & {
|
|
18
18
|
itemComponent?: ItemComponent<TObject>;
|
|
19
19
|
tools?: UserClientSideTools;
|
|
20
20
|
getSearchPageURL?: (nextUiState: IndexUiState) => string;
|
|
@@ -22,6 +22,7 @@ export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<
|
|
|
22
22
|
headerProps?: UserHeaderProps;
|
|
23
23
|
messagesProps?: UserMessagesProps;
|
|
24
24
|
promptProps?: UserPromptProps;
|
|
25
|
+
layoutComponent?: (props: ChatLayoutOwnProps) => JSX.Element;
|
|
25
26
|
toggleButtonComponent?: ChatUiProps['toggleButtonComponent'];
|
|
26
27
|
toggleButtonIconComponent?: ChatUiProps['toggleButtonProps']['toggleIconComponent'];
|
|
27
28
|
headerComponent?: ChatUiProps['headerComponent'];
|
|
@@ -34,6 +35,7 @@ export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<
|
|
|
34
35
|
promptComponent?: ChatUiProps['promptComponent'];
|
|
35
36
|
promptHeaderComponent?: ChatUiProps['promptProps']['headerComponent'];
|
|
36
37
|
promptFooterComponent?: ChatUiProps['promptProps']['footerComponent'];
|
|
38
|
+
emptyComponent?: ChatUiProps['messagesProps']['emptyComponent'];
|
|
37
39
|
actionsComponent?: ChatUiProps['messagesProps']['actionsComponent'];
|
|
38
40
|
assistantMessageLeadingComponent?: ChatMessageProps['leadingComponent'];
|
|
39
41
|
assistantMessageFooterComponent?: ChatMessageProps['footerComponent'];
|
|
@@ -47,4 +49,13 @@ export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<
|
|
|
47
49
|
messages: ChatUiProps['messagesProps']['translations'];
|
|
48
50
|
}>;
|
|
49
51
|
};
|
|
50
|
-
export
|
|
52
|
+
export type ChatHandle = {
|
|
53
|
+
setOpen: (open: boolean) => void;
|
|
54
|
+
sendMessage: (params: {
|
|
55
|
+
text: string;
|
|
56
|
+
}) => void;
|
|
57
|
+
setInput: (input: string) => void;
|
|
58
|
+
};
|
|
59
|
+
export declare const Chat: <TObject extends RecordWithObjectID = RecordWithObjectID, TUiMessage extends UIMessage = UIMessage>(props: ChatProps<TObject, TUiMessage> & {
|
|
60
|
+
ref?: React.Ref<ChatHandle>;
|
|
61
|
+
}) => React.ReactElement | null;
|
package/dist/es/widgets/Chat.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { _ } from '@swc/helpers/esm/_define_property.js';
|
|
2
|
-
import { _ as _$
|
|
3
|
-
import { _ as _$
|
|
4
|
-
import { _ as _$
|
|
5
|
-
import { _ as _$
|
|
2
|
+
import { _ as _$4 } from '@swc/helpers/esm/_object_spread.js';
|
|
3
|
+
import { _ as _$5 } from '@swc/helpers/esm/_object_spread_props.js';
|
|
4
|
+
import { _ as _$2 } from '@swc/helpers/esm/_object_without_properties.js';
|
|
5
|
+
import { _ as _$3 } from '@swc/helpers/esm/_sliced_to_array.js';
|
|
6
|
+
import { _ as _$1 } from '@swc/helpers/esm/_to_array.js';
|
|
6
7
|
import { createChatComponent } from 'instantsearch-ui-components';
|
|
7
8
|
import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
8
9
|
export { MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
9
|
-
import React, { createElement, Fragment, useState, useRef, useMemo, useEffect } from 'react';
|
|
10
|
+
import React, { createElement, Fragment, useState, useRef, useMemo, useImperativeHandle, useEffect } from 'react';
|
|
10
11
|
import { useInstantSearch, useChat } from 'react-instantsearch-core';
|
|
11
12
|
import { useStickToBottom } from '../lib/useStickToBottom.js';
|
|
12
13
|
import { createCarouselTool } from './chat/tools/SearchIndexTool.js';
|
|
@@ -19,14 +20,18 @@ function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
|
19
20
|
var _obj;
|
|
20
21
|
return _obj = {}, _(_obj, SearchIndexToolType, createCarouselTool(true, itemComponent, getSearchPageURL)), _(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _(_obj, MemorizeToolType, {}), _(_obj, MemorySearchToolType, {}), _(_obj, PonderToolType, {}), _obj;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
var
|
|
23
|
+
function ChatInner(_0, _1) {
|
|
24
|
+
var _ref = [
|
|
25
|
+
_0,
|
|
26
|
+
_1
|
|
27
|
+
], _ref1 = _$1(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, toggleButtonProps = _ref2.toggleButtonProps, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, toggleButtonComponent = _ref2.toggleButtonComponent, toggleButtonIconComponent = _ref2.toggleButtonIconComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, messagesLoaderComponent = _ref2.messagesLoaderComponent, messagesErrorComponent = _ref2.messagesErrorComponent, promptComponent = _ref2.promptComponent, promptHeaderComponent = _ref2.promptHeaderComponent, promptFooterComponent = _ref2.promptFooterComponent, assistantMessageLeadingComponent = _ref2.assistantMessageLeadingComponent, assistantMessageFooterComponent = _ref2.assistantMessageFooterComponent, userMessageLeadingComponent = _ref2.userMessageLeadingComponent, userMessageFooterComponent = _ref2.userMessageFooterComponent, emptyComponent = _ref2.emptyComponent, actionsComponent = _ref2.actionsComponent, suggestionsComponent = _ref2.suggestionsComponent, classNames = _ref2.classNames, _ref_translations = _ref2.translations, translations = _ref_translations === void 0 ? {} : _ref_translations, title = _ref2.title, getSearchPageURL = _ref2.getSearchPageURL, props = _$2(_ref2, [
|
|
24
28
|
"tools",
|
|
25
29
|
"toggleButtonProps",
|
|
26
30
|
"headerProps",
|
|
27
31
|
"messagesProps",
|
|
28
32
|
"promptProps",
|
|
29
33
|
"itemComponent",
|
|
34
|
+
"layoutComponent",
|
|
30
35
|
"toggleButtonComponent",
|
|
31
36
|
"toggleButtonIconComponent",
|
|
32
37
|
"headerComponent",
|
|
@@ -43,16 +48,17 @@ function Chat(_0) {
|
|
|
43
48
|
"assistantMessageFooterComponent",
|
|
44
49
|
"userMessageLeadingComponent",
|
|
45
50
|
"userMessageFooterComponent",
|
|
51
|
+
"emptyComponent",
|
|
46
52
|
"actionsComponent",
|
|
47
53
|
"suggestionsComponent",
|
|
48
54
|
"classNames",
|
|
49
55
|
"translations",
|
|
50
56
|
"title",
|
|
51
57
|
"getSearchPageURL"
|
|
52
|
-
]);
|
|
58
|
+
]), _rest1 = _$3(_rest, 1), ref = _rest1[0];
|
|
53
59
|
var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
|
|
54
60
|
var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, setIndexUiState = _useInstantSearch.setIndexUiState;
|
|
55
|
-
var _useState = _$
|
|
61
|
+
var _useState = _$3(useState(false), 2), maximized = _useState[0], setMaximized = _useState[1];
|
|
56
62
|
var promptRef = useRef(null);
|
|
57
63
|
var _useStickToBottom = useStickToBottom({
|
|
58
64
|
initial: 'smooth',
|
|
@@ -60,16 +66,25 @@ function Chat(_0) {
|
|
|
60
66
|
}), scrollRef = _useStickToBottom.scrollRef, contentRef = _useStickToBottom.contentRef, scrollToBottom = _useStickToBottom.scrollToBottom, isAtBottom = _useStickToBottom.isAtBottom;
|
|
61
67
|
var tools = useMemo(function() {
|
|
62
68
|
var defaults = createDefaultTools(itemComponent, getSearchPageURL);
|
|
63
|
-
return _$
|
|
69
|
+
return _$4({}, defaults, userTools);
|
|
64
70
|
}, [
|
|
65
71
|
getSearchPageURL,
|
|
66
72
|
itemComponent,
|
|
67
73
|
userTools
|
|
68
74
|
]);
|
|
69
|
-
var chatState = useChat(_$
|
|
75
|
+
var chatState = useChat(_$5(_$4({}, props), {
|
|
70
76
|
tools: tools
|
|
71
77
|
}));
|
|
72
|
-
var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop
|
|
78
|
+
var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, isClearing = chatState.isClearing, clearMessages = chatState.clearMessages, onClearTransitionEnd = chatState.onClearTransitionEnd, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState;
|
|
79
|
+
useImperativeHandle(ref, function() {
|
|
80
|
+
return {
|
|
81
|
+
setOpen: setOpen,
|
|
82
|
+
sendMessage: function sendMessage1(params) {
|
|
83
|
+
return sendMessage(params);
|
|
84
|
+
},
|
|
85
|
+
setInput: setInput
|
|
86
|
+
};
|
|
87
|
+
});
|
|
73
88
|
var wasOpenRef = useRef(false);
|
|
74
89
|
useEffect(function() {
|
|
75
90
|
var shouldFocusPrompt = !wasOpenRef.current && open;
|
|
@@ -87,18 +102,23 @@ function Chat(_0) {
|
|
|
87
102
|
title: title,
|
|
88
103
|
open: open,
|
|
89
104
|
maximized: maximized,
|
|
105
|
+
sendMessage: sendMessage,
|
|
106
|
+
regenerate: regenerate,
|
|
107
|
+
stop: stop,
|
|
108
|
+
error: error,
|
|
109
|
+
layoutComponent: layoutComponent,
|
|
90
110
|
headerComponent: headerComponent,
|
|
91
111
|
promptComponent: promptComponent,
|
|
92
112
|
toggleButtonComponent: toggleButtonComponent,
|
|
93
113
|
suggestionsComponent: suggestionsComponent,
|
|
94
|
-
toggleButtonProps: _$
|
|
114
|
+
toggleButtonProps: _$4({
|
|
95
115
|
open: open,
|
|
96
116
|
onClick: function onClick() {
|
|
97
117
|
return setOpen(!open);
|
|
98
118
|
},
|
|
99
119
|
toggleIconComponent: toggleButtonIconComponent
|
|
100
120
|
}, toggleButtonProps),
|
|
101
|
-
headerProps: _$
|
|
121
|
+
headerProps: _$4({
|
|
102
122
|
onClose: function onClose() {
|
|
103
123
|
return setOpen(false);
|
|
104
124
|
},
|
|
@@ -114,7 +134,7 @@ function Chat(_0) {
|
|
|
114
134
|
maximizeIconComponent: headerMaximizeIconComponent,
|
|
115
135
|
translations: headerTranslations
|
|
116
136
|
}, headerProps),
|
|
117
|
-
messagesProps: _$
|
|
137
|
+
messagesProps: _$4({
|
|
118
138
|
status: status,
|
|
119
139
|
onReload: function onReload(messageId) {
|
|
120
140
|
return regenerate({
|
|
@@ -124,6 +144,10 @@ function Chat(_0) {
|
|
|
124
144
|
onClose: function onClose() {
|
|
125
145
|
return setOpen(false);
|
|
126
146
|
},
|
|
147
|
+
sendMessage: sendMessage,
|
|
148
|
+
setInput: setInput,
|
|
149
|
+
onFeedback: onFeedback,
|
|
150
|
+
feedbackState: feedbackState,
|
|
127
151
|
messages: messages,
|
|
128
152
|
tools: toolsFromConnector,
|
|
129
153
|
indexUiState: indexUiState,
|
|
@@ -136,19 +160,20 @@ function Chat(_0) {
|
|
|
136
160
|
onScrollToBottom: scrollToBottom,
|
|
137
161
|
loaderComponent: messagesLoaderComponent,
|
|
138
162
|
errorComponent: messagesErrorComponent,
|
|
163
|
+
emptyComponent: emptyComponent,
|
|
139
164
|
actionsComponent: actionsComponent,
|
|
140
|
-
assistantMessageProps: _$
|
|
165
|
+
assistantMessageProps: _$4({
|
|
141
166
|
leadingComponent: assistantMessageLeadingComponent,
|
|
142
167
|
footerComponent: assistantMessageFooterComponent
|
|
143
168
|
}, messagesProps === null || messagesProps === void 0 ? void 0 : messagesProps.assistantMessageProps),
|
|
144
|
-
userMessageProps: _$
|
|
169
|
+
userMessageProps: _$4({
|
|
145
170
|
leadingComponent: userMessageLeadingComponent,
|
|
146
171
|
footerComponent: userMessageFooterComponent
|
|
147
172
|
}, messagesProps === null || messagesProps === void 0 ? void 0 : messagesProps.userMessageProps),
|
|
148
173
|
translations: messagesTranslations,
|
|
149
174
|
messageTranslations: messageTranslations
|
|
150
175
|
}, messagesProps),
|
|
151
|
-
promptProps: _$
|
|
176
|
+
promptProps: _$4({
|
|
152
177
|
promptRef: promptRef,
|
|
153
178
|
status: status,
|
|
154
179
|
value: input,
|
|
@@ -179,5 +204,6 @@ function Chat(_0) {
|
|
|
179
204
|
classNames: classNames
|
|
180
205
|
});
|
|
181
206
|
}
|
|
207
|
+
var Chat = /*#__PURE__*/ React.forwardRef(ChatInner);
|
|
182
208
|
|
|
183
209
|
export { Chat, createDefaultTools };
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { RefinementListProps as RefinementListUiComponentProps } from '../ui/RefinementList';
|
|
3
|
-
import type { SearchBoxTranslations } from '../ui/SearchBox';
|
|
4
3
|
import type { RefinementListWidgetParams } from 'instantsearch.js/es/widgets/refinement-list/refinement-list';
|
|
5
4
|
import type { UseRefinementListProps } from 'react-instantsearch-core';
|
|
6
5
|
type UiProps = Pick<RefinementListUiComponentProps, 'canRefine' | 'items' | 'onRefine' | 'query' | 'searchBox' | 'noResults' | 'canToggleShowMore' | 'onToggleShowMore' | 'isShowingMore' | 'translations'>;
|
|
7
6
|
export type RefinementListProps = Omit<RefinementListUiComponentProps, keyof UiProps> & UseRefinementListProps & Pick<RefinementListWidgetParams, 'searchable' | 'searchablePlaceholder' | 'searchableSelectOnSubmit'> & {
|
|
8
|
-
translations?: Partial<UiProps['translations'] &
|
|
7
|
+
translations?: Partial<UiProps['translations'] & {
|
|
8
|
+
submitButtonTitle: string;
|
|
9
|
+
resetButtonTitle: string;
|
|
9
10
|
/**
|
|
10
11
|
* What to display when there are no results.
|
|
11
12
|
*/
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { SearchBoxProps as SearchBoxUiComponentProps } from '../ui/SearchBox';
|
|
3
3
|
import type { UseSearchBoxProps } from 'react-instantsearch-core';
|
|
4
|
-
type UiProps = Pick<SearchBoxUiComponentProps, 'inputRef' | 'isSearchStalled' | 'onChange' | 'onReset' | 'onSubmit' | 'value' | 'autoFocus' | 'translations'>;
|
|
4
|
+
type UiProps = Pick<SearchBoxUiComponentProps, 'inputRef' | 'isSearchStalled' | 'onChange' | 'onReset' | 'onSubmit' | 'onAiModeClick' | 'value' | 'autoFocus' | 'translations'>;
|
|
5
5
|
export type SearchBoxProps = Omit<SearchBoxUiComponentProps, Exclude<keyof UiProps, 'onSubmit' | 'autoFocus'>> & UseSearchBoxProps & {
|
|
6
6
|
/**
|
|
7
7
|
* Whether to trigger the search only on submit.
|
|
@@ -14,7 +14,13 @@ export type SearchBoxProps = Omit<SearchBoxUiComponentProps, Exclude<keyof UiPro
|
|
|
14
14
|
* @default false
|
|
15
15
|
*/
|
|
16
16
|
ignoreCompositionEvents?: boolean;
|
|
17
|
+
/**
|
|
18
|
+
* When true, renders an AI mode button inside the search box
|
|
19
|
+
* that opens the Chat widget and sends the current query.
|
|
20
|
+
* Requires a Chat widget on the same index.
|
|
21
|
+
*/
|
|
22
|
+
aiMode?: boolean;
|
|
17
23
|
translations?: Partial<UiProps['translations']>;
|
|
18
24
|
};
|
|
19
|
-
export declare function SearchBox({ queryHook, searchAsYouType, ignoreCompositionEvents, translations, ...props }: SearchBoxProps): React.JSX.Element;
|
|
25
|
+
export declare function SearchBox({ queryHook, searchAsYouType, ignoreCompositionEvents, aiMode, translations, ...props }: SearchBoxProps): React.JSX.Element;
|
|
20
26
|
export {};
|
|
@@ -2,14 +2,15 @@ import { _ as _$2 } from '@swc/helpers/esm/_object_spread.js';
|
|
|
2
2
|
import { _ } from '@swc/helpers/esm/_object_without_properties.js';
|
|
3
3
|
import { _ as _$1 } from '@swc/helpers/esm/_sliced_to_array.js';
|
|
4
4
|
import React, { useState, useRef } from 'react';
|
|
5
|
-
import { useSearchBox } from 'react-instantsearch-core';
|
|
5
|
+
import { useSearchBox, useInstantSearch } from 'react-instantsearch-core';
|
|
6
6
|
import { SearchBox as SearchBox$1 } from '../ui/SearchBox.js';
|
|
7
7
|
|
|
8
8
|
function SearchBox(_0) {
|
|
9
|
-
var queryHook = _0.queryHook, _0_searchAsYouType = _0.searchAsYouType, searchAsYouType = _0_searchAsYouType === void 0 ? true : _0_searchAsYouType, _0_ignoreCompositionEvents = _0.ignoreCompositionEvents, ignoreCompositionEvents = _0_ignoreCompositionEvents === void 0 ? false : _0_ignoreCompositionEvents, translations = _0.translations, props = _(_0, [
|
|
9
|
+
var queryHook = _0.queryHook, _0_searchAsYouType = _0.searchAsYouType, searchAsYouType = _0_searchAsYouType === void 0 ? true : _0_searchAsYouType, _0_ignoreCompositionEvents = _0.ignoreCompositionEvents, ignoreCompositionEvents = _0_ignoreCompositionEvents === void 0 ? false : _0_ignoreCompositionEvents, aiMode = _0.aiMode, translations = _0.translations, props = _(_0, [
|
|
10
10
|
"queryHook",
|
|
11
11
|
"searchAsYouType",
|
|
12
12
|
"ignoreCompositionEvents",
|
|
13
|
+
"aiMode",
|
|
13
14
|
"translations"
|
|
14
15
|
]);
|
|
15
16
|
var _useSearchBox = useSearchBox({
|
|
@@ -17,6 +18,7 @@ function SearchBox(_0) {
|
|
|
17
18
|
}, {
|
|
18
19
|
$$widgetType: 'ais.searchBox'
|
|
19
20
|
}), query = _useSearchBox.query, refine = _useSearchBox.refine, isSearchStalled = _useSearchBox.isSearchStalled;
|
|
21
|
+
var indexRenderState = useInstantSearch().indexRenderState;
|
|
20
22
|
var _useState = _$1(useState(query), 2), inputValue = _useState[0], setInputValue = _useState[1];
|
|
21
23
|
var inputRef = useRef(null);
|
|
22
24
|
function setQuery(newQuery) {
|
|
@@ -56,10 +58,24 @@ function SearchBox(_0) {
|
|
|
56
58
|
onChange: onChange,
|
|
57
59
|
onReset: onReset,
|
|
58
60
|
onSubmit: onSubmit,
|
|
61
|
+
onAiModeClick: aiMode ? function() {
|
|
62
|
+
var chatRenderState = indexRenderState.chat;
|
|
63
|
+
if (chatRenderState) {
|
|
64
|
+
var _chatRenderState_setOpen;
|
|
65
|
+
(_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
|
|
66
|
+
if (inputValue.trim()) {
|
|
67
|
+
var _chatRenderState_sendMessage;
|
|
68
|
+
(_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
|
|
69
|
+
text: inputValue
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
} : undefined,
|
|
59
74
|
value: inputValue,
|
|
60
75
|
translations: _$2({
|
|
61
76
|
submitButtonTitle: 'Submit the search query',
|
|
62
|
-
resetButtonTitle: 'Clear the search query'
|
|
77
|
+
resetButtonTitle: 'Clear the search query',
|
|
78
|
+
aiModeButtonTitle: 'AI Mode'
|
|
63
79
|
}, translations)
|
|
64
80
|
};
|
|
65
81
|
return /*#__PURE__*/ React.createElement(SearchBox$1, _$2({}, props, uiProps));
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TrendingFacetsProps as TrendingFacetsUiComponentProps } from 'instantsearch-ui-components';
|
|
3
|
+
import type { UseTrendingFacetsProps } from 'react-instantsearch-core';
|
|
4
|
+
type UiProps = Pick<TrendingFacetsUiComponentProps, 'items' | 'itemComponent' | 'headerComponent' | 'emptyComponent' | 'status'>;
|
|
5
|
+
export type TrendingFacetsProps = Omit<TrendingFacetsUiComponentProps, keyof UiProps> & UseTrendingFacetsProps & {
|
|
6
|
+
itemComponent?: TrendingFacetsUiComponentProps['itemComponent'];
|
|
7
|
+
headerComponent?: TrendingFacetsUiComponentProps['headerComponent'];
|
|
8
|
+
emptyComponent?: TrendingFacetsUiComponentProps['emptyComponent'];
|
|
9
|
+
};
|
|
10
|
+
export declare function TrendingFacets({ facetName, limit, threshold, fallbackParameters, queryParameters, escapeHTML, transformItems, itemComponent, headerComponent, emptyComponent, ...props }: TrendingFacetsProps): React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { _ as _$1 } from '@swc/helpers/esm/_object_spread.js';
|
|
2
|
+
import { _ } from '@swc/helpers/esm/_object_without_properties.js';
|
|
3
|
+
import { createTrendingFacetsComponent } from 'instantsearch-ui-components';
|
|
4
|
+
import React, { createElement, Fragment } from 'react';
|
|
5
|
+
import { useInstantSearch, useTrendingFacets } from 'react-instantsearch-core';
|
|
6
|
+
|
|
7
|
+
var TrendingFacetsUiComponent = createTrendingFacetsComponent({
|
|
8
|
+
createElement: createElement,
|
|
9
|
+
Fragment: Fragment
|
|
10
|
+
});
|
|
11
|
+
function TrendingFacets(_0) {
|
|
12
|
+
var facetName = _0.facetName, limit = _0.limit, threshold = _0.threshold, fallbackParameters = _0.fallbackParameters, queryParameters = _0.queryParameters, escapeHTML = _0.escapeHTML, transformItems = _0.transformItems, itemComponent = _0.itemComponent, headerComponent = _0.headerComponent, emptyComponent = _0.emptyComponent, props = _(_0, [
|
|
13
|
+
"facetName",
|
|
14
|
+
"limit",
|
|
15
|
+
"threshold",
|
|
16
|
+
"fallbackParameters",
|
|
17
|
+
"queryParameters",
|
|
18
|
+
"escapeHTML",
|
|
19
|
+
"transformItems",
|
|
20
|
+
"itemComponent",
|
|
21
|
+
"headerComponent",
|
|
22
|
+
"emptyComponent"
|
|
23
|
+
]);
|
|
24
|
+
var status = useInstantSearch().status;
|
|
25
|
+
var items = useTrendingFacets({
|
|
26
|
+
facetName: facetName,
|
|
27
|
+
limit: limit,
|
|
28
|
+
threshold: threshold,
|
|
29
|
+
fallbackParameters: fallbackParameters,
|
|
30
|
+
queryParameters: queryParameters,
|
|
31
|
+
escapeHTML: escapeHTML,
|
|
32
|
+
transformItems: transformItems
|
|
33
|
+
}, {
|
|
34
|
+
$$widgetType: 'ais.trendingFacets'
|
|
35
|
+
}).items;
|
|
36
|
+
var uiProps = {
|
|
37
|
+
items: items,
|
|
38
|
+
itemComponent: itemComponent,
|
|
39
|
+
headerComponent: headerComponent,
|
|
40
|
+
emptyComponent: emptyComponent,
|
|
41
|
+
status: status
|
|
42
|
+
};
|
|
43
|
+
return /*#__PURE__*/ React.createElement(TrendingFacetsUiComponent, _$1({}, props, uiProps));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { TrendingFacets };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { _ } from '@swc/helpers/esm/_object_spread.js';
|
|
2
2
|
import { createButtonComponent, ArrowRightIcon, ChevronLeftIcon, ChevronRightIcon } from 'instantsearch-ui-components';
|
|
3
|
+
import { addAbsolutePosition, addQueryID } from 'instantsearch.js/es/lib/utils/index.js';
|
|
3
4
|
import React, { createElement } from 'react';
|
|
4
5
|
import { Carousel } from '../../../components/Carousel.js';
|
|
5
6
|
|
|
@@ -8,10 +9,13 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
|
8
9
|
createElement: createElement
|
|
9
10
|
});
|
|
10
11
|
function SearchLayoutComponent(param) {
|
|
11
|
-
var message = param.message, applyFilters = param.applyFilters, onClose = param.onClose;
|
|
12
|
+
var message = param.message, applyFilters = param.applyFilters, onClose = param.onClose, sendEvent = param.sendEvent;
|
|
13
|
+
var _ref;
|
|
14
|
+
var _output_hits;
|
|
12
15
|
var input = message === null || message === void 0 ? void 0 : message.input;
|
|
13
16
|
var output = message === null || message === void 0 ? void 0 : message.output;
|
|
14
|
-
var
|
|
17
|
+
var hitsWithAbsolutePosition = addAbsolutePosition((output === null || output === void 0 ? void 0 : output.hits) || [], 0, ((_ref = input === null || input === void 0 ? void 0 : input.number_of_results) !== null && _ref !== void 0 ? _ref : output === null || output === void 0 ? void 0 : (_output_hits = output.hits) === null || _output_hits === void 0 ? void 0 : _output_hits.length) || 5);
|
|
18
|
+
var items = addQueryID(hitsWithAbsolutePosition, output === null || output === void 0 ? void 0 : output.queryID);
|
|
15
19
|
var MemoedHeaderComponent = React.useMemo(function() {
|
|
16
20
|
return function(props) {
|
|
17
21
|
return /*#__PURE__*/ React.createElement(HeaderComponent, _({
|
|
@@ -32,7 +36,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
|
32
36
|
return /*#__PURE__*/ React.createElement(Carousel, {
|
|
33
37
|
items: items,
|
|
34
38
|
itemComponent: itemComponent,
|
|
35
|
-
sendEvent:
|
|
39
|
+
sendEvent: sendEvent,
|
|
36
40
|
showNavigation: false,
|
|
37
41
|
headerComponent: MemoedHeaderComponent
|
|
38
42
|
});
|
package/dist/es/widgets/index.js
CHANGED
|
@@ -23,5 +23,6 @@ export { SortBy } from './SortBy.js';
|
|
|
23
23
|
export { Stats } from './Stats.js';
|
|
24
24
|
export { ToggleRefinement } from './ToggleRefinement.js';
|
|
25
25
|
export { TrendingItems } from './TrendingItems.js';
|
|
26
|
+
export { TrendingFacets } from './TrendingFacets.js';
|
|
26
27
|
export { FilterSuggestions } from './FilterSuggestions.js';
|
|
27
28
|
export { MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|