react-instantsearch 7.47.0 → 7.48.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/widgets/Chat.js
CHANGED
|
@@ -46,6 +46,7 @@ var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
|
|
|
46
46
|
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
|
|
47
47
|
var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
|
|
48
48
|
var _to_array = require("@swc/helpers/_/_to_array");
|
|
49
|
+
var _to_consumable_array = require("@swc/helpers/_/_to_consumable_array");
|
|
49
50
|
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
50
51
|
var _chat = require("instantsearch.js/cjs/lib/chat");
|
|
51
52
|
var _focusAfterReveal = require("instantsearch.js/cjs/lib/chat/focusAfterReveal");
|
|
@@ -138,7 +139,7 @@ function ChatInner(_0, _1) {
|
|
|
138
139
|
var _ref = [
|
|
139
140
|
_0,
|
|
140
141
|
_1
|
|
141
|
-
], _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, loaderPosition = _ref2.loaderPosition, shouldShowLoader = _ref2.shouldShowLoader, loaderShowDelay = _ref2.loaderShowDelay, loaderMinDuration = _ref2.loaderMinDuration, 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, [
|
|
142
|
+
], _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, loaderPosition = _ref2.loaderPosition, shouldShowLoader = _ref2.shouldShowLoader, loaderShowDelay = _ref2.loaderShowDelay, loaderMinDuration = _ref2.loaderMinDuration, 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, reasoningComponent = _ref2.reasoningComponent, props = _object_without_properties._(_ref2, [
|
|
142
143
|
"tools",
|
|
143
144
|
"headerProps",
|
|
144
145
|
"messagesProps",
|
|
@@ -171,7 +172,8 @@ function ChatInner(_0, _1) {
|
|
|
171
172
|
"title",
|
|
172
173
|
"getSearchPageURL",
|
|
173
174
|
"disableTriggerValidation",
|
|
174
|
-
"showReasoning"
|
|
175
|
+
"showReasoning",
|
|
176
|
+
"reasoningComponent"
|
|
175
177
|
]), _rest1 = _sliced_to_array._(_rest, 1), ref = _rest1[0];
|
|
176
178
|
var _ref3;
|
|
177
179
|
var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
|
|
@@ -202,11 +204,21 @@ function ChatInner(_0, _1) {
|
|
|
202
204
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
203
205
|
}));
|
|
204
206
|
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, suggestionsStatus = chatState.suggestionsStatus, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
|
|
207
|
+
var sendMessageAndScrollToBottom = (0, _react.useCallback)(function() {
|
|
208
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
209
|
+
args[_key] = arguments[_key];
|
|
210
|
+
}
|
|
211
|
+
scrollToBottom();
|
|
212
|
+
return sendMessage.apply(void 0, _to_consumable_array._(args));
|
|
213
|
+
}, [
|
|
214
|
+
scrollToBottom,
|
|
215
|
+
sendMessage
|
|
216
|
+
]);
|
|
205
217
|
(0, _react.useImperativeHandle)(ref, function() {
|
|
206
218
|
return {
|
|
207
219
|
setOpen: setOpen,
|
|
208
|
-
sendMessage: function
|
|
209
|
-
return
|
|
220
|
+
sendMessage: function sendMessage(params) {
|
|
221
|
+
return sendMessageAndScrollToBottom(params);
|
|
210
222
|
},
|
|
211
223
|
setInput: setInput
|
|
212
224
|
};
|
|
@@ -255,7 +267,7 @@ function ChatInner(_0, _1) {
|
|
|
255
267
|
title: title,
|
|
256
268
|
open: open,
|
|
257
269
|
maximized: maximized,
|
|
258
|
-
sendMessage:
|
|
270
|
+
sendMessage: sendMessageAndScrollToBottom,
|
|
259
271
|
regenerate: regenerate,
|
|
260
272
|
stop: stop,
|
|
261
273
|
error: error,
|
|
@@ -290,7 +302,7 @@ function ChatInner(_0, _1) {
|
|
|
290
302
|
onClose: function onClose() {
|
|
291
303
|
return setOpen(false);
|
|
292
304
|
},
|
|
293
|
-
sendMessage:
|
|
305
|
+
sendMessage: sendMessageAndScrollToBottom,
|
|
294
306
|
setInput: setInput,
|
|
295
307
|
onFeedback: onFeedback,
|
|
296
308
|
feedbackState: feedbackState,
|
|
@@ -316,7 +328,8 @@ function ChatInner(_0, _1) {
|
|
|
316
328
|
assistantMessageProps: _object_spread._({
|
|
317
329
|
leadingComponent: assistantMessageLeadingComponent,
|
|
318
330
|
footerComponent: assistantMessageFooterComponent,
|
|
319
|
-
showReasoning: showReasoning
|
|
331
|
+
showReasoning: showReasoning,
|
|
332
|
+
reasoningComponent: reasoningComponent
|
|
320
333
|
}, callerAssistantMessageProps),
|
|
321
334
|
userMessageProps: _object_spread._({
|
|
322
335
|
leadingComponent: userMessageLeadingComponent,
|
|
@@ -333,7 +346,7 @@ function ChatInner(_0, _1) {
|
|
|
333
346
|
setInput(event.currentTarget.value);
|
|
334
347
|
},
|
|
335
348
|
onSubmit: function onSubmit() {
|
|
336
|
-
|
|
349
|
+
sendMessageAndScrollToBottom({
|
|
337
350
|
text: input
|
|
338
351
|
});
|
|
339
352
|
setInput('');
|
|
@@ -350,7 +363,7 @@ function ChatInner(_0, _1) {
|
|
|
350
363
|
suggestions: suggestions,
|
|
351
364
|
isLoading: suggestionsStatus === 'loading',
|
|
352
365
|
onSuggestionClick: function onSuggestionClick(suggestion) {
|
|
353
|
-
|
|
366
|
+
sendMessageAndScrollToBottom({
|
|
354
367
|
text: suggestion
|
|
355
368
|
});
|
|
356
369
|
}
|
|
@@ -60,9 +60,18 @@ export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<
|
|
|
60
60
|
userMessageFooterComponent?: ChatMessageProps['footerComponent'];
|
|
61
61
|
suggestionsComponent?: ChatUiProps['suggestionsComponent'];
|
|
62
62
|
/**
|
|
63
|
-
* Whether to render reasoning
|
|
63
|
+
* Whether to render the reasoning an agent sends. `true` by default, so
|
|
64
|
+
* reasoning that arrives is shown. Pass `false` to suppress it in this
|
|
65
|
+
* widget. It cannot make an agent send reasoning: whether reasoning reaches
|
|
66
|
+
* the client at all is the agent's own `sendReasoning` setting.
|
|
64
67
|
*/
|
|
65
68
|
showReasoning?: boolean;
|
|
69
|
+
/**
|
|
70
|
+
* Custom reasoning renderer. It replaces the built-in disclosure rather than
|
|
71
|
+
* enabling reasoning: reasoning renders by default, and
|
|
72
|
+
* `showReasoning: false` suppresses this renderer along with it.
|
|
73
|
+
*/
|
|
74
|
+
reasoningComponent?: ChatMessageProps<TUiMessage>['reasoningComponent'];
|
|
66
75
|
translations?: Partial<{
|
|
67
76
|
prompt: ChatUiProps['promptProps']['translations'];
|
|
68
77
|
header: ChatUiProps['headerProps']['translations'];
|
package/dist/es/widgets/Chat.js
CHANGED
|
@@ -8,11 +8,12 @@ import { _ as _$5 } from '@swc/helpers/esm/_object_spread_props.js';
|
|
|
8
8
|
import { _ as _$8 } from '@swc/helpers/esm/_object_without_properties.js';
|
|
9
9
|
import { _ as _$9 } from '@swc/helpers/esm/_sliced_to_array.js';
|
|
10
10
|
import { _ as _$7 } from '@swc/helpers/esm/_to_array.js';
|
|
11
|
+
import { _ as _$a } from '@swc/helpers/esm/_to_consumable_array.js';
|
|
11
12
|
import { createChatComponent } from 'instantsearch-ui-components';
|
|
12
13
|
import { SearchIndexToolType, RecommendToolType, DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
13
14
|
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
14
15
|
import { getActiveContainerAnimations, holdContainerInertUntilReveal, restoreContainerInertUntilReveal, focusAfterReveal } from 'instantsearch.js/es/lib/chat/focusAfterReveal.js';
|
|
15
|
-
import React, { createElement, Fragment, useMemo, useState, useEffect, useRef, useImperativeHandle } from 'react';
|
|
16
|
+
import React, { createElement, Fragment, useMemo, useState, useEffect, useRef, useCallback, useImperativeHandle } from 'react';
|
|
16
17
|
import { useInstantSearch, useChat } from 'react-instantsearch-core';
|
|
17
18
|
import { useStickToBottom } from '../lib/useStickToBottom.js';
|
|
18
19
|
import { createDisplayResultsTool } from './chat/tools/DisplayResultsTool.js';
|
|
@@ -102,7 +103,7 @@ function ChatInner(_0, _1) {
|
|
|
102
103
|
var _ref = [
|
|
103
104
|
_0,
|
|
104
105
|
_1
|
|
105
|
-
], _ref1 = _$7(_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, loaderPosition = _ref2.loaderPosition, shouldShowLoader = _ref2.shouldShowLoader, loaderShowDelay = _ref2.loaderShowDelay, loaderMinDuration = _ref2.loaderMinDuration, 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 = _$8(_ref2, [
|
|
106
|
+
], _ref1 = _$7(_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, loaderPosition = _ref2.loaderPosition, shouldShowLoader = _ref2.shouldShowLoader, loaderShowDelay = _ref2.loaderShowDelay, loaderMinDuration = _ref2.loaderMinDuration, 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, reasoningComponent = _ref2.reasoningComponent, props = _$8(_ref2, [
|
|
106
107
|
"tools",
|
|
107
108
|
"headerProps",
|
|
108
109
|
"messagesProps",
|
|
@@ -135,7 +136,8 @@ function ChatInner(_0, _1) {
|
|
|
135
136
|
"title",
|
|
136
137
|
"getSearchPageURL",
|
|
137
138
|
"disableTriggerValidation",
|
|
138
|
-
"showReasoning"
|
|
139
|
+
"showReasoning",
|
|
140
|
+
"reasoningComponent"
|
|
139
141
|
]), _rest1 = _$9(_rest, 1), ref = _rest1[0];
|
|
140
142
|
var _ref3;
|
|
141
143
|
var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
|
|
@@ -166,11 +168,21 @@ function ChatInner(_0, _1) {
|
|
|
166
168
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
167
169
|
}));
|
|
168
170
|
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, suggestionsStatus = chatState.suggestionsStatus, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
|
|
171
|
+
var sendMessageAndScrollToBottom = useCallback(function() {
|
|
172
|
+
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
173
|
+
args[_key] = arguments[_key];
|
|
174
|
+
}
|
|
175
|
+
scrollToBottom();
|
|
176
|
+
return sendMessage.apply(void 0, _$a(args));
|
|
177
|
+
}, [
|
|
178
|
+
scrollToBottom,
|
|
179
|
+
sendMessage
|
|
180
|
+
]);
|
|
169
181
|
useImperativeHandle(ref, function() {
|
|
170
182
|
return {
|
|
171
183
|
setOpen: setOpen,
|
|
172
|
-
sendMessage: function
|
|
173
|
-
return
|
|
184
|
+
sendMessage: function sendMessage(params) {
|
|
185
|
+
return sendMessageAndScrollToBottom(params);
|
|
174
186
|
},
|
|
175
187
|
setInput: setInput
|
|
176
188
|
};
|
|
@@ -219,7 +231,7 @@ function ChatInner(_0, _1) {
|
|
|
219
231
|
title: title,
|
|
220
232
|
open: open,
|
|
221
233
|
maximized: maximized,
|
|
222
|
-
sendMessage:
|
|
234
|
+
sendMessage: sendMessageAndScrollToBottom,
|
|
223
235
|
regenerate: regenerate,
|
|
224
236
|
stop: stop,
|
|
225
237
|
error: error,
|
|
@@ -254,7 +266,7 @@ function ChatInner(_0, _1) {
|
|
|
254
266
|
onClose: function onClose() {
|
|
255
267
|
return setOpen(false);
|
|
256
268
|
},
|
|
257
|
-
sendMessage:
|
|
269
|
+
sendMessage: sendMessageAndScrollToBottom,
|
|
258
270
|
setInput: setInput,
|
|
259
271
|
onFeedback: onFeedback,
|
|
260
272
|
feedbackState: feedbackState,
|
|
@@ -280,7 +292,8 @@ function ChatInner(_0, _1) {
|
|
|
280
292
|
assistantMessageProps: _$6({
|
|
281
293
|
leadingComponent: assistantMessageLeadingComponent,
|
|
282
294
|
footerComponent: assistantMessageFooterComponent,
|
|
283
|
-
showReasoning: showReasoning
|
|
295
|
+
showReasoning: showReasoning,
|
|
296
|
+
reasoningComponent: reasoningComponent
|
|
284
297
|
}, callerAssistantMessageProps),
|
|
285
298
|
userMessageProps: _$6({
|
|
286
299
|
leadingComponent: userMessageLeadingComponent,
|
|
@@ -297,7 +310,7 @@ function ChatInner(_0, _1) {
|
|
|
297
310
|
setInput(event.currentTarget.value);
|
|
298
311
|
},
|
|
299
312
|
onSubmit: function onSubmit() {
|
|
300
|
-
|
|
313
|
+
sendMessageAndScrollToBottom({
|
|
301
314
|
text: input
|
|
302
315
|
});
|
|
303
316
|
setInput('');
|
|
@@ -314,7 +327,7 @@ function ChatInner(_0, _1) {
|
|
|
314
327
|
suggestions: suggestions,
|
|
315
328
|
isLoading: suggestionsStatus === 'loading',
|
|
316
329
|
onSuggestionClick: function onSuggestionClick(suggestion) {
|
|
317
|
-
|
|
330
|
+
sendMessageAndScrollToBottom({
|
|
318
331
|
text: suggestion
|
|
319
332
|
});
|
|
320
333
|
}
|