react-instantsearch 7.42.0 → 7.44.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
|
@@ -111,6 +111,7 @@ function ChatInner(_0, _1) {
|
|
|
111
111
|
"disableTriggerValidation",
|
|
112
112
|
"showReasoning"
|
|
113
113
|
]), _rest1 = _sliced_to_array._(_rest, 1), ref = _rest1[0];
|
|
114
|
+
var _ref3;
|
|
114
115
|
var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
|
|
115
116
|
var _useInstantSearch = (0, _reactinstantsearchcore.useInstantSearch)(), indexUiState = _useInstantSearch.indexUiState, setIndexUiState = _useInstantSearch.setIndexUiState;
|
|
116
117
|
var _useState = _sliced_to_array._((0, _react.useState)(false), 2), maximized = _useState[0], setMaximized = _useState[1];
|
|
@@ -136,7 +137,7 @@ function ChatInner(_0, _1) {
|
|
|
136
137
|
tools: tools,
|
|
137
138
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
138
139
|
}));
|
|
139
|
-
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'];
|
|
140
141
|
(0, _react.useImperativeHandle)(ref, function() {
|
|
141
142
|
return {
|
|
142
143
|
setOpen: setOpen,
|
|
@@ -146,19 +147,14 @@ function ChatInner(_0, _1) {
|
|
|
146
147
|
setInput: setInput
|
|
147
148
|
};
|
|
148
149
|
});
|
|
149
|
-
var wasOpenRef = (0, _react.useRef)(false);
|
|
150
150
|
(0, _react.useEffect)(function() {
|
|
151
|
-
|
|
152
|
-
if (shouldFocusPrompt) {
|
|
151
|
+
if (consumeInputFocus === null || consumeInputFocus === void 0 ? void 0 : consumeInputFocus()) {
|
|
153
152
|
window.requestAnimationFrame(function() {
|
|
154
153
|
var _promptRef_current;
|
|
155
154
|
(_promptRef_current = promptRef.current) === null || _promptRef_current === void 0 ? void 0 : _promptRef_current.focus();
|
|
156
155
|
});
|
|
157
156
|
}
|
|
158
|
-
|
|
159
|
-
}, [
|
|
160
|
-
open
|
|
161
|
-
]);
|
|
157
|
+
});
|
|
162
158
|
// Keep the conversation pinned to the bottom while streaming. The stick-to-
|
|
163
159
|
// bottom ResizeObserver only reacts to content *height* changes, but tool
|
|
164
160
|
// results such as a horizontally-growing carousel stream in without changing
|
|
@@ -176,7 +172,7 @@ function ChatInner(_0, _1) {
|
|
|
176
172
|
status,
|
|
177
173
|
scrollToBottom
|
|
178
174
|
]);
|
|
179
|
-
var
|
|
175
|
+
var _ref4 = messagesProps !== null && messagesProps !== void 0 ? messagesProps : {}, callerAssistantMessageProps = _ref4.assistantMessageProps, callerUserMessageProps = _ref4.userMessageProps, restMessagesProps = _object_without_properties._(_ref4, [
|
|
180
176
|
"assistantMessageProps",
|
|
181
177
|
"userMessageProps"
|
|
182
178
|
]);
|
|
@@ -249,7 +245,7 @@ function ChatInner(_0, _1) {
|
|
|
249
245
|
}, callerUserMessageProps),
|
|
250
246
|
error: error
|
|
251
247
|
}),
|
|
252
|
-
promptProps: _object_spread._({
|
|
248
|
+
promptProps: _object_spread_props._(_object_spread._({
|
|
253
249
|
promptRef: promptRef,
|
|
254
250
|
status: status,
|
|
255
251
|
value: input,
|
|
@@ -268,7 +264,9 @@ function ChatInner(_0, _1) {
|
|
|
268
264
|
},
|
|
269
265
|
headerComponent: promptHeaderComponent,
|
|
270
266
|
footerComponent: promptFooterComponent
|
|
271
|
-
}, promptProps),
|
|
267
|
+
}, promptProps), {
|
|
268
|
+
autoFocus: (_ref3 = promptProps === null || promptProps === void 0 ? void 0 : promptProps.autoFocus) !== null && _ref3 !== void 0 ? _ref3 : !isOpenStatePersistenceEnabled || isInlineLayoutComponent
|
|
269
|
+
}),
|
|
272
270
|
suggestionsProps: {
|
|
273
271
|
suggestions: suggestions,
|
|
274
272
|
onSuggestionClick: function onSuggestionClick(suggestion) {
|
|
@@ -9,7 +9,7 @@ export declare function createDefaultTools<TObject extends RecordWithObjectID>(i
|
|
|
9
9
|
type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent'];
|
|
10
10
|
type UiProps = Pick<ChatUiProps, 'open' | 'headerProps' | 'messagesProps' | 'promptProps' | 'suggestionsProps' | 'headerComponent' | 'promptComponent' | 'suggestionsComponent' | 'layoutComponent' | 'sendMessage' | 'regenerate' | 'stop' | 'error'>;
|
|
11
11
|
type UserHeaderProps = Omit<ChatUiProps['headerProps'], 'onClose'>;
|
|
12
|
-
type UserMessagesProps = Omit<ChatUiProps['messagesProps'], 'messages' | 'tools' | 'indexUiState' | 'setIndexUiState' | 'scrollRef' | 'contentRef' | 'messageComponent' | 'leadingComponent' | 'footerComponent' | 'suggestionsComponent' | 'translations' | 'classNames'>;
|
|
12
|
+
type UserMessagesProps<TUiMessage extends UIMessage = UIMessage> = Omit<ChatUiProps<TUiMessage>['messagesProps'], 'messages' | 'tools' | 'indexUiState' | 'setIndexUiState' | 'scrollRef' | 'contentRef' | 'messageComponent' | 'leadingComponent' | 'footerComponent' | 'suggestionsComponent' | 'translations' | 'classNames'>;
|
|
13
13
|
type UserPromptProps = Omit<ChatUiProps['promptProps'], 'value' | 'onInput' | 'onSubmit' | 'headerComponent' | 'footerComponent'>;
|
|
14
14
|
export type Tool = UserClientSideTool;
|
|
15
15
|
export type Tools = UserClientSideTools;
|
|
@@ -18,7 +18,7 @@ export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<
|
|
|
18
18
|
tools?: UserClientSideTools;
|
|
19
19
|
getSearchPageURL?: (nextUiState: IndexUiState) => string;
|
|
20
20
|
headerProps?: UserHeaderProps;
|
|
21
|
-
messagesProps?: UserMessagesProps
|
|
21
|
+
messagesProps?: UserMessagesProps<TUiMessage>;
|
|
22
22
|
promptProps?: UserPromptProps;
|
|
23
23
|
layoutComponent?: (props: ChatLayoutOwnProps) => JSX.Element;
|
|
24
24
|
headerComponent?: ChatUiProps['headerComponent'];
|
package/dist/es/widgets/Chat.js
CHANGED
|
@@ -75,6 +75,7 @@ function ChatInner(_0, _1) {
|
|
|
75
75
|
"disableTriggerValidation",
|
|
76
76
|
"showReasoning"
|
|
77
77
|
]), _rest1 = _$3(_rest, 1), ref = _rest1[0];
|
|
78
|
+
var _ref3;
|
|
78
79
|
var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
|
|
79
80
|
var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, setIndexUiState = _useInstantSearch.setIndexUiState;
|
|
80
81
|
var _useState = _$3(useState(false), 2), maximized = _useState[0], setMaximized = _useState[1];
|
|
@@ -100,7 +101,7 @@ function ChatInner(_0, _1) {
|
|
|
100
101
|
tools: tools,
|
|
101
102
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
102
103
|
}));
|
|
103
|
-
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'];
|
|
104
105
|
useImperativeHandle(ref, function() {
|
|
105
106
|
return {
|
|
106
107
|
setOpen: setOpen,
|
|
@@ -110,19 +111,14 @@ function ChatInner(_0, _1) {
|
|
|
110
111
|
setInput: setInput
|
|
111
112
|
};
|
|
112
113
|
});
|
|
113
|
-
var wasOpenRef = useRef(false);
|
|
114
114
|
useEffect(function() {
|
|
115
|
-
|
|
116
|
-
if (shouldFocusPrompt) {
|
|
115
|
+
if (consumeInputFocus === null || consumeInputFocus === void 0 ? void 0 : consumeInputFocus()) {
|
|
117
116
|
window.requestAnimationFrame(function() {
|
|
118
117
|
var _promptRef_current;
|
|
119
118
|
(_promptRef_current = promptRef.current) === null || _promptRef_current === void 0 ? void 0 : _promptRef_current.focus();
|
|
120
119
|
});
|
|
121
120
|
}
|
|
122
|
-
|
|
123
|
-
}, [
|
|
124
|
-
open
|
|
125
|
-
]);
|
|
121
|
+
});
|
|
126
122
|
// Keep the conversation pinned to the bottom while streaming. The stick-to-
|
|
127
123
|
// bottom ResizeObserver only reacts to content *height* changes, but tool
|
|
128
124
|
// results such as a horizontally-growing carousel stream in without changing
|
|
@@ -140,7 +136,7 @@ function ChatInner(_0, _1) {
|
|
|
140
136
|
status,
|
|
141
137
|
scrollToBottom
|
|
142
138
|
]);
|
|
143
|
-
var
|
|
139
|
+
var _ref4 = messagesProps !== null && messagesProps !== void 0 ? messagesProps : {}, callerAssistantMessageProps = _ref4.assistantMessageProps, callerUserMessageProps = _ref4.userMessageProps, restMessagesProps = _$2(_ref4, [
|
|
144
140
|
"assistantMessageProps",
|
|
145
141
|
"userMessageProps"
|
|
146
142
|
]);
|
|
@@ -213,7 +209,7 @@ function ChatInner(_0, _1) {
|
|
|
213
209
|
}, callerUserMessageProps),
|
|
214
210
|
error: error
|
|
215
211
|
}),
|
|
216
|
-
promptProps: _$5({
|
|
212
|
+
promptProps: _$4(_$5({
|
|
217
213
|
promptRef: promptRef,
|
|
218
214
|
status: status,
|
|
219
215
|
value: input,
|
|
@@ -232,7 +228,9 @@ function ChatInner(_0, _1) {
|
|
|
232
228
|
},
|
|
233
229
|
headerComponent: promptHeaderComponent,
|
|
234
230
|
footerComponent: promptFooterComponent
|
|
235
|
-
}, promptProps),
|
|
231
|
+
}, promptProps), {
|
|
232
|
+
autoFocus: (_ref3 = promptProps === null || promptProps === void 0 ? void 0 : promptProps.autoFocus) !== null && _ref3 !== void 0 ? _ref3 : !isOpenStatePersistenceEnabled || isInlineLayoutComponent
|
|
233
|
+
}),
|
|
236
234
|
suggestionsProps: {
|
|
237
235
|
suggestions: suggestions,
|
|
238
236
|
onSuggestionClick: function onSuggestionClick(suggestion) {
|