react-instantsearch 7.41.0 → 7.43.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/Carousel.js +3 -1
- package/dist/cjs/widgets/Autocomplete.js +1 -1
- package/dist/cjs/widgets/Chat.js +40 -19
- package/dist/cjs/widgets/PromptSuggestions.js +66 -0
- package/dist/cjs/widgets/chat/tools/DisplayResultsTool.js +36 -30
- package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +1 -0
- package/dist/cjs/widgets/index.js +1 -0
- package/dist/es/components/Carousel.js +4 -2
- package/dist/es/index.js +1 -0
- package/dist/es/widgets/Autocomplete.js +1 -1
- package/dist/es/widgets/Chat.d.ts +4 -0
- package/dist/es/widgets/Chat.js +47 -26
- package/dist/es/widgets/PromptSuggestions.d.ts +23 -0
- package/dist/es/widgets/PromptSuggestions.js +57 -0
- package/dist/es/widgets/chat/tools/DisplayResultsTool.js +37 -31
- package/dist/es/widgets/chat/tools/SearchIndexTool.js +2 -1
- package/dist/es/widgets/index.d.ts +1 -0
- package/dist/es/widgets/index.js +1 -0
- package/dist/umd/ReactInstantSearch.js +1657 -351
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
|
@@ -16,7 +16,9 @@ var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
|
16
16
|
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
17
17
|
var CarouselUiComponent = (0, _instantsearchuicomponents.createCarouselComponent)({
|
|
18
18
|
createElement: _react.createElement,
|
|
19
|
-
Fragment: _react.Fragment
|
|
19
|
+
Fragment: _react.Fragment,
|
|
20
|
+
useEffect: _react.useEffect,
|
|
21
|
+
useRef: _react.useRef
|
|
20
22
|
});
|
|
21
23
|
function Carousel(props) {
|
|
22
24
|
var _useState = _sliced_to_array._((0, _react.useState)(false), 2), canScrollLeft = _useState[0], setCanScrollLeft = _useState[1];
|
package/dist/cjs/widgets/Chat.js
CHANGED
|
@@ -59,11 +59,28 @@ function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
|
59
59
|
var _obj;
|
|
60
60
|
return _obj = {}, _define_property._(_obj, _chat.SearchIndexToolType, (0, _SearchIndexTool.createCarouselTool)(true, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.RecommendToolType, (0, _SearchIndexTool.createCarouselTool)(false, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.DisplayResultsToolType, (0, _DisplayResultsTool.createDisplayResultsTool)(itemComponent)), _define_property._(_obj, _chat.MemorizeToolType, {}), _define_property._(_obj, _chat.MemorySearchToolType, {}), _define_property._(_obj, _chat.PonderToolType, {}), _obj;
|
|
61
61
|
}
|
|
62
|
+
function mergeToolOptions(defaultTools, userTools) {
|
|
63
|
+
if (!userTools) {
|
|
64
|
+
return defaultTools;
|
|
65
|
+
}
|
|
66
|
+
var tools = _object_spread._({}, defaultTools, userTools);
|
|
67
|
+
Object.keys(userTools).forEach(function(toolName) {
|
|
68
|
+
var _defaultTools_toolName;
|
|
69
|
+
var userTool = userTools[toolName];
|
|
70
|
+
var defaultStreamInput = (_defaultTools_toolName = defaultTools[toolName]) === null || _defaultTools_toolName === void 0 ? void 0 : _defaultTools_toolName.streamInput;
|
|
71
|
+
if (userTool.layoutComponent !== undefined && userTool.streamInput === undefined && defaultStreamInput !== undefined) {
|
|
72
|
+
tools[toolName] = _object_spread_props._(_object_spread._({}, userTool), {
|
|
73
|
+
streamInput: defaultStreamInput
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return tools;
|
|
78
|
+
}
|
|
62
79
|
function ChatInner(_0, _1) {
|
|
63
80
|
var _ref = [
|
|
64
81
|
_0,
|
|
65
82
|
_1
|
|
66
|
-
], _ref1 = _to_array._(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, loaderComponent = _ref2.loaderComponent, 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, _ref_disableTriggerValidation = _ref2.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, props = _object_without_properties._(_ref2, [
|
|
83
|
+
], _ref1 = _to_array._(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, loaderComponent = _ref2.loaderComponent, 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, _ref_disableTriggerValidation = _ref2.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, showReasoning = _ref2.showReasoning, props = _object_without_properties._(_ref2, [
|
|
67
84
|
"tools",
|
|
68
85
|
"headerProps",
|
|
69
86
|
"messagesProps",
|
|
@@ -91,8 +108,10 @@ function ChatInner(_0, _1) {
|
|
|
91
108
|
"translations",
|
|
92
109
|
"title",
|
|
93
110
|
"getSearchPageURL",
|
|
94
|
-
"disableTriggerValidation"
|
|
111
|
+
"disableTriggerValidation",
|
|
112
|
+
"showReasoning"
|
|
95
113
|
]), _rest1 = _sliced_to_array._(_rest, 1), ref = _rest1[0];
|
|
114
|
+
var _ref3;
|
|
96
115
|
var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
|
|
97
116
|
var _useInstantSearch = (0, _reactinstantsearchcore.useInstantSearch)(), indexUiState = _useInstantSearch.indexUiState, setIndexUiState = _useInstantSearch.setIndexUiState;
|
|
98
117
|
var _useState = _sliced_to_array._((0, _react.useState)(false), 2), maximized = _useState[0], setMaximized = _useState[1];
|
|
@@ -103,7 +122,7 @@ function ChatInner(_0, _1) {
|
|
|
103
122
|
}), scrollRef = _useStickToBottom1.scrollRef, contentRef = _useStickToBottom1.contentRef, scrollToBottom = _useStickToBottom1.scrollToBottom, isAtBottom = _useStickToBottom1.isAtBottom;
|
|
104
123
|
var tools = (0, _react.useMemo)(function() {
|
|
105
124
|
var defaults = createDefaultTools(itemComponent, getSearchPageURL);
|
|
106
|
-
return
|
|
125
|
+
return mergeToolOptions(defaults, userTools);
|
|
107
126
|
}, [
|
|
108
127
|
getSearchPageURL,
|
|
109
128
|
itemComponent,
|
|
@@ -118,7 +137,7 @@ function ChatInner(_0, _1) {
|
|
|
118
137
|
tools: tools,
|
|
119
138
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
120
139
|
}));
|
|
121
|
-
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, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState;
|
|
140
|
+
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, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
|
|
122
141
|
(0, _react.useImperativeHandle)(ref, function() {
|
|
123
142
|
return {
|
|
124
143
|
setOpen: setOpen,
|
|
@@ -128,19 +147,14 @@ function ChatInner(_0, _1) {
|
|
|
128
147
|
setInput: setInput
|
|
129
148
|
};
|
|
130
149
|
});
|
|
131
|
-
var wasOpenRef = (0, _react.useRef)(false);
|
|
132
150
|
(0, _react.useEffect)(function() {
|
|
133
|
-
|
|
134
|
-
if (shouldFocusPrompt) {
|
|
151
|
+
if (consumeInputFocus === null || consumeInputFocus === void 0 ? void 0 : consumeInputFocus()) {
|
|
135
152
|
window.requestAnimationFrame(function() {
|
|
136
153
|
var _promptRef_current;
|
|
137
154
|
(_promptRef_current = promptRef.current) === null || _promptRef_current === void 0 ? void 0 : _promptRef_current.focus();
|
|
138
155
|
});
|
|
139
156
|
}
|
|
140
|
-
|
|
141
|
-
}, [
|
|
142
|
-
open
|
|
143
|
-
]);
|
|
157
|
+
});
|
|
144
158
|
// Keep the conversation pinned to the bottom while streaming. The stick-to-
|
|
145
159
|
// bottom ResizeObserver only reacts to content *height* changes, but tool
|
|
146
160
|
// results such as a horizontally-growing carousel stream in without changing
|
|
@@ -158,6 +172,10 @@ function ChatInner(_0, _1) {
|
|
|
158
172
|
status,
|
|
159
173
|
scrollToBottom
|
|
160
174
|
]);
|
|
175
|
+
var _ref4 = messagesProps !== null && messagesProps !== void 0 ? messagesProps : {}, callerAssistantMessageProps = _ref4.assistantMessageProps, callerUserMessageProps = _ref4.userMessageProps, restMessagesProps = _object_without_properties._(_ref4, [
|
|
176
|
+
"assistantMessageProps",
|
|
177
|
+
"userMessageProps"
|
|
178
|
+
]);
|
|
161
179
|
return /*#__PURE__*/ _react.default.createElement(ChatUiComponent, {
|
|
162
180
|
title: title,
|
|
163
181
|
open: open,
|
|
@@ -213,20 +231,21 @@ function ChatInner(_0, _1) {
|
|
|
213
231
|
errorComponent: messagesErrorComponent,
|
|
214
232
|
emptyComponent: emptyComponent,
|
|
215
233
|
actionsComponent: actionsComponent,
|
|
234
|
+
translations: messagesTranslations,
|
|
235
|
+
messageTranslations: messageTranslations
|
|
236
|
+
}, restMessagesProps), {
|
|
216
237
|
assistantMessageProps: _object_spread._({
|
|
217
238
|
leadingComponent: assistantMessageLeadingComponent,
|
|
218
|
-
footerComponent: assistantMessageFooterComponent
|
|
219
|
-
|
|
239
|
+
footerComponent: assistantMessageFooterComponent,
|
|
240
|
+
showReasoning: showReasoning
|
|
241
|
+
}, callerAssistantMessageProps),
|
|
220
242
|
userMessageProps: _object_spread._({
|
|
221
243
|
leadingComponent: userMessageLeadingComponent,
|
|
222
244
|
footerComponent: userMessageFooterComponent
|
|
223
|
-
},
|
|
224
|
-
translations: messagesTranslations,
|
|
225
|
-
messageTranslations: messageTranslations
|
|
226
|
-
}, messagesProps), {
|
|
245
|
+
}, callerUserMessageProps),
|
|
227
246
|
error: error
|
|
228
247
|
}),
|
|
229
|
-
promptProps: _object_spread._({
|
|
248
|
+
promptProps: _object_spread_props._(_object_spread._({
|
|
230
249
|
promptRef: promptRef,
|
|
231
250
|
status: status,
|
|
232
251
|
value: input,
|
|
@@ -245,7 +264,9 @@ function ChatInner(_0, _1) {
|
|
|
245
264
|
},
|
|
246
265
|
headerComponent: promptHeaderComponent,
|
|
247
266
|
footerComponent: promptFooterComponent
|
|
248
|
-
}, promptProps),
|
|
267
|
+
}, promptProps), {
|
|
268
|
+
autoFocus: (_ref3 = promptProps === null || promptProps === void 0 ? void 0 : promptProps.autoFocus) !== null && _ref3 !== void 0 ? _ref3 : !isOpenStatePersistenceEnabled || isInlineLayoutComponent
|
|
269
|
+
}),
|
|
249
270
|
suggestionsProps: {
|
|
250
271
|
suggestions: suggestions,
|
|
251
272
|
onSuggestionClick: function onSuggestionClick(suggestion) {
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "PromptSuggestions", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return PromptSuggestions;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
14
|
+
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
|
|
15
|
+
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
|
|
16
|
+
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
17
|
+
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
18
|
+
var _reactinstantsearchcore = require("react-instantsearch-core");
|
|
19
|
+
var PromptSuggestionsUi = (0, _instantsearchuicomponents.createPromptSuggestionsComponent)({
|
|
20
|
+
createElement: _react.createElement,
|
|
21
|
+
Fragment: _react.Fragment
|
|
22
|
+
});
|
|
23
|
+
function PromptSuggestions(_0) {
|
|
24
|
+
var _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, LayoutComponent = _0.layoutComponent, onSuggestionClickOverride = _0.onSuggestionClick, // Connector params — forwarded to the hook, not the UI root.
|
|
25
|
+
agentId = _0.agentId, transport = _0.transport, configurationId = _0.configurationId, transformHits = _0.transformHits, context = _0.context, transformItems = _0.transformItems, props = _object_without_properties._(_0, [
|
|
26
|
+
"classNames",
|
|
27
|
+
"layoutComponent",
|
|
28
|
+
"onSuggestionClick",
|
|
29
|
+
"agentId",
|
|
30
|
+
"transport",
|
|
31
|
+
"configurationId",
|
|
32
|
+
"transformHits",
|
|
33
|
+
"context",
|
|
34
|
+
"transformItems"
|
|
35
|
+
]);
|
|
36
|
+
var _usePromptSuggestions = (0, _reactinstantsearchcore.usePromptSuggestions)({
|
|
37
|
+
agentId: agentId,
|
|
38
|
+
transport: transport,
|
|
39
|
+
configurationId: configurationId,
|
|
40
|
+
transformHits: transformHits,
|
|
41
|
+
context: context,
|
|
42
|
+
transformItems: transformItems
|
|
43
|
+
}, {
|
|
44
|
+
$$widgetType: 'ais.promptSuggestions'
|
|
45
|
+
}), suggestions = _usePromptSuggestions.suggestions, isLoading = _usePromptSuggestions.isLoading, onSuggestionClick = _usePromptSuggestions.onSuggestionClick, isChatBusy = _usePromptSuggestions.isChatBusy, sendToChat = _usePromptSuggestions.sendToChat;
|
|
46
|
+
var handleClick = onSuggestionClickOverride ? function(prompt) {
|
|
47
|
+
return onSuggestionClickOverride(prompt, {
|
|
48
|
+
sendToChat: sendToChat
|
|
49
|
+
});
|
|
50
|
+
} : onSuggestionClick;
|
|
51
|
+
if (LayoutComponent) {
|
|
52
|
+
return /*#__PURE__*/ _react.default.createElement(LayoutComponent, {
|
|
53
|
+
suggestions: suggestions,
|
|
54
|
+
isLoading: isLoading,
|
|
55
|
+
onSuggestionClick: handleClick,
|
|
56
|
+
isChatBusy: isChatBusy
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return /*#__PURE__*/ _react.default.createElement(PromptSuggestionsUi, _object_spread_props._(_object_spread._({}, props), {
|
|
60
|
+
classNames: classNames,
|
|
61
|
+
suggestions: suggestions,
|
|
62
|
+
isLoading: isLoading,
|
|
63
|
+
onSuggestionClick: handleClick,
|
|
64
|
+
disabled: isChatBusy
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
@@ -17,11 +17,43 @@ function createDisplayResultsTool(itemComponent) {
|
|
|
17
17
|
var DisplayResultsUIComponent = (0, _instantsearchuicomponents.createDisplayResultsToolComponent)({
|
|
18
18
|
createElement: _react.createElement,
|
|
19
19
|
Fragment: _react.Fragment,
|
|
20
|
-
|
|
20
|
+
useEffect: _react.useEffect,
|
|
21
|
+
useMemo: _react.useMemo,
|
|
22
|
+
useRef: _react.useRef
|
|
21
23
|
});
|
|
22
24
|
var Button = (0, _instantsearchuicomponents.createButtonComponent)({
|
|
23
25
|
createElement: _react.createElement
|
|
24
26
|
});
|
|
27
|
+
var DisplayResultsCarouselHeader = function DisplayResultsCarouselHeader(param) {
|
|
28
|
+
var nbItems = param.nbItems, canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight;
|
|
29
|
+
return /*#__PURE__*/ _react.default.createElement("div", {
|
|
30
|
+
className: "ais-ChatToolDisplayResultsCarouselHeader"
|
|
31
|
+
}, /*#__PURE__*/ _react.default.createElement("div", {
|
|
32
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderCount"
|
|
33
|
+
}, nbItems, " result", nbItems > 1 ? 's' : ''), /*#__PURE__*/ _react.default.createElement("div", {
|
|
34
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButtons"
|
|
35
|
+
}, /*#__PURE__*/ _react.default.createElement(Button, {
|
|
36
|
+
variant: "outline",
|
|
37
|
+
size: "sm",
|
|
38
|
+
iconOnly: true,
|
|
39
|
+
"aria-label": "Previous",
|
|
40
|
+
onClick: scrollLeft,
|
|
41
|
+
disabled: !canScrollLeft,
|
|
42
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
|
|
43
|
+
}, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronLeftIcon, {
|
|
44
|
+
createElement: _react.createElement
|
|
45
|
+
})), /*#__PURE__*/ _react.default.createElement(Button, {
|
|
46
|
+
variant: "outline",
|
|
47
|
+
size: "sm",
|
|
48
|
+
iconOnly: true,
|
|
49
|
+
"aria-label": "Next",
|
|
50
|
+
onClick: scrollRight,
|
|
51
|
+
disabled: !canScrollRight,
|
|
52
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
|
|
53
|
+
}, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronRightIcon, {
|
|
54
|
+
createElement: _react.createElement
|
|
55
|
+
}))));
|
|
56
|
+
};
|
|
25
57
|
var DisplayResultsLayoutComponent = function DisplayResultsLayoutComponent(toolProps) {
|
|
26
58
|
return /*#__PURE__*/ _react.default.createElement(DisplayResultsUIComponent, {
|
|
27
59
|
toolProps: toolProps,
|
|
@@ -32,39 +64,13 @@ function createDisplayResultsTool(itemComponent) {
|
|
|
32
64
|
itemComponent: itemComponent,
|
|
33
65
|
sendEvent: sendEvent,
|
|
34
66
|
showNavigation: false,
|
|
35
|
-
headerComponent:
|
|
36
|
-
var canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight;
|
|
37
|
-
return /*#__PURE__*/ _react.default.createElement("div", {
|
|
38
|
-
className: "ais-ChatToolDisplayResultsCarouselHeader"
|
|
39
|
-
}, /*#__PURE__*/ _react.default.createElement("div", {
|
|
40
|
-
className: "ais-ChatToolDisplayResultsCarouselHeaderCount"
|
|
41
|
-
}, items.length, " result", items.length > 1 ? 's' : ''), /*#__PURE__*/ _react.default.createElement("div", {
|
|
42
|
-
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButtons"
|
|
43
|
-
}, /*#__PURE__*/ _react.default.createElement(Button, {
|
|
44
|
-
variant: "outline",
|
|
45
|
-
size: "sm",
|
|
46
|
-
iconOnly: true,
|
|
47
|
-
onClick: scrollLeft,
|
|
48
|
-
disabled: !canScrollLeft,
|
|
49
|
-
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
|
|
50
|
-
}, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronLeftIcon, {
|
|
51
|
-
createElement: _react.createElement
|
|
52
|
-
})), /*#__PURE__*/ _react.default.createElement(Button, {
|
|
53
|
-
variant: "outline",
|
|
54
|
-
size: "sm",
|
|
55
|
-
iconOnly: true,
|
|
56
|
-
onClick: scrollRight,
|
|
57
|
-
disabled: !canScrollRight,
|
|
58
|
-
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
|
|
59
|
-
}, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronRightIcon, {
|
|
60
|
-
createElement: _react.createElement
|
|
61
|
-
}))));
|
|
62
|
-
}
|
|
67
|
+
headerComponent: DisplayResultsCarouselHeader
|
|
63
68
|
});
|
|
64
69
|
}
|
|
65
70
|
});
|
|
66
71
|
};
|
|
67
72
|
return {
|
|
68
|
-
layoutComponent: DisplayResultsLayoutComponent
|
|
73
|
+
layoutComponent: DisplayResultsLayoutComponent,
|
|
74
|
+
streamInput: true
|
|
69
75
|
};
|
|
70
76
|
}
|
|
@@ -16,6 +16,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
|
16
16
|
var SearchLayoutUIComponent = (0, _instantsearchuicomponents.createCarouselToolComponent)({
|
|
17
17
|
createElement: _react.createElement,
|
|
18
18
|
Fragment: _react.Fragment,
|
|
19
|
+
useEffect: _react.useEffect,
|
|
19
20
|
useMemo: _react.useMemo,
|
|
20
21
|
useRef: _react.useRef,
|
|
21
22
|
useState: _react.useState
|
|
@@ -7,6 +7,7 @@ var _export_star = require("@swc/helpers/_/_export_star");
|
|
|
7
7
|
_export_star._(require("./Autocomplete"), exports);
|
|
8
8
|
_export_star._(require("./Breadcrumb"), exports);
|
|
9
9
|
_export_star._(require("./Chat"), exports);
|
|
10
|
+
_export_star._(require("./PromptSuggestions"), exports);
|
|
10
11
|
_export_star._(require("./ChatTrigger"), exports);
|
|
11
12
|
_export_star._(require("./ClearRefinements"), exports);
|
|
12
13
|
_export_star._(require("./CurrentRefinements"), exports);
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { _ as _$1 } from '@swc/helpers/esm/_object_spread.js';
|
|
2
2
|
import { _ } from '@swc/helpers/esm/_sliced_to_array.js';
|
|
3
3
|
import { createCarouselComponent, generateCarouselId } from 'instantsearch-ui-components';
|
|
4
|
-
import React, { createElement, Fragment,
|
|
4
|
+
import React, { createElement, Fragment, useEffect, useRef, useState } from 'react';
|
|
5
5
|
|
|
6
6
|
var CarouselUiComponent = createCarouselComponent({
|
|
7
7
|
createElement: createElement,
|
|
8
|
-
Fragment: Fragment
|
|
8
|
+
Fragment: Fragment,
|
|
9
|
+
useEffect: useEffect,
|
|
10
|
+
useRef: useRef
|
|
9
11
|
});
|
|
10
12
|
function Carousel(props) {
|
|
11
13
|
var _useState = _(useState(false), 2), canScrollLeft = _useState[0], setCanScrollLeft = _useState[1];
|
package/dist/es/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { Autocomplete, EXPERIMENTAL_Autocomplete } from './widgets/Autocomplete.
|
|
|
4
4
|
export { Breadcrumb } from './widgets/Breadcrumb.js';
|
|
5
5
|
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
6
6
|
export { Chat, createDefaultTools } from './widgets/Chat.js';
|
|
7
|
+
export { PromptSuggestions } from './widgets/PromptSuggestions.js';
|
|
7
8
|
export { ChatTrigger } from './widgets/ChatTrigger.js';
|
|
8
9
|
export { ClearRefinements } from './widgets/ClearRefinements.js';
|
|
9
10
|
export { CurrentRefinements } from './widgets/CurrentRefinements.js';
|
|
@@ -38,6 +38,10 @@ export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<
|
|
|
38
38
|
userMessageLeadingComponent?: ChatMessageProps['leadingComponent'];
|
|
39
39
|
userMessageFooterComponent?: ChatMessageProps['footerComponent'];
|
|
40
40
|
suggestionsComponent?: ChatUiProps['suggestionsComponent'];
|
|
41
|
+
/**
|
|
42
|
+
* Whether to render reasoning parts
|
|
43
|
+
*/
|
|
44
|
+
showReasoning?: boolean;
|
|
41
45
|
translations?: Partial<{
|
|
42
46
|
prompt: ChatUiProps['promptProps']['translations'];
|
|
43
47
|
header: ChatUiProps['headerProps']['translations'];
|
package/dist/es/widgets/Chat.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ } from '@swc/helpers/esm/_define_property.js';
|
|
2
|
-
import { _ as _$
|
|
3
|
-
import { _ as _$
|
|
2
|
+
import { _ as _$5 } from '@swc/helpers/esm/_object_spread.js';
|
|
3
|
+
import { _ as _$4 } from '@swc/helpers/esm/_object_spread_props.js';
|
|
4
4
|
import { _ as _$2 } from '@swc/helpers/esm/_object_without_properties.js';
|
|
5
5
|
import { _ as _$3 } from '@swc/helpers/esm/_sliced_to_array.js';
|
|
6
6
|
import { _ as _$1 } from '@swc/helpers/esm/_to_array.js';
|
|
@@ -23,11 +23,28 @@ function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
|
23
23
|
var _obj;
|
|
24
24
|
return _obj = {}, _(_obj, SearchIndexToolType, createCarouselTool(true, itemComponent, getSearchPageURL)), _(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _(_obj, DisplayResultsToolType, createDisplayResultsTool(itemComponent)), _(_obj, MemorizeToolType, {}), _(_obj, MemorySearchToolType, {}), _(_obj, PonderToolType, {}), _obj;
|
|
25
25
|
}
|
|
26
|
+
function mergeToolOptions(defaultTools, userTools) {
|
|
27
|
+
if (!userTools) {
|
|
28
|
+
return defaultTools;
|
|
29
|
+
}
|
|
30
|
+
var tools = _$5({}, defaultTools, userTools);
|
|
31
|
+
Object.keys(userTools).forEach(function(toolName) {
|
|
32
|
+
var _defaultTools_toolName;
|
|
33
|
+
var userTool = userTools[toolName];
|
|
34
|
+
var defaultStreamInput = (_defaultTools_toolName = defaultTools[toolName]) === null || _defaultTools_toolName === void 0 ? void 0 : _defaultTools_toolName.streamInput;
|
|
35
|
+
if (userTool.layoutComponent !== undefined && userTool.streamInput === undefined && defaultStreamInput !== undefined) {
|
|
36
|
+
tools[toolName] = _$4(_$5({}, userTool), {
|
|
37
|
+
streamInput: defaultStreamInput
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return tools;
|
|
42
|
+
}
|
|
26
43
|
function ChatInner(_0, _1) {
|
|
27
44
|
var _ref = [
|
|
28
45
|
_0,
|
|
29
46
|
_1
|
|
30
|
-
], _ref1 = _$1(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, loaderComponent = _ref2.loaderComponent, 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, _ref_disableTriggerValidation = _ref2.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, props = _$2(_ref2, [
|
|
47
|
+
], _ref1 = _$1(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, loaderComponent = _ref2.loaderComponent, 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, _ref_disableTriggerValidation = _ref2.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, showReasoning = _ref2.showReasoning, props = _$2(_ref2, [
|
|
31
48
|
"tools",
|
|
32
49
|
"headerProps",
|
|
33
50
|
"messagesProps",
|
|
@@ -55,8 +72,10 @@ function ChatInner(_0, _1) {
|
|
|
55
72
|
"translations",
|
|
56
73
|
"title",
|
|
57
74
|
"getSearchPageURL",
|
|
58
|
-
"disableTriggerValidation"
|
|
75
|
+
"disableTriggerValidation",
|
|
76
|
+
"showReasoning"
|
|
59
77
|
]), _rest1 = _$3(_rest, 1), ref = _rest1[0];
|
|
78
|
+
var _ref3;
|
|
60
79
|
var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
|
|
61
80
|
var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, setIndexUiState = _useInstantSearch.setIndexUiState;
|
|
62
81
|
var _useState = _$3(useState(false), 2), maximized = _useState[0], setMaximized = _useState[1];
|
|
@@ -67,7 +86,7 @@ function ChatInner(_0, _1) {
|
|
|
67
86
|
}), scrollRef = _useStickToBottom.scrollRef, contentRef = _useStickToBottom.contentRef, scrollToBottom = _useStickToBottom.scrollToBottom, isAtBottom = _useStickToBottom.isAtBottom;
|
|
68
87
|
var tools = useMemo(function() {
|
|
69
88
|
var defaults = createDefaultTools(itemComponent, getSearchPageURL);
|
|
70
|
-
return
|
|
89
|
+
return mergeToolOptions(defaults, userTools);
|
|
71
90
|
}, [
|
|
72
91
|
getSearchPageURL,
|
|
73
92
|
itemComponent,
|
|
@@ -78,11 +97,11 @@ function ChatInner(_0, _1) {
|
|
|
78
97
|
// set on the layout component, which is consistent across flavors.
|
|
79
98
|
var isInlineLayoutComponent = typeof layoutComponent === 'function' && layoutComponent.$$inlineLayout === true;
|
|
80
99
|
var effectiveDisableTriggerValidation = disableTriggerValidation || isInlineLayoutComponent;
|
|
81
|
-
var chatState = useChat(_$
|
|
100
|
+
var chatState = useChat(_$4(_$5({}, props), {
|
|
82
101
|
tools: tools,
|
|
83
102
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
84
103
|
}));
|
|
85
|
-
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, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState;
|
|
104
|
+
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, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
|
|
86
105
|
useImperativeHandle(ref, function() {
|
|
87
106
|
return {
|
|
88
107
|
setOpen: setOpen,
|
|
@@ -92,19 +111,14 @@ function ChatInner(_0, _1) {
|
|
|
92
111
|
setInput: setInput
|
|
93
112
|
};
|
|
94
113
|
});
|
|
95
|
-
var wasOpenRef = useRef(false);
|
|
96
114
|
useEffect(function() {
|
|
97
|
-
|
|
98
|
-
if (shouldFocusPrompt) {
|
|
115
|
+
if (consumeInputFocus === null || consumeInputFocus === void 0 ? void 0 : consumeInputFocus()) {
|
|
99
116
|
window.requestAnimationFrame(function() {
|
|
100
117
|
var _promptRef_current;
|
|
101
118
|
(_promptRef_current = promptRef.current) === null || _promptRef_current === void 0 ? void 0 : _promptRef_current.focus();
|
|
102
119
|
});
|
|
103
120
|
}
|
|
104
|
-
|
|
105
|
-
}, [
|
|
106
|
-
open
|
|
107
|
-
]);
|
|
121
|
+
});
|
|
108
122
|
// Keep the conversation pinned to the bottom while streaming. The stick-to-
|
|
109
123
|
// bottom ResizeObserver only reacts to content *height* changes, but tool
|
|
110
124
|
// results such as a horizontally-growing carousel stream in without changing
|
|
@@ -122,6 +136,10 @@ function ChatInner(_0, _1) {
|
|
|
122
136
|
status,
|
|
123
137
|
scrollToBottom
|
|
124
138
|
]);
|
|
139
|
+
var _ref4 = messagesProps !== null && messagesProps !== void 0 ? messagesProps : {}, callerAssistantMessageProps = _ref4.assistantMessageProps, callerUserMessageProps = _ref4.userMessageProps, restMessagesProps = _$2(_ref4, [
|
|
140
|
+
"assistantMessageProps",
|
|
141
|
+
"userMessageProps"
|
|
142
|
+
]);
|
|
125
143
|
return /*#__PURE__*/ React.createElement(ChatUiComponent, {
|
|
126
144
|
title: title,
|
|
127
145
|
open: open,
|
|
@@ -134,7 +152,7 @@ function ChatInner(_0, _1) {
|
|
|
134
152
|
headerComponent: headerComponent,
|
|
135
153
|
promptComponent: promptComponent,
|
|
136
154
|
suggestionsComponent: suggestionsComponent,
|
|
137
|
-
headerProps: _$
|
|
155
|
+
headerProps: _$5({
|
|
138
156
|
onClose: function onClose() {
|
|
139
157
|
return setOpen(false);
|
|
140
158
|
},
|
|
@@ -150,7 +168,7 @@ function ChatInner(_0, _1) {
|
|
|
150
168
|
maximizeIconComponent: headerMaximizeIconComponent,
|
|
151
169
|
translations: headerTranslations
|
|
152
170
|
}, headerProps),
|
|
153
|
-
messagesProps: _$
|
|
171
|
+
messagesProps: _$4(_$5({
|
|
154
172
|
status: status,
|
|
155
173
|
onReload: function onReload(messageId) {
|
|
156
174
|
return regenerate({
|
|
@@ -177,20 +195,21 @@ function ChatInner(_0, _1) {
|
|
|
177
195
|
errorComponent: messagesErrorComponent,
|
|
178
196
|
emptyComponent: emptyComponent,
|
|
179
197
|
actionsComponent: actionsComponent,
|
|
180
|
-
|
|
198
|
+
translations: messagesTranslations,
|
|
199
|
+
messageTranslations: messageTranslations
|
|
200
|
+
}, restMessagesProps), {
|
|
201
|
+
assistantMessageProps: _$5({
|
|
181
202
|
leadingComponent: assistantMessageLeadingComponent,
|
|
182
|
-
footerComponent: assistantMessageFooterComponent
|
|
183
|
-
|
|
184
|
-
|
|
203
|
+
footerComponent: assistantMessageFooterComponent,
|
|
204
|
+
showReasoning: showReasoning
|
|
205
|
+
}, callerAssistantMessageProps),
|
|
206
|
+
userMessageProps: _$5({
|
|
185
207
|
leadingComponent: userMessageLeadingComponent,
|
|
186
208
|
footerComponent: userMessageFooterComponent
|
|
187
|
-
},
|
|
188
|
-
translations: messagesTranslations,
|
|
189
|
-
messageTranslations: messageTranslations
|
|
190
|
-
}, messagesProps), {
|
|
209
|
+
}, callerUserMessageProps),
|
|
191
210
|
error: error
|
|
192
211
|
}),
|
|
193
|
-
promptProps: _$4({
|
|
212
|
+
promptProps: _$4(_$5({
|
|
194
213
|
promptRef: promptRef,
|
|
195
214
|
status: status,
|
|
196
215
|
value: input,
|
|
@@ -209,7 +228,9 @@ function ChatInner(_0, _1) {
|
|
|
209
228
|
},
|
|
210
229
|
headerComponent: promptHeaderComponent,
|
|
211
230
|
footerComponent: promptFooterComponent
|
|
212
|
-
}, promptProps),
|
|
231
|
+
}, promptProps), {
|
|
232
|
+
autoFocus: (_ref3 = promptProps === null || promptProps === void 0 ? void 0 : promptProps.autoFocus) !== null && _ref3 !== void 0 ? _ref3 : !isOpenStatePersistenceEnabled || isInlineLayoutComponent
|
|
233
|
+
}),
|
|
213
234
|
suggestionsProps: {
|
|
214
235
|
suggestions: suggestions,
|
|
215
236
|
onSuggestionClick: function onSuggestionClick(suggestion) {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PromptSuggestionsOwnProps } from 'instantsearch-ui-components';
|
|
3
|
+
import type { UsePromptSuggestionsProps } from 'react-instantsearch-core';
|
|
4
|
+
/**
|
|
5
|
+
* Props passed to a custom `layoutComponent`. Mirrors the connector render
|
|
6
|
+
* state so a layout component owns the full markup.
|
|
7
|
+
*/
|
|
8
|
+
export type PromptSuggestionsLayoutComponentProps = {
|
|
9
|
+
suggestions: string[];
|
|
10
|
+
isLoading: boolean;
|
|
11
|
+
onSuggestionClick: (prompt: string) => void;
|
|
12
|
+
isChatBusy: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type PromptSuggestionsOnSuggestionClick = (prompt: string, helpers: {
|
|
15
|
+
sendToChat: (prompt: string) => boolean;
|
|
16
|
+
}) => void;
|
|
17
|
+
type OwnedUiProps = 'suggestions' | 'isLoading' | 'onSuggestionClick' | 'disabled' | 'skeletonCount';
|
|
18
|
+
export type PromptSuggestionsProps = Omit<PromptSuggestionsOwnProps, OwnedUiProps> & UsePromptSuggestionsProps & {
|
|
19
|
+
layoutComponent?: (props: PromptSuggestionsLayoutComponentProps) => JSX.Element | null;
|
|
20
|
+
onSuggestionClick?: PromptSuggestionsOnSuggestionClick;
|
|
21
|
+
};
|
|
22
|
+
export declare function PromptSuggestions({ classNames, layoutComponent: LayoutComponent, onSuggestionClick: onSuggestionClickOverride, agentId, transport, configurationId, transformHits, context, transformItems, ...props }: PromptSuggestionsProps): React.JSX.Element;
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { _ as _$2 } from '@swc/helpers/esm/_object_spread.js';
|
|
2
|
+
import { _ as _$1 } from '@swc/helpers/esm/_object_spread_props.js';
|
|
3
|
+
import { _ } from '@swc/helpers/esm/_object_without_properties.js';
|
|
4
|
+
import { createPromptSuggestionsComponent } from 'instantsearch-ui-components';
|
|
5
|
+
import React, { createElement, Fragment } from 'react';
|
|
6
|
+
import { usePromptSuggestions } from 'react-instantsearch-core';
|
|
7
|
+
|
|
8
|
+
var PromptSuggestionsUi = createPromptSuggestionsComponent({
|
|
9
|
+
createElement: createElement,
|
|
10
|
+
Fragment: Fragment
|
|
11
|
+
});
|
|
12
|
+
function PromptSuggestions(_0) {
|
|
13
|
+
var _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, LayoutComponent = _0.layoutComponent, onSuggestionClickOverride = _0.onSuggestionClick, // Connector params — forwarded to the hook, not the UI root.
|
|
14
|
+
agentId = _0.agentId, transport = _0.transport, configurationId = _0.configurationId, transformHits = _0.transformHits, context = _0.context, transformItems = _0.transformItems, props = _(_0, [
|
|
15
|
+
"classNames",
|
|
16
|
+
"layoutComponent",
|
|
17
|
+
"onSuggestionClick",
|
|
18
|
+
"agentId",
|
|
19
|
+
"transport",
|
|
20
|
+
"configurationId",
|
|
21
|
+
"transformHits",
|
|
22
|
+
"context",
|
|
23
|
+
"transformItems"
|
|
24
|
+
]);
|
|
25
|
+
var _usePromptSuggestions = usePromptSuggestions({
|
|
26
|
+
agentId: agentId,
|
|
27
|
+
transport: transport,
|
|
28
|
+
configurationId: configurationId,
|
|
29
|
+
transformHits: transformHits,
|
|
30
|
+
context: context,
|
|
31
|
+
transformItems: transformItems
|
|
32
|
+
}, {
|
|
33
|
+
$$widgetType: 'ais.promptSuggestions'
|
|
34
|
+
}), suggestions = _usePromptSuggestions.suggestions, isLoading = _usePromptSuggestions.isLoading, onSuggestionClick = _usePromptSuggestions.onSuggestionClick, isChatBusy = _usePromptSuggestions.isChatBusy, sendToChat = _usePromptSuggestions.sendToChat;
|
|
35
|
+
var handleClick = onSuggestionClickOverride ? function(prompt) {
|
|
36
|
+
return onSuggestionClickOverride(prompt, {
|
|
37
|
+
sendToChat: sendToChat
|
|
38
|
+
});
|
|
39
|
+
} : onSuggestionClick;
|
|
40
|
+
if (LayoutComponent) {
|
|
41
|
+
return /*#__PURE__*/ React.createElement(LayoutComponent, {
|
|
42
|
+
suggestions: suggestions,
|
|
43
|
+
isLoading: isLoading,
|
|
44
|
+
onSuggestionClick: handleClick,
|
|
45
|
+
isChatBusy: isChatBusy
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
return /*#__PURE__*/ React.createElement(PromptSuggestionsUi, _$1(_$2({}, props), {
|
|
49
|
+
classNames: classNames,
|
|
50
|
+
suggestions: suggestions,
|
|
51
|
+
isLoading: isLoading,
|
|
52
|
+
onSuggestionClick: handleClick,
|
|
53
|
+
disabled: isChatBusy
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export { PromptSuggestions };
|