react-instantsearch 7.36.0 → 7.38.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearch 7.
|
|
1
|
+
/*! React InstantSearch 7.38.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
26
|
|
|
27
|
-
var version$2 = '7.
|
|
27
|
+
var version$2 = '7.38.0';
|
|
28
28
|
|
|
29
29
|
function _define_property(obj, key, value) {
|
|
30
30
|
if (key in obj) {
|
|
@@ -6890,10 +6890,11 @@
|
|
|
6890
6890
|
|
|
6891
6891
|
var hasAlphanumeric = new RegExp(/\w/i);
|
|
6892
6892
|
function getHighlightFromSiblings(parts, i) {
|
|
6893
|
+
var _ref, _ref1;
|
|
6893
6894
|
var _parts_, _parts_1;
|
|
6894
6895
|
var current = parts[i];
|
|
6895
|
-
var isNextHighlighted = ((_parts_ = parts[i + 1]) === null || _parts_ === void 0 ? void 0 : _parts_.isHighlighted)
|
|
6896
|
-
var isPreviousHighlighted = ((_parts_1 = parts[i - 1]) === null || _parts_1 === void 0 ? void 0 : _parts_1.isHighlighted)
|
|
6896
|
+
var isNextHighlighted = (_ref = (_parts_ = parts[i + 1]) === null || _parts_ === void 0 ? void 0 : _parts_.isHighlighted) !== null && _ref !== void 0 ? _ref : true;
|
|
6897
|
+
var isPreviousHighlighted = (_ref1 = (_parts_1 = parts[i - 1]) === null || _parts_1 === void 0 ? void 0 : _parts_1.isHighlighted) !== null && _ref1 !== void 0 ? _ref1 : true;
|
|
6897
6898
|
if (!hasAlphanumeric.test(unescape$1(current.value)) && isPreviousHighlighted === isNextHighlighted) {
|
|
6898
6899
|
return isPreviousHighlighted;
|
|
6899
6900
|
}
|
|
@@ -10821,7 +10822,7 @@
|
|
|
10821
10822
|
};
|
|
10822
10823
|
}
|
|
10823
10824
|
|
|
10824
|
-
var version = '4.
|
|
10825
|
+
var version = '4.104.0';
|
|
10825
10826
|
|
|
10826
10827
|
var withUsage$r = createDocumentationMessageGenerator({
|
|
10827
10828
|
name: 'instantsearch'
|
|
@@ -13123,33 +13124,74 @@
|
|
|
13123
13124
|
}
|
|
13124
13125
|
break;
|
|
13125
13126
|
}
|
|
13126
|
-
case 'tool-error':
|
|
13127
|
+
case 'tool-input-error':
|
|
13127
13128
|
{
|
|
13129
|
+
var _chunk_input, _chunk_providerExecuted, _chunk_providerMetadata;
|
|
13128
13130
|
if (!currentMessage) break;
|
|
13131
|
+
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13132
|
+
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13129
13133
|
var toolIndex3 = currentMessage.parts.findIndex(function(p) {
|
|
13130
13134
|
return 'toolCallId' in p && p.toolCallId === chunk.toolCallId;
|
|
13131
13135
|
});
|
|
13136
|
+
var existingPart3 = toolIndex3 >= 0 ? currentMessage.parts[toolIndex3] : null;
|
|
13137
|
+
var _ref5 = existingPart3 !== null && existingPart3 !== void 0 ? existingPart3 : {}, _ignoredOutput = _ref5.output, _ignoredRawOutput = _ref5.rawOutput, _ignoredPreliminary = _ref5.preliminary, carryOver = _object_without_properties(_ref5, [
|
|
13138
|
+
"output",
|
|
13139
|
+
"rawOutput",
|
|
13140
|
+
"preliminary"
|
|
13141
|
+
]);
|
|
13142
|
+
var nextToolPart2 = _object_spread_props(_object_spread({}, carryOver), {
|
|
13143
|
+
type: "tool-".concat(chunk.toolName),
|
|
13144
|
+
toolCallId: chunk.toolCallId,
|
|
13145
|
+
state: 'output-error',
|
|
13146
|
+
input: undefined,
|
|
13147
|
+
rawInput: (_chunk_input = chunk.input) !== null && _chunk_input !== void 0 ? _chunk_input : carryOver.rawInput,
|
|
13148
|
+
errorText: chunk.errorText,
|
|
13149
|
+
providerExecuted: (_chunk_providerExecuted = chunk.providerExecuted) !== null && _chunk_providerExecuted !== void 0 ? _chunk_providerExecuted : carryOver.providerExecuted,
|
|
13150
|
+
callProviderMetadata: (_chunk_providerMetadata = chunk.providerMetadata) !== null && _chunk_providerMetadata !== void 0 ? _chunk_providerMetadata : carryOver.callProviderMetadata
|
|
13151
|
+
});
|
|
13132
13152
|
if (toolIndex3 >= 0) {
|
|
13133
|
-
var _chunk_input;
|
|
13134
|
-
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13135
|
-
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13136
13153
|
var updatedParts8 = _to_consumable_array(currentMessage.parts);
|
|
13137
|
-
|
|
13138
|
-
var _ignoredRawOutput = existingPart3.rawOutput, _ignoredPreliminary = existingPart3.preliminary, rest1 = _object_without_properties(existingPart3, [
|
|
13139
|
-
"rawOutput",
|
|
13140
|
-
"preliminary"
|
|
13141
|
-
]);
|
|
13142
|
-
updatedParts8[toolIndex3] = _object_spread_props(_object_spread({}, rest1), {
|
|
13143
|
-
state: 'output-error',
|
|
13144
|
-
errorText: chunk.errorText,
|
|
13145
|
-
input: (_chunk_input = chunk.input) !== null && _chunk_input !== void 0 ? _chunk_input : existingPart3.input,
|
|
13146
|
-
callProviderMetadata: chunk.callProviderMetadata
|
|
13147
|
-
});
|
|
13154
|
+
updatedParts8[toolIndex3] = nextToolPart2;
|
|
13148
13155
|
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13149
13156
|
parts: updatedParts8
|
|
13150
13157
|
});
|
|
13151
|
-
|
|
13158
|
+
} else {
|
|
13159
|
+
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13160
|
+
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13161
|
+
nextToolPart2
|
|
13162
|
+
])
|
|
13163
|
+
});
|
|
13152
13164
|
}
|
|
13165
|
+
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13166
|
+
break;
|
|
13167
|
+
}
|
|
13168
|
+
case 'tool-output-error':
|
|
13169
|
+
{
|
|
13170
|
+
var _chunk_providerExecuted1, _chunk_providerMetadata1;
|
|
13171
|
+
if (!currentMessage) break;
|
|
13172
|
+
var toolIndex4 = currentMessage.parts.findIndex(function(p) {
|
|
13173
|
+
return 'toolCallId' in p && p.toolCallId === chunk.toolCallId;
|
|
13174
|
+
});
|
|
13175
|
+
if (toolIndex4 < 0) break;
|
|
13176
|
+
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13177
|
+
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13178
|
+
var updatedParts9 = _to_consumable_array(currentMessage.parts);
|
|
13179
|
+
var existingPart4 = updatedParts9[toolIndex4];
|
|
13180
|
+
var _ignoredRawOutput1 = existingPart4.rawOutput, _ignoredPreliminary1 = existingPart4.preliminary, _ignoredOutput1 = existingPart4.output, rest1 = _object_without_properties(existingPart4, [
|
|
13181
|
+
"rawOutput",
|
|
13182
|
+
"preliminary",
|
|
13183
|
+
"output"
|
|
13184
|
+
]);
|
|
13185
|
+
updatedParts9[toolIndex4] = _object_spread_props(_object_spread({}, rest1), {
|
|
13186
|
+
state: 'output-error',
|
|
13187
|
+
errorText: chunk.errorText,
|
|
13188
|
+
providerExecuted: (_chunk_providerExecuted1 = chunk.providerExecuted) !== null && _chunk_providerExecuted1 !== void 0 ? _chunk_providerExecuted1 : rest1.providerExecuted,
|
|
13189
|
+
callProviderMetadata: (_chunk_providerMetadata1 = chunk.providerMetadata) !== null && _chunk_providerMetadata1 !== void 0 ? _chunk_providerMetadata1 : rest1.callProviderMetadata
|
|
13190
|
+
});
|
|
13191
|
+
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13192
|
+
parts: updatedParts9
|
|
13193
|
+
});
|
|
13194
|
+
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13153
13195
|
break;
|
|
13154
13196
|
}
|
|
13155
13197
|
case 'source-url':
|
|
@@ -13843,12 +13885,10 @@
|
|
|
13843
13885
|
var _chatInstance;
|
|
13844
13886
|
var input = '';
|
|
13845
13887
|
var open = false;
|
|
13846
|
-
var isClearing = false;
|
|
13847
13888
|
var sendEvent;
|
|
13848
13889
|
var setInput;
|
|
13849
13890
|
var setOpen;
|
|
13850
13891
|
var focusInput;
|
|
13851
|
-
var setIsClearing;
|
|
13852
13892
|
var setFeedbackState;
|
|
13853
13893
|
var hasValidatedEntryPoints = false;
|
|
13854
13894
|
var agentId = 'agentId' in options ? options.agentId : undefined;
|
|
@@ -13878,21 +13918,17 @@
|
|
|
13878
13918
|
_chatInstance.messages = messagesParam;
|
|
13879
13919
|
};
|
|
13880
13920
|
var clearMessages = function clearMessages() {
|
|
13881
|
-
if (!_chatInstance.messages || _chatInstance.messages.length === 0) {
|
|
13882
|
-
return;
|
|
13883
|
-
}
|
|
13884
13921
|
var status = _chatInstance.status;
|
|
13885
13922
|
if (status === 'submitted' || status === 'streaming') {
|
|
13886
13923
|
_chatInstance.stop();
|
|
13887
13924
|
}
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
13925
|
+
// Reset the non-reactive state first: `setMessages` and `clearError` emit
|
|
13926
|
+
// ChatState callbacks that synchronously re-render, so they must run last
|
|
13927
|
+
// for that render to see the cleared feedback and rotated conversation id.
|
|
13928
|
+
feedbackState = {};
|
|
13929
|
+
_chatInstance.resetConversationId();
|
|
13891
13930
|
setMessages([]);
|
|
13892
13931
|
_chatInstance.clearError();
|
|
13893
|
-
_chatInstance.resetConversationId();
|
|
13894
|
-
feedbackState = {};
|
|
13895
|
-
setIsClearing(false);
|
|
13896
13932
|
};
|
|
13897
13933
|
var validateEntryPoints = function validateEntryPoints(instantSearchInstance) {
|
|
13898
13934
|
if (disableTriggerValidation || hasValidatedEntryPoints) {
|
|
@@ -13958,22 +13994,37 @@
|
|
|
13958
13994
|
}));
|
|
13959
13995
|
}
|
|
13960
13996
|
if ('agentId' in options && options.agentId) {
|
|
13997
|
+
var _options_requestOptions, _options_requestOptions1;
|
|
13961
13998
|
if (!appId || !apiKey) {
|
|
13962
13999
|
throw new Error(withUsage$o('Could not extract Algolia credentials from the search client.'));
|
|
13963
14000
|
}
|
|
13964
|
-
var
|
|
14001
|
+
var createApi = function createApi() {
|
|
14002
|
+
var bypassCache = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : false;
|
|
14003
|
+
var _options_requestOptions;
|
|
14004
|
+
var api = new URL("https://".concat(appId, ".algolia.net/agent-studio/1/agents/").concat(agentId, "/completions"));
|
|
14005
|
+
var queryParameters = _object_spread(_object_spread_props(_object_spread({}, (_options_requestOptions = options.requestOptions) === null || _options_requestOptions === void 0 ? void 0 : _options_requestOptions.queryParameters), {
|
|
14006
|
+
compatibilityMode: 'ai-sdk-5'
|
|
14007
|
+
}), bypassCache ? {
|
|
14008
|
+
cache: false
|
|
14009
|
+
} : {});
|
|
14010
|
+
api.search = new URLSearchParams(queryParameters).toString();
|
|
14011
|
+
return api.toString();
|
|
14012
|
+
};
|
|
14013
|
+
var baseApi = createApi();
|
|
13965
14014
|
transport = new DefaultChatTransport({
|
|
13966
14015
|
api: baseApi,
|
|
13967
|
-
headers: {
|
|
14016
|
+
headers: _object_spread_props(_object_spread({}, _instanceof((_options_requestOptions = options.requestOptions) === null || _options_requestOptions === void 0 ? void 0 : _options_requestOptions.headers, Headers) ? Object.fromEntries(options.requestOptions.headers.entries()) : (_options_requestOptions1 = options.requestOptions) === null || _options_requestOptions1 === void 0 ? void 0 : _options_requestOptions1.headers), {
|
|
14017
|
+
// Preserve the required Algolia identity headers and chat agent
|
|
14018
|
+
// marker, even when requestOptions.headers contains the same keys.
|
|
13968
14019
|
'x-algolia-application-id': appId,
|
|
13969
14020
|
'x-algolia-api-key': apiKey,
|
|
13970
14021
|
'x-algolia-agent': "".concat(getAlgoliaAgent(client), "; chat")
|
|
13971
|
-
},
|
|
14022
|
+
}),
|
|
13972
14023
|
prepareSendMessagesRequest: function prepareSendMessagesRequest(param) {
|
|
13973
14024
|
var id = param.id, messages = param.messages, trigger = param.trigger, messageId = param.messageId;
|
|
13974
14025
|
return {
|
|
13975
14026
|
// Bypass cache when regenerating to ensure fresh responses
|
|
13976
|
-
api: trigger === 'regenerate-message' ?
|
|
14027
|
+
api: trigger === 'regenerate-message' ? createApi(true) : baseApi,
|
|
13977
14028
|
body: {
|
|
13978
14029
|
id: id,
|
|
13979
14030
|
messageId: messageId,
|
|
@@ -14058,10 +14109,6 @@
|
|
|
14058
14109
|
input = i;
|
|
14059
14110
|
render();
|
|
14060
14111
|
};
|
|
14061
|
-
setIsClearing = function setIsClearing(value) {
|
|
14062
|
-
isClearing = value;
|
|
14063
|
-
render();
|
|
14064
|
-
};
|
|
14065
14112
|
setFeedbackState = function setFeedbackState(messageId, state) {
|
|
14066
14113
|
feedbackState = _object_spread_props(_object_spread({}, feedbackState), _define_property({}, messageId, state));
|
|
14067
14114
|
render();
|
|
@@ -14180,9 +14227,7 @@
|
|
|
14180
14227
|
focusInput: focusInput,
|
|
14181
14228
|
setMessages: setMessages,
|
|
14182
14229
|
suggestions: getSuggestionsFromMessages(_chatInstance.messages),
|
|
14183
|
-
isClearing: isClearing,
|
|
14184
14230
|
clearMessages: clearMessages,
|
|
14185
|
-
onClearTransitionEnd: onClearTransitionEnd,
|
|
14186
14231
|
tools: toolsWithAddToolResult,
|
|
14187
14232
|
sendChatMessageFeedback: _sendChatMessageFeedback,
|
|
14188
14233
|
feedbackState: feedbackState,
|
|
@@ -19194,8 +19239,9 @@
|
|
|
19194
19239
|
function createAutocompletePropGetters(param) {
|
|
19195
19240
|
var useEffect = param.useEffect, useId = param.useId, useMemo = param.useMemo, useRef = param.useRef, useState = param.useState;
|
|
19196
19241
|
return function usePropGetters(param) {
|
|
19197
|
-
var indices = param.indices, indicesConfig = param.indicesConfig, onRefine = param.onRefine, globalOnSelect = param.onSelect, onApply = param.onApply, onSubmit = param.onSubmit, placeholder = param.placeholder, _param_isDetached = param.isDetached, isDetached = _param_isDetached === void 0 ? false : _param_isDetached, _param_shouldHidePanel = param.shouldHidePanel, shouldHidePanel = _param_shouldHidePanel === void 0 ? false : _param_shouldHidePanel, _param_autoFocus = param.autoFocus, autoFocus = _param_autoFocus === void 0 ? false : _param_autoFocus;
|
|
19198
|
-
var
|
|
19242
|
+
var indices = param.indices, indicesConfig = param.indicesConfig, onRefine = param.onRefine, globalOnSelect = param.onSelect, onApply = param.onApply, onSubmit = param.onSubmit, placeholder = param.placeholder, _param_isDetached = param.isDetached, isDetached = _param_isDetached === void 0 ? false : _param_isDetached, _param_shouldHidePanel = param.shouldHidePanel, shouldHidePanel = _param_shouldHidePanel === void 0 ? false : _param_shouldHidePanel, _param_autoFocus = param.autoFocus, autoFocus = _param_autoFocus === void 0 ? false : _param_autoFocus, id = param.id;
|
|
19243
|
+
var internalId = useId();
|
|
19244
|
+
var getElementId = createGetElementId(id !== null && id !== void 0 ? id : internalId);
|
|
19199
19245
|
var inputRef = useRef(null);
|
|
19200
19246
|
var rootRef = useRef(null);
|
|
19201
19247
|
var _useState = _sliced_to_array(useState(autoFocus), 2), isOpen = _useState[0], setIsOpen = _useState[1];
|
|
@@ -20406,9 +20452,8 @@
|
|
|
20406
20452
|
Fragment: Fragment
|
|
20407
20453
|
});
|
|
20408
20454
|
// Skip re-rendering (and re-compiling the markdown of) completed messages on
|
|
20409
|
-
// every streaming delta.
|
|
20410
|
-
|
|
20411
|
-
var MemoizedDefaultMessage = memo ? memo(DefaultMessageComponent, areMessagePropsEqual) : DefaultMessageComponent;
|
|
20455
|
+
// every streaming delta.
|
|
20456
|
+
var MemoizedDefaultMessage = memo(DefaultMessageComponent, areMessagePropsEqual);
|
|
20412
20457
|
var DefaultLoaderComponent = createChatMessageLoaderComponent({
|
|
20413
20458
|
createElement: createElement
|
|
20414
20459
|
});
|
|
@@ -20785,8 +20830,11 @@
|
|
|
20785
20830
|
};
|
|
20786
20831
|
}
|
|
20787
20832
|
|
|
20833
|
+
function prefersReducedMotion() {
|
|
20834
|
+
return typeof window !== 'undefined' && typeof window.matchMedia === 'function' && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
20835
|
+
}
|
|
20788
20836
|
function createChatComponent(param) {
|
|
20789
|
-
var createElement = param.createElement, Fragment = param.Fragment, memo = param.memo;
|
|
20837
|
+
var createElement = param.createElement, Fragment = param.Fragment, memo = param.memo, useState = param.useState;
|
|
20790
20838
|
var ChatHeader = createChatHeaderComponent({
|
|
20791
20839
|
createElement: createElement,
|
|
20792
20840
|
Fragment: Fragment
|
|
@@ -20827,11 +20875,38 @@
|
|
|
20827
20875
|
"stop",
|
|
20828
20876
|
"error"
|
|
20829
20877
|
]);
|
|
20878
|
+
var _useState = _sliced_to_array(useState(false), 2), isClearing = _useState[0], setIsClearing = _useState[1];
|
|
20879
|
+
var commitClear = headerProps.onClear || messagesProps.onNewConversation;
|
|
20880
|
+
var startClear = function startClear() {
|
|
20881
|
+
if (!commitClear) {
|
|
20882
|
+
return;
|
|
20883
|
+
}
|
|
20884
|
+
// Reduced motion disables the transition, so `transitionend` never fires;
|
|
20885
|
+
// commit immediately instead of waiting for it.
|
|
20886
|
+
if (prefersReducedMotion()) {
|
|
20887
|
+
commitClear();
|
|
20888
|
+
return;
|
|
20889
|
+
}
|
|
20890
|
+
// Stop streaming now so the assistant stops immediately, not after the fade.
|
|
20891
|
+
if (messagesProps.status === 'submitted' || messagesProps.status === 'streaming') {
|
|
20892
|
+
stop();
|
|
20893
|
+
}
|
|
20894
|
+
setIsClearing(true);
|
|
20895
|
+
};
|
|
20896
|
+
var finishClear = function finishClear() {
|
|
20897
|
+
commitClear === null || commitClear === void 0 ? void 0 : commitClear();
|
|
20898
|
+
setIsClearing(false);
|
|
20899
|
+
};
|
|
20830
20900
|
var headerComponent = createElement(HeaderComponent || ChatHeader, _object_spread_props(_object_spread({}, headerProps), {
|
|
20901
|
+
onClear: commitClear ? startClear : headerProps.onClear,
|
|
20902
|
+
canClear: headerProps.canClear && !isClearing,
|
|
20831
20903
|
classNames: classNames.header,
|
|
20832
20904
|
maximized: maximized
|
|
20833
20905
|
}));
|
|
20834
20906
|
var messagesComponent = /*#__PURE__*/ createElement(ChatMessages, _object_spread_props(_object_spread({}, messagesProps), {
|
|
20907
|
+
isClearing: isClearing,
|
|
20908
|
+
onClearTransitionEnd: finishClear,
|
|
20909
|
+
onNewConversation: commitClear ? startClear : messagesProps.onNewConversation,
|
|
20835
20910
|
error: error,
|
|
20836
20911
|
classNames: classNames.messages,
|
|
20837
20912
|
messageClassNames: classNames.message,
|
|
@@ -20856,9 +20931,9 @@
|
|
|
20856
20931
|
messages: messagesProps.messages,
|
|
20857
20932
|
status: messagesProps.status,
|
|
20858
20933
|
tools: messagesProps.tools,
|
|
20859
|
-
isClearing:
|
|
20860
|
-
clearMessages: headerProps.onClear,
|
|
20861
|
-
onClearTransitionEnd:
|
|
20934
|
+
isClearing: isClearing,
|
|
20935
|
+
clearMessages: commitClear ? startClear : headerProps.onClear,
|
|
20936
|
+
onClearTransitionEnd: finishClear,
|
|
20862
20937
|
suggestions: suggestionsProps.suggestions,
|
|
20863
20938
|
sendMessage: sendMessage,
|
|
20864
20939
|
regenerate: regenerate,
|
|
@@ -22270,11 +22345,14 @@
|
|
|
22270
22345
|
Fragment: React.Fragment
|
|
22271
22346
|
});
|
|
22272
22347
|
var id = 0;
|
|
22273
|
-
|
|
22274
|
-
|
|
22348
|
+
// Colons (`:r0:`) preserved so concatenations like `autocomplete:r0:input`
|
|
22349
|
+
// have a recognisable boundary; callers that need a colon-free variant for
|
|
22350
|
+
// InstantSearch's `indexId` strip them at the use site.
|
|
22351
|
+
var useAutocompleteId = React.useId ? function() {
|
|
22352
|
+
return React.useId();
|
|
22275
22353
|
} : function() {
|
|
22276
22354
|
return React.useState(function() {
|
|
22277
|
-
return "a".concat(id
|
|
22355
|
+
return ":a".concat(id++, ":");
|
|
22278
22356
|
})[0];
|
|
22279
22357
|
};
|
|
22280
22358
|
var usePropGetters = createAutocompletePropGetters({
|
|
@@ -22426,6 +22504,10 @@
|
|
|
22426
22504
|
"translations",
|
|
22427
22505
|
"transformItems"
|
|
22428
22506
|
]);
|
|
22507
|
+
var autoFocus = restProps.autoFocus, placeholder = restProps.placeholder, classNames = restProps.classNames;
|
|
22508
|
+
// Eager-mount only when `autoFocus` is set — otherwise wait for first focus
|
|
22509
|
+
// before registering the autocomplete subtree in the search graph.
|
|
22510
|
+
var _useState = _sliced_to_array(React.useState(autoFocus === true), 2), activated = _useState[0], setActivated = _useState[1];
|
|
22429
22511
|
var translations = _object_spread({}, DEFAULT_TRANSLATIONS, userTranslations);
|
|
22430
22512
|
var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, indexRenderState = _useInstantSearch.indexRenderState, status = _useInstantSearch.status;
|
|
22431
22513
|
var compositionID = useInstantSearchContext().compositionID;
|
|
@@ -22435,9 +22517,8 @@
|
|
|
22435
22517
|
}, props.aiMode ? {
|
|
22436
22518
|
opensChat: true
|
|
22437
22519
|
} : {})).refine;
|
|
22438
|
-
|
|
22439
|
-
|
|
22440
|
-
var instanceKey = useAutocompleteInstanceId();
|
|
22520
|
+
var domId = useAutocompleteId();
|
|
22521
|
+
var instanceKey = domId.replace(/:/g, '');
|
|
22441
22522
|
if (isFeedsMode && indices !== undefined) {
|
|
22442
22523
|
throw new Error('EXPERIMENTAL_Autocomplete: `feeds` and `indices` are mutually exclusive.');
|
|
22443
22524
|
}
|
|
@@ -22607,7 +22688,84 @@
|
|
|
22607
22688
|
"indices",
|
|
22608
22689
|
"feeds"
|
|
22609
22690
|
]);
|
|
22691
|
+
var instance = useInstantSearchContext();
|
|
22692
|
+
var detached = useDetachedMode(detachedMediaQuery);
|
|
22693
|
+
var isDetached = detached.isDetached, setIsModalOpen = detached.setIsModalOpen;
|
|
22694
|
+
// Lazy activation only: when `activated` flips from false to true, the
|
|
22695
|
+
// newly-mounted isolated `<Index>` schedules the parent's search even
|
|
22696
|
+
// though the parent's state hasn't changed. Cancel it so only the
|
|
22697
|
+
// autocomplete's own search fires on activation. Skip when `autoFocus`
|
|
22698
|
+
// mounts the inner eagerly — the parent's legitimate initial search
|
|
22699
|
+
// shares the same defer slot and must not be cancelled.
|
|
22700
|
+
var initialActivatedRef = React.useRef(activated);
|
|
22701
|
+
React.useLayoutEffect(function() {
|
|
22702
|
+
if (activated && !initialActivatedRef.current) {
|
|
22703
|
+
initialActivatedRef.current = true;
|
|
22704
|
+
instance.scheduleSearch.cancel();
|
|
22705
|
+
}
|
|
22706
|
+
}, [
|
|
22707
|
+
activated,
|
|
22708
|
+
instance
|
|
22709
|
+
]);
|
|
22710
|
+
if (!activated) {
|
|
22711
|
+
var _indexUiState_query, _indexUiState_query1;
|
|
22712
|
+
restProps.indices; restProps.feeds; restProps.autoFocus; restProps.placeholder; restProps.classNames; restProps.aiMode; restProps.panelComponent; restProps.getSearchPageURL; restProps.onSelect; var shellRootProps = _object_without_properties(restProps, [
|
|
22713
|
+
"indices",
|
|
22714
|
+
"feeds",
|
|
22715
|
+
"autoFocus",
|
|
22716
|
+
"placeholder",
|
|
22717
|
+
"classNames",
|
|
22718
|
+
"aiMode",
|
|
22719
|
+
"panelComponent",
|
|
22720
|
+
"getSearchPageURL",
|
|
22721
|
+
"onSelect"
|
|
22722
|
+
]);
|
|
22723
|
+
var activateWithQueryMirror = function activateWithQueryMirror() {
|
|
22724
|
+
// Routing only fills the parent index's UI state, not the
|
|
22725
|
+
// autocomplete's isolated one, so without this, the autocomplete
|
|
22726
|
+
// would activate with an empty query and fire a useless search.
|
|
22727
|
+
// We copy the parent's query into the autocomplete's slot of
|
|
22728
|
+
// `_initialUiState` right before flipping `activated`: that's the
|
|
22729
|
+
// moment the isolated `<Index>` is about to mount and read it.
|
|
22730
|
+
// Doing this later would mean firing a second search to correct
|
|
22731
|
+
// the first.
|
|
22732
|
+
if (indexUiState.query) {
|
|
22733
|
+
var isoIndexId = "ais-autocomplete-".concat(instanceKey);
|
|
22734
|
+
var initial = instance._initialUiState;
|
|
22735
|
+
initial[isoIndexId] = _object_spread_props(_object_spread({}, initial[isoIndexId]), {
|
|
22736
|
+
query: indexUiState.query
|
|
22737
|
+
});
|
|
22738
|
+
}
|
|
22739
|
+
setActivated(true);
|
|
22740
|
+
};
|
|
22741
|
+
return /*#__PURE__*/ React.createElement(Autocomplete, _object_spread_props(_object_spread({}, shellRootProps), {
|
|
22742
|
+
classNames: classNames
|
|
22743
|
+
}), isDetached ? /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
22744
|
+
query: (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '',
|
|
22745
|
+
placeholder: placeholder,
|
|
22746
|
+
classNames: classNames,
|
|
22747
|
+
translations: translations,
|
|
22748
|
+
onClick: function onClick() {
|
|
22749
|
+
setIsModalOpen(true);
|
|
22750
|
+
activateWithQueryMirror();
|
|
22751
|
+
}
|
|
22752
|
+
}) : /*#__PURE__*/ React.createElement(AutocompleteSearch, {
|
|
22753
|
+
inputProps: {
|
|
22754
|
+
id: "autocomplete".concat(domId, "input"),
|
|
22755
|
+
role: 'combobox',
|
|
22756
|
+
placeholder: placeholder,
|
|
22757
|
+
onFocus: activateWithQueryMirror
|
|
22758
|
+
},
|
|
22759
|
+
clearQuery: function clearQuery() {},
|
|
22760
|
+
query: (_indexUiState_query1 = indexUiState.query) !== null && _indexUiState_query1 !== void 0 ? _indexUiState_query1 : '',
|
|
22761
|
+
isSearchStalled: false,
|
|
22762
|
+
classNames: classNames
|
|
22763
|
+
}));
|
|
22764
|
+
}
|
|
22610
22765
|
var innerAutocomplete = /*#__PURE__*/ React.createElement(InnerAutocomplete, _object_spread_props(_object_spread({}, forwardedProps), {
|
|
22766
|
+
autoFocus: true,
|
|
22767
|
+
domId: domId,
|
|
22768
|
+
detached: detached,
|
|
22611
22769
|
indicesConfig: indicesConfig,
|
|
22612
22770
|
refineSearchBox: refine,
|
|
22613
22771
|
isSearchStalled: isSearchStalled,
|
|
@@ -22616,7 +22774,6 @@
|
|
|
22616
22774
|
showRecent: showRecent,
|
|
22617
22775
|
recentSearchConfig: recentSearchConfig,
|
|
22618
22776
|
showQuerySuggestions: normalizedShowQuerySuggestions,
|
|
22619
|
-
detachedMediaQuery: detachedMediaQuery,
|
|
22620
22777
|
translations: translations,
|
|
22621
22778
|
showPromptSuggestions: normalizedShowPromptSuggestions,
|
|
22622
22779
|
transformItems: effectiveTransformItems,
|
|
@@ -22635,16 +22792,18 @@
|
|
|
22635
22792
|
}), innerAutocomplete);
|
|
22636
22793
|
}
|
|
22637
22794
|
return /*#__PURE__*/ React.createElement(Index, {
|
|
22638
|
-
EXPERIMENTAL_isolated: true
|
|
22795
|
+
EXPERIMENTAL_isolated: true,
|
|
22796
|
+
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
22639
22797
|
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), indicesConfig.map(function(index) {
|
|
22640
22798
|
return /*#__PURE__*/ React.createElement(Index, {
|
|
22641
22799
|
key: index.indexName,
|
|
22642
|
-
indexName: index.indexName
|
|
22800
|
+
indexName: index.indexName,
|
|
22801
|
+
indexId: "ais-autocomplete-".concat(instanceKey, "-").concat(index.indexName)
|
|
22643
22802
|
}, /*#__PURE__*/ React.createElement(Configure, index.searchParameters));
|
|
22644
22803
|
}), innerAutocomplete);
|
|
22645
22804
|
}
|
|
22646
22805
|
function InnerAutocomplete(_0) {
|
|
22647
|
-
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,
|
|
22806
|
+
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, translations = _0.translations, classNames = _0.classNames, aiMode = _0.aiMode, domId = _0.domId, detached = _0.detached, props = _object_without_properties(_0, [
|
|
22648
22807
|
"indicesConfig",
|
|
22649
22808
|
"refineSearchBox",
|
|
22650
22809
|
"isSearchStalled",
|
|
@@ -22661,10 +22820,11 @@
|
|
|
22661
22820
|
"transformItems",
|
|
22662
22821
|
"placeholder",
|
|
22663
22822
|
"autoFocus",
|
|
22664
|
-
"detachedMediaQuery",
|
|
22665
22823
|
"translations",
|
|
22666
22824
|
"classNames",
|
|
22667
|
-
"aiMode"
|
|
22825
|
+
"aiMode",
|
|
22826
|
+
"domId",
|
|
22827
|
+
"detached"
|
|
22668
22828
|
]);
|
|
22669
22829
|
var _indexUiState_query, _ref;
|
|
22670
22830
|
var _showPromptSuggestions_searchParameters;
|
|
@@ -22675,7 +22835,7 @@
|
|
|
22675
22835
|
}
|
|
22676
22836
|
}), indices = _useAutocomplete.indices, refineAutocomplete = _useAutocomplete.refine, currentRefinement = _useAutocomplete.currentRefinement;
|
|
22677
22837
|
var resolvedQuery = currentRefinement !== undefined ? currentRefinement : (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '';
|
|
22678
|
-
var
|
|
22838
|
+
var isDetached = detached.isDetached, isModalDetached = detached.isModalDetached, isModalOpen = detached.isModalOpen, setIsModalOpen = detached.setIsModalOpen;
|
|
22679
22839
|
var previousIsDetachedRef = React.useRef(isDetached);
|
|
22680
22840
|
var _useStorage = useStorage({
|
|
22681
22841
|
showRecent: showRecent,
|
|
@@ -22741,6 +22901,7 @@
|
|
|
22741
22901
|
});
|
|
22742
22902
|
var shouldHideEmptyPanel = allIndicesEmpty && recentEmpty && !hasNoResultsTemplate && !PanelComponent;
|
|
22743
22903
|
var _usePropGetters = usePropGetters({
|
|
22904
|
+
id: domId,
|
|
22744
22905
|
indices: indicesForPropGettersWithPromptSuggestions,
|
|
22745
22906
|
indicesConfig: indicesConfigForPropGetters,
|
|
22746
22907
|
onRefine: function onRefine(query) {
|
|
@@ -22865,7 +23026,7 @@
|
|
|
22865
23026
|
NoResultsComponent: currentIndexConfig.noResultsComponent,
|
|
22866
23027
|
items: hits.map(function(item) {
|
|
22867
23028
|
return _object_spread_props(_object_spread({}, item), {
|
|
22868
|
-
__indexName:
|
|
23029
|
+
__indexName: indexName
|
|
22869
23030
|
});
|
|
22870
23031
|
}),
|
|
22871
23032
|
getItemProps: getItemProps,
|
|
@@ -23267,7 +23428,8 @@
|
|
|
23267
23428
|
var ChatUiComponent = createChatComponent({
|
|
23268
23429
|
createElement: React.createElement,
|
|
23269
23430
|
Fragment: React.Fragment,
|
|
23270
|
-
memo: React.memo
|
|
23431
|
+
memo: React.memo,
|
|
23432
|
+
useState: React.useState
|
|
23271
23433
|
});
|
|
23272
23434
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
23273
23435
|
var _obj;
|
|
@@ -23332,7 +23494,7 @@
|
|
|
23332
23494
|
tools: tools,
|
|
23333
23495
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
23334
23496
|
}));
|
|
23335
|
-
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,
|
|
23497
|
+
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;
|
|
23336
23498
|
React.useImperativeHandle(ref, function() {
|
|
23337
23499
|
return {
|
|
23338
23500
|
setOpen: setOpen,
|
|
@@ -23396,7 +23558,7 @@
|
|
|
23396
23558
|
return setMaximized(!maximized);
|
|
23397
23559
|
},
|
|
23398
23560
|
onClear: clearMessages,
|
|
23399
|
-
canClear: Boolean(messages === null || messages === void 0 ? void 0 : messages.length)
|
|
23561
|
+
canClear: Boolean(messages === null || messages === void 0 ? void 0 : messages.length),
|
|
23400
23562
|
titleIconComponent: headerTitleIconComponent,
|
|
23401
23563
|
closeIconComponent: headerCloseIconComponent,
|
|
23402
23564
|
minimizeIconComponent: headerMinimizeIconComponent,
|
|
@@ -23422,8 +23584,6 @@
|
|
|
23422
23584
|
tools: toolsFromConnector,
|
|
23423
23585
|
indexUiState: indexUiState,
|
|
23424
23586
|
setIndexUiState: setIndexUiState,
|
|
23425
|
-
isClearing: isClearing,
|
|
23426
|
-
onClearTransitionEnd: onClearTransitionEnd,
|
|
23427
23587
|
isScrollAtBottom: isAtBottom,
|
|
23428
23588
|
scrollRef: scrollRef,
|
|
23429
23589
|
contentRef: contentRef,
|