react-instantsearch 7.35.1 → 7.37.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/Autocomplete.js +284 -83
- package/dist/cjs/widgets/Chat.js +19 -1
- package/dist/es/widgets/Autocomplete.d.ts +78 -27
- package/dist/es/widgets/Autocomplete.js +311 -110
- package/dist/es/widgets/Chat.js +20 -2
- package/dist/umd/ReactInstantSearch.js +404 -111
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearch 7.
|
|
1
|
+
/*! React InstantSearch 7.37.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.37.0';
|
|
28
28
|
|
|
29
29
|
function _define_property(obj, key, value) {
|
|
30
30
|
if (key in obj) {
|
|
@@ -10821,7 +10821,7 @@
|
|
|
10821
10821
|
};
|
|
10822
10822
|
}
|
|
10823
10823
|
|
|
10824
|
-
var version = '4.
|
|
10824
|
+
var version = '4.103.0';
|
|
10825
10825
|
|
|
10826
10826
|
var withUsage$r = createDocumentationMessageGenerator({
|
|
10827
10827
|
name: 'instantsearch'
|
|
@@ -13123,33 +13123,74 @@
|
|
|
13123
13123
|
}
|
|
13124
13124
|
break;
|
|
13125
13125
|
}
|
|
13126
|
-
case 'tool-error':
|
|
13126
|
+
case 'tool-input-error':
|
|
13127
13127
|
{
|
|
13128
|
+
var _chunk_input, _chunk_providerExecuted, _chunk_providerMetadata;
|
|
13128
13129
|
if (!currentMessage) break;
|
|
13130
|
+
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13131
|
+
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13129
13132
|
var toolIndex3 = currentMessage.parts.findIndex(function(p) {
|
|
13130
13133
|
return 'toolCallId' in p && p.toolCallId === chunk.toolCallId;
|
|
13131
13134
|
});
|
|
13135
|
+
var existingPart3 = toolIndex3 >= 0 ? currentMessage.parts[toolIndex3] : null;
|
|
13136
|
+
var _ref5 = existingPart3 !== null && existingPart3 !== void 0 ? existingPart3 : {}, _ignoredOutput = _ref5.output, _ignoredRawOutput = _ref5.rawOutput, _ignoredPreliminary = _ref5.preliminary, carryOver = _object_without_properties(_ref5, [
|
|
13137
|
+
"output",
|
|
13138
|
+
"rawOutput",
|
|
13139
|
+
"preliminary"
|
|
13140
|
+
]);
|
|
13141
|
+
var nextToolPart2 = _object_spread_props(_object_spread({}, carryOver), {
|
|
13142
|
+
type: "tool-".concat(chunk.toolName),
|
|
13143
|
+
toolCallId: chunk.toolCallId,
|
|
13144
|
+
state: 'output-error',
|
|
13145
|
+
input: undefined,
|
|
13146
|
+
rawInput: (_chunk_input = chunk.input) !== null && _chunk_input !== void 0 ? _chunk_input : carryOver.rawInput,
|
|
13147
|
+
errorText: chunk.errorText,
|
|
13148
|
+
providerExecuted: (_chunk_providerExecuted = chunk.providerExecuted) !== null && _chunk_providerExecuted !== void 0 ? _chunk_providerExecuted : carryOver.providerExecuted,
|
|
13149
|
+
callProviderMetadata: (_chunk_providerMetadata = chunk.providerMetadata) !== null && _chunk_providerMetadata !== void 0 ? _chunk_providerMetadata : carryOver.callProviderMetadata
|
|
13150
|
+
});
|
|
13132
13151
|
if (toolIndex3 >= 0) {
|
|
13133
|
-
var _chunk_input;
|
|
13134
|
-
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13135
|
-
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13136
13152
|
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
|
-
});
|
|
13153
|
+
updatedParts8[toolIndex3] = nextToolPart2;
|
|
13148
13154
|
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13149
13155
|
parts: updatedParts8
|
|
13150
13156
|
});
|
|
13151
|
-
|
|
13157
|
+
} else {
|
|
13158
|
+
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13159
|
+
parts: _to_consumable_array(currentMessage.parts).concat([
|
|
13160
|
+
nextToolPart2
|
|
13161
|
+
])
|
|
13162
|
+
});
|
|
13152
13163
|
}
|
|
13164
|
+
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13165
|
+
break;
|
|
13166
|
+
}
|
|
13167
|
+
case 'tool-output-error':
|
|
13168
|
+
{
|
|
13169
|
+
var _chunk_providerExecuted1, _chunk_providerMetadata1;
|
|
13170
|
+
if (!currentMessage) break;
|
|
13171
|
+
var toolIndex4 = currentMessage.parts.findIndex(function(p) {
|
|
13172
|
+
return 'toolCallId' in p && p.toolCallId === chunk.toolCallId;
|
|
13173
|
+
});
|
|
13174
|
+
if (toolIndex4 < 0) break;
|
|
13175
|
+
delete toolRawInputByCallId[chunk.toolCallId];
|
|
13176
|
+
delete toolRawOutputByCallId[chunk.toolCallId];
|
|
13177
|
+
var updatedParts9 = _to_consumable_array(currentMessage.parts);
|
|
13178
|
+
var existingPart4 = updatedParts9[toolIndex4];
|
|
13179
|
+
var _ignoredRawOutput1 = existingPart4.rawOutput, _ignoredPreliminary1 = existingPart4.preliminary, _ignoredOutput1 = existingPart4.output, rest1 = _object_without_properties(existingPart4, [
|
|
13180
|
+
"rawOutput",
|
|
13181
|
+
"preliminary",
|
|
13182
|
+
"output"
|
|
13183
|
+
]);
|
|
13184
|
+
updatedParts9[toolIndex4] = _object_spread_props(_object_spread({}, rest1), {
|
|
13185
|
+
state: 'output-error',
|
|
13186
|
+
errorText: chunk.errorText,
|
|
13187
|
+
providerExecuted: (_chunk_providerExecuted1 = chunk.providerExecuted) !== null && _chunk_providerExecuted1 !== void 0 ? _chunk_providerExecuted1 : rest1.providerExecuted,
|
|
13188
|
+
callProviderMetadata: (_chunk_providerMetadata1 = chunk.providerMetadata) !== null && _chunk_providerMetadata1 !== void 0 ? _chunk_providerMetadata1 : rest1.callProviderMetadata
|
|
13189
|
+
});
|
|
13190
|
+
currentMessage = _object_spread_props(_object_spread({}, currentMessage), {
|
|
13191
|
+
parts: updatedParts9
|
|
13192
|
+
});
|
|
13193
|
+
_this.state.replaceMessage(currentMessageIndex, currentMessage);
|
|
13153
13194
|
break;
|
|
13154
13195
|
}
|
|
13155
13196
|
case 'source-url':
|
|
@@ -19194,8 +19235,9 @@
|
|
|
19194
19235
|
function createAutocompletePropGetters(param) {
|
|
19195
19236
|
var useEffect = param.useEffect, useId = param.useId, useMemo = param.useMemo, useRef = param.useRef, useState = param.useState;
|
|
19196
19237
|
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
|
|
19238
|
+
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;
|
|
19239
|
+
var internalId = useId();
|
|
19240
|
+
var getElementId = createGetElementId(id !== null && id !== void 0 ? id : internalId);
|
|
19199
19241
|
var inputRef = useRef(null);
|
|
19200
19242
|
var rootRef = useRef(null);
|
|
19201
19243
|
var _useState = _sliced_to_array(useState(autoFocus), 2), isOpen = _useState[0], setIsOpen = _useState[1];
|
|
@@ -20018,7 +20060,7 @@
|
|
|
20018
20060
|
createElement: createElement
|
|
20019
20061
|
});
|
|
20020
20062
|
return function ChatMessage(userProps) {
|
|
20021
|
-
var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, status = userProps.status, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, _userProps_tools = userProps.tools, tools = _userProps_tools === void 0 ? {} : _userProps_tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, messages = userProps.messages, onClose = userProps.onClose, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, props = _object_without_properties(userProps, [
|
|
20063
|
+
var _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, message = userProps.message, status = userProps.status, _userProps_side = userProps.side, side = _userProps_side === void 0 ? 'left' : _userProps_side, _userProps_variant = userProps.variant, variant = _userProps_variant === void 0 ? 'subtle' : _userProps_variant, _userProps_actions = userProps.actions, actions = _userProps_actions === void 0 ? [] : _userProps_actions, _userProps_autoHideActions = userProps.autoHideActions, autoHideActions = _userProps_autoHideActions === void 0 ? false : _userProps_autoHideActions, LeadingComponent = userProps.leadingComponent, ActionsComponent = userProps.actionsComponent, FooterComponent = userProps.footerComponent, _userProps_tools = userProps.tools, tools = _userProps_tools === void 0 ? {} : _userProps_tools, indexUiState = userProps.indexUiState, setIndexUiState = userProps.setIndexUiState, messages = userProps.messages, onClose = userProps.onClose, userTranslations = userProps.translations, suggestionsElement = userProps.suggestionsElement, _userProps_parseMarkdown = userProps.parseMarkdown, parseMarkdown = _userProps_parseMarkdown === void 0 ? true : _userProps_parseMarkdown, props = _object_without_properties(userProps, [
|
|
20022
20064
|
"classNames",
|
|
20023
20065
|
"message",
|
|
20024
20066
|
"status",
|
|
@@ -20035,7 +20077,8 @@
|
|
|
20035
20077
|
"messages",
|
|
20036
20078
|
"onClose",
|
|
20037
20079
|
"translations",
|
|
20038
|
-
"suggestionsElement"
|
|
20080
|
+
"suggestionsElement",
|
|
20081
|
+
"parseMarkdown"
|
|
20039
20082
|
]);
|
|
20040
20083
|
var translations = _object_spread({
|
|
20041
20084
|
messageLabel: 'Message',
|
|
@@ -20064,6 +20107,18 @@
|
|
|
20064
20107
|
if (part.text.startsWith('<context>') && part.text.endsWith('</context>')) {
|
|
20065
20108
|
return null;
|
|
20066
20109
|
}
|
|
20110
|
+
if (!parseMarkdown) {
|
|
20111
|
+
// Render the literal text. The `ais-ChatMessage-text` class applies
|
|
20112
|
+
// `white-space: pre-wrap` to preserve the newlines that markdown
|
|
20113
|
+
// would otherwise collapse, and streaming deltas append cleanly
|
|
20114
|
+
// because there's no parser state to get into a half-parsed entity.
|
|
20115
|
+
// Wrapped in a `<p>` to keep some structure for screen readers
|
|
20116
|
+
// (markdown produces semantic elements; a bare text node would not).
|
|
20117
|
+
return /*#__PURE__*/ createElement("p", {
|
|
20118
|
+
key: "".concat(message.id, "-").concat(index),
|
|
20119
|
+
className: "ais-ChatMessage-text"
|
|
20120
|
+
}, part.text);
|
|
20121
|
+
}
|
|
20067
20122
|
var markdown = We(part.text, {
|
|
20068
20123
|
createElement: createElement,
|
|
20069
20124
|
disableParsingRawHTML: true
|
|
@@ -20263,6 +20318,20 @@
|
|
|
20263
20318
|
var copyToClipboard = function copyToClipboard(message) {
|
|
20264
20319
|
navigator.clipboard.writeText(getTextContent(message));
|
|
20265
20320
|
};
|
|
20321
|
+
/**
|
|
20322
|
+
* Memoization comparator for a message row. `replaceMessage` only clones the
|
|
20323
|
+
* message being updated, so completed messages keep a stable reference across
|
|
20324
|
+
* streaming deltas. We compare just what affects a row's render — `message`,
|
|
20325
|
+
* `status`, `suggestionsElement`, and this message's feedback — and ignore the
|
|
20326
|
+
* props that get a fresh reference every render but don't change the output
|
|
20327
|
+
* (`tools`, `messages`, callbacks, `indexUiState`). `indexUiState` in
|
|
20328
|
+
* particular can't be compared: `getUiState()` returns a new object each render
|
|
20329
|
+
* and would defeat the memo. Trade-off: a completed row keeps the callbacks/
|
|
20330
|
+
* `indexUiState` it last rendered with until its next genuine render.
|
|
20331
|
+
*/ function areMessagePropsEqual(prev, next) {
|
|
20332
|
+
var _prev_feedbackState, _next_feedbackState;
|
|
20333
|
+
return prev.message === next.message && prev.status === next.status && prev.suggestionsElement === next.suggestionsElement && ((_prev_feedbackState = prev.feedbackState) === null || _prev_feedbackState === void 0 ? void 0 : _prev_feedbackState[prev.message.id]) === ((_next_feedbackState = next.feedbackState) === null || _next_feedbackState === void 0 ? void 0 : _next_feedbackState[next.message.id]);
|
|
20334
|
+
}
|
|
20266
20335
|
function createDefaultMessageComponent(param) {
|
|
20267
20336
|
var createElement = param.createElement, Fragment = param.Fragment;
|
|
20268
20337
|
var ChatMessage = createChatMessageComponent({
|
|
@@ -20370,7 +20439,7 @@
|
|
|
20370
20439
|
};
|
|
20371
20440
|
}
|
|
20372
20441
|
function createChatMessagesComponent(param) {
|
|
20373
|
-
var createElement = param.createElement, Fragment = param.Fragment;
|
|
20442
|
+
var createElement = param.createElement, Fragment = param.Fragment, memo = param.memo;
|
|
20374
20443
|
var Button = createButtonComponent({
|
|
20375
20444
|
createElement: createElement
|
|
20376
20445
|
});
|
|
@@ -20378,6 +20447,10 @@
|
|
|
20378
20447
|
createElement: createElement,
|
|
20379
20448
|
Fragment: Fragment
|
|
20380
20449
|
});
|
|
20450
|
+
// Skip re-rendering (and re-compiling the markdown of) completed messages on
|
|
20451
|
+
// every streaming delta. Falls back to the plain component when the host
|
|
20452
|
+
// renderer doesn't provide a `memo` HOC.
|
|
20453
|
+
var MemoizedDefaultMessage = memo ? memo(DefaultMessageComponent, areMessagePropsEqual) : DefaultMessageComponent;
|
|
20381
20454
|
var DefaultLoaderComponent = createChatMessageLoaderComponent({
|
|
20382
20455
|
createElement: createElement
|
|
20383
20456
|
});
|
|
@@ -20440,7 +20513,7 @@
|
|
|
20440
20513
|
var lastPart = lastMessage === null || lastMessage === void 0 ? void 0 : (_lastMessage_parts = lastMessage.parts) === null || _lastMessage_parts === void 0 ? void 0 : _lastMessage_parts[lastMessage.parts.length - 1];
|
|
20441
20514
|
var showLoader = getShowLoader(status, lastPart, tools);
|
|
20442
20515
|
var showEmpty = messages.length === 0 && !showLoader && !isClearing && status !== 'error';
|
|
20443
|
-
var DefaultMessage = MessageComponent ||
|
|
20516
|
+
var DefaultMessage = MessageComponent || MemoizedDefaultMessage;
|
|
20444
20517
|
var DefaultLoader = LoaderComponent || DefaultLoaderComponent;
|
|
20445
20518
|
var DefaultError = ErrorComponent || DefaultErrorComponent;
|
|
20446
20519
|
return /*#__PURE__*/ createElement("div", _object_spread_props(_object_spread({}, props), {
|
|
@@ -20755,14 +20828,15 @@
|
|
|
20755
20828
|
}
|
|
20756
20829
|
|
|
20757
20830
|
function createChatComponent(param) {
|
|
20758
|
-
var createElement = param.createElement, Fragment = param.Fragment;
|
|
20831
|
+
var createElement = param.createElement, Fragment = param.Fragment, memo = param.memo;
|
|
20759
20832
|
var ChatHeader = createChatHeaderComponent({
|
|
20760
20833
|
createElement: createElement,
|
|
20761
20834
|
Fragment: Fragment
|
|
20762
20835
|
});
|
|
20763
20836
|
var ChatMessages = createChatMessagesComponent({
|
|
20764
20837
|
createElement: createElement,
|
|
20765
|
-
Fragment: Fragment
|
|
20838
|
+
Fragment: Fragment,
|
|
20839
|
+
memo: memo
|
|
20766
20840
|
});
|
|
20767
20841
|
var ChatPrompt = createChatPromptComponent({
|
|
20768
20842
|
createElement: createElement,
|
|
@@ -22238,6 +22312,16 @@
|
|
|
22238
22312
|
Fragment: React.Fragment
|
|
22239
22313
|
});
|
|
22240
22314
|
var id = 0;
|
|
22315
|
+
// Colons (`:r0:`) preserved so concatenations like `autocomplete:r0:input`
|
|
22316
|
+
// have a recognisable boundary; callers that need a colon-free variant for
|
|
22317
|
+
// InstantSearch's `indexId` strip them at the use site.
|
|
22318
|
+
var useAutocompleteId = React.useId ? function() {
|
|
22319
|
+
return React.useId();
|
|
22320
|
+
} : function() {
|
|
22321
|
+
return React.useState(function() {
|
|
22322
|
+
return ":a".concat(id++, ":");
|
|
22323
|
+
})[0];
|
|
22324
|
+
};
|
|
22241
22325
|
var usePropGetters = createAutocompletePropGetters({
|
|
22242
22326
|
useEffect: React.useEffect,
|
|
22243
22327
|
useId: React.useId || function() {
|
|
@@ -22373,91 +22457,185 @@
|
|
|
22373
22457
|
setIsModalOpen: setIsModalOpen
|
|
22374
22458
|
};
|
|
22375
22459
|
}
|
|
22376
|
-
function EXPERIMENTAL_Autocomplete(
|
|
22377
|
-
var
|
|
22378
|
-
|
|
22460
|
+
function EXPERIMENTAL_Autocomplete(props) {
|
|
22461
|
+
var _showRecent_classNames, _showRecent_classNames1, _showRecent_classNames2, _showRecent_classNames3;
|
|
22462
|
+
var indices = 'indices' in props ? props.indices : undefined;
|
|
22463
|
+
var feeds = 'feeds' in props ? props.feeds : undefined;
|
|
22464
|
+
var isFeedsMode = feeds !== undefined;
|
|
22465
|
+
var showQuerySuggestions = props.showQuerySuggestions, showPromptSuggestions = props.showPromptSuggestions, showRecent = props.showRecent, userSearchParameters = props.searchParameters, detachedMediaQuery = props.detachedMediaQuery, tmp = props.translations, userTranslations = tmp === void 0 ? {} : tmp, transformItems = props.transformItems, restProps = _object_without_properties(props, [
|
|
22379
22466
|
"showQuerySuggestions",
|
|
22380
22467
|
"showPromptSuggestions",
|
|
22381
22468
|
"showRecent",
|
|
22382
22469
|
"searchParameters",
|
|
22383
22470
|
"detachedMediaQuery",
|
|
22384
22471
|
"translations",
|
|
22385
|
-
"
|
|
22472
|
+
"transformItems"
|
|
22386
22473
|
]);
|
|
22387
|
-
var
|
|
22474
|
+
var autoFocus = restProps.autoFocus, placeholder = restProps.placeholder, classNames = restProps.classNames;
|
|
22475
|
+
// Eager-mount only when `autoFocus` is set — otherwise wait for first focus
|
|
22476
|
+
// before registering the autocomplete subtree in the search graph.
|
|
22477
|
+
var _useState = _sliced_to_array(React.useState(autoFocus === true), 2), activated = _useState[0], setActivated = _useState[1];
|
|
22388
22478
|
var translations = _object_spread({}, DEFAULT_TRANSLATIONS, userTranslations);
|
|
22389
22479
|
var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, indexRenderState = _useInstantSearch.indexRenderState, status = _useInstantSearch.status;
|
|
22480
|
+
var compositionID = useInstantSearchContext().compositionID;
|
|
22390
22481
|
var refine = useSearchBox({}, _object_spread({
|
|
22391
22482
|
$$type: 'ais.autocomplete',
|
|
22392
22483
|
$$widgetType: 'ais.autocomplete'
|
|
22393
|
-
}, aiMode ? {
|
|
22484
|
+
}, props.aiMode ? {
|
|
22394
22485
|
opensChat: true
|
|
22395
22486
|
} : {})).refine;
|
|
22487
|
+
var domId = useAutocompleteId();
|
|
22488
|
+
var instanceKey = domId.replace(/:/g, '');
|
|
22489
|
+
if (isFeedsMode && indices !== undefined) {
|
|
22490
|
+
throw new Error('EXPERIMENTAL_Autocomplete: `feeds` and `indices` are mutually exclusive.');
|
|
22491
|
+
}
|
|
22492
|
+
if (isFeedsMode && !compositionID) {
|
|
22493
|
+
throw new Error('EXPERIMENTAL_Autocomplete in feeds-mode requires a composition-based <InstantSearch> (compositionID must be set).');
|
|
22494
|
+
}
|
|
22396
22495
|
var isSearchStalled = status === 'stalled';
|
|
22397
22496
|
var searchParameters = _object_spread({
|
|
22398
22497
|
hitsPerPage: 5
|
|
22399
22498
|
}, userSearchParameters);
|
|
22400
|
-
|
|
22401
|
-
|
|
22402
|
-
|
|
22403
|
-
|
|
22404
|
-
|
|
22405
|
-
|
|
22406
|
-
|
|
22407
|
-
|
|
22408
|
-
|
|
22409
|
-
|
|
22410
|
-
|
|
22411
|
-
|
|
22412
|
-
|
|
22413
|
-
|
|
22414
|
-
|
|
22415
|
-
}
|
|
22416
|
-
|
|
22417
|
-
|
|
22418
|
-
|
|
22419
|
-
|
|
22420
|
-
item: cx('ais-AutocompleteSuggestionsItem', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames3 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames3 === void 0 ? void 0 : _showQuerySuggestions_classNames3.item)
|
|
22421
|
-
},
|
|
22422
|
-
searchParameters: _object_spread({
|
|
22499
|
+
// In feeds-mode `indexName` carries the feedID so downstream matching
|
|
22500
|
+
// (section building, dedupe in createAutocompleteStorage) treats feeds
|
|
22501
|
+
// like indices without any changes to InnerAutocomplete.
|
|
22502
|
+
var querySuggestionsKey = isFeedsMode ? showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.feedID : showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName;
|
|
22503
|
+
var promptSuggestionsKey = isFeedsMode ? showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.feedID : showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName;
|
|
22504
|
+
var indicesConfig = React.useMemo(function() {
|
|
22505
|
+
var config = isFeedsMode ? feeds.map(function(feed) {
|
|
22506
|
+
return {
|
|
22507
|
+
indexName: feed.feedID,
|
|
22508
|
+
headerComponent: feed.headerComponent,
|
|
22509
|
+
itemComponent: feed.itemComponent,
|
|
22510
|
+
noResultsComponent: feed.noResultsComponent,
|
|
22511
|
+
getURL: feed.getURL,
|
|
22512
|
+
getQuery: feed.getQuery,
|
|
22513
|
+
classNames: feed.classNames
|
|
22514
|
+
};
|
|
22515
|
+
}) : _to_consumable_array(indices !== null && indices !== void 0 ? indices : []);
|
|
22516
|
+
if (querySuggestionsKey) {
|
|
22517
|
+
var _showQuerySuggestions_classNames, _showQuerySuggestions_classNames1, _showQuerySuggestions_classNames2, _showQuerySuggestions_classNames3;
|
|
22518
|
+
var querySuggestionsSearchParameters = isFeedsMode ? undefined : _object_spread({
|
|
22423
22519
|
hitsPerPage: 3
|
|
22424
|
-
}, showQuerySuggestions.searchParameters)
|
|
22425
|
-
|
|
22426
|
-
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
|
|
22431
|
-
|
|
22432
|
-
|
|
22433
|
-
|
|
22434
|
-
|
|
22435
|
-
|
|
22436
|
-
|
|
22437
|
-
|
|
22438
|
-
|
|
22439
|
-
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
item: item
|
|
22443
|
-
|
|
22444
|
-
|
|
22445
|
-
|
|
22446
|
-
|
|
22447
|
-
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22451
|
-
|
|
22452
|
-
|
|
22520
|
+
}, showQuerySuggestions.searchParameters);
|
|
22521
|
+
config.unshift({
|
|
22522
|
+
indexName: querySuggestionsKey,
|
|
22523
|
+
headerComponent: showQuerySuggestions.headerComponent,
|
|
22524
|
+
itemComponent: showQuerySuggestions.itemComponent || function(param) {
|
|
22525
|
+
var item = param.item, onSelect = param.onSelect, onApply = param.onApply;
|
|
22526
|
+
return /*#__PURE__*/ React.createElement(AutocompleteSuggestion, {
|
|
22527
|
+
item: item,
|
|
22528
|
+
onSelect: onSelect,
|
|
22529
|
+
onApply: onApply
|
|
22530
|
+
}, /*#__PURE__*/ React.createElement(ConditionalReverseHighlight, {
|
|
22531
|
+
item: item
|
|
22532
|
+
}));
|
|
22533
|
+
},
|
|
22534
|
+
classNames: {
|
|
22535
|
+
root: cx('ais-AutocompleteSuggestions', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames === void 0 ? void 0 : _showQuerySuggestions_classNames.root),
|
|
22536
|
+
list: cx('ais-AutocompleteSuggestionsList', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames1 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames1 === void 0 ? void 0 : _showQuerySuggestions_classNames1.list),
|
|
22537
|
+
header: cx('ais-AutocompleteSuggestionsHeader', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames2 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames2 === void 0 ? void 0 : _showQuerySuggestions_classNames2.header),
|
|
22538
|
+
item: cx('ais-AutocompleteSuggestionsItem', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames3 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames3 === void 0 ? void 0 : _showQuerySuggestions_classNames3.item)
|
|
22539
|
+
},
|
|
22540
|
+
searchParameters: querySuggestionsSearchParameters,
|
|
22541
|
+
getQuery: function getQuery(item) {
|
|
22542
|
+
return item.query;
|
|
22543
|
+
},
|
|
22544
|
+
getURL: showQuerySuggestions.getURL
|
|
22545
|
+
});
|
|
22546
|
+
}
|
|
22547
|
+
if (promptSuggestionsKey) {
|
|
22548
|
+
var _showPromptSuggestions_classNames, _showPromptSuggestions_classNames1, _showPromptSuggestions_classNames2, _showPromptSuggestions_classNames3;
|
|
22549
|
+
var promptSuggestionsSearchParameters = isFeedsMode ? undefined : _object_spread({
|
|
22453
22550
|
hitsPerPage: 3
|
|
22454
|
-
}, showPromptSuggestions.searchParameters)
|
|
22455
|
-
|
|
22456
|
-
|
|
22457
|
-
|
|
22458
|
-
|
|
22459
|
-
|
|
22460
|
-
|
|
22551
|
+
}, showPromptSuggestions.searchParameters);
|
|
22552
|
+
config.push({
|
|
22553
|
+
indexName: promptSuggestionsKey,
|
|
22554
|
+
headerComponent: showPromptSuggestions.headerComponent,
|
|
22555
|
+
itemComponent: showPromptSuggestions.itemComponent || function(param) {
|
|
22556
|
+
var item = param.item, onSelect = param.onSelect;
|
|
22557
|
+
return /*#__PURE__*/ React.createElement(AutocompletePromptSuggestion, {
|
|
22558
|
+
item: item,
|
|
22559
|
+
onSelect: onSelect
|
|
22560
|
+
}, /*#__PURE__*/ React.createElement(ConditionalHighlight, {
|
|
22561
|
+
item: item,
|
|
22562
|
+
attribute: "prompt"
|
|
22563
|
+
}));
|
|
22564
|
+
},
|
|
22565
|
+
classNames: {
|
|
22566
|
+
root: cx('ais-AutocompletePromptSuggestions', showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : (_showPromptSuggestions_classNames = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames === void 0 ? void 0 : _showPromptSuggestions_classNames.root),
|
|
22567
|
+
list: cx('ais-AutocompletePromptSuggestionsList', showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : (_showPromptSuggestions_classNames1 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames1 === void 0 ? void 0 : _showPromptSuggestions_classNames1.list),
|
|
22568
|
+
header: cx('ais-AutocompletePromptSuggestionsHeader', showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : (_showPromptSuggestions_classNames2 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames2 === void 0 ? void 0 : _showPromptSuggestions_classNames2.header),
|
|
22569
|
+
item: cx('ais-AutocompletePromptSuggestionsItem', showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : (_showPromptSuggestions_classNames3 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames3 === void 0 ? void 0 : _showPromptSuggestions_classNames3.item)
|
|
22570
|
+
},
|
|
22571
|
+
searchParameters: promptSuggestionsSearchParameters,
|
|
22572
|
+
getQuery: function getQuery(item) {
|
|
22573
|
+
return item.prompt;
|
|
22574
|
+
},
|
|
22575
|
+
getURL: showPromptSuggestions.getURL
|
|
22576
|
+
});
|
|
22577
|
+
}
|
|
22578
|
+
return config;
|
|
22579
|
+
}, [
|
|
22580
|
+
feeds,
|
|
22581
|
+
indices,
|
|
22582
|
+
isFeedsMode,
|
|
22583
|
+
promptSuggestionsKey,
|
|
22584
|
+
querySuggestionsKey,
|
|
22585
|
+
showPromptSuggestions,
|
|
22586
|
+
showQuerySuggestions
|
|
22587
|
+
]);
|
|
22588
|
+
// Normalize `show*` for InnerAutocomplete: always surface `indexName`
|
|
22589
|
+
// (in feeds-mode it carries the feedID). Keeps downstream dedupe in
|
|
22590
|
+
// createAutocompleteStorage (suggestionsIndexName === index.indexName) working.
|
|
22591
|
+
var normalizedShowQuerySuggestions = React.useMemo(function() {
|
|
22592
|
+
if (!showQuerySuggestions) {
|
|
22593
|
+
return undefined;
|
|
22594
|
+
}
|
|
22595
|
+
if (isFeedsMode) {
|
|
22596
|
+
return _object_spread_props(_object_spread({}, showQuerySuggestions), {
|
|
22597
|
+
indexName: querySuggestionsKey
|
|
22598
|
+
});
|
|
22599
|
+
}
|
|
22600
|
+
return showQuerySuggestions;
|
|
22601
|
+
}, [
|
|
22602
|
+
isFeedsMode,
|
|
22603
|
+
querySuggestionsKey,
|
|
22604
|
+
showQuerySuggestions
|
|
22605
|
+
]);
|
|
22606
|
+
var normalizedShowPromptSuggestions = React.useMemo(function() {
|
|
22607
|
+
if (!showPromptSuggestions) {
|
|
22608
|
+
return undefined;
|
|
22609
|
+
}
|
|
22610
|
+
if (isFeedsMode) {
|
|
22611
|
+
return _object_spread_props(_object_spread({}, showPromptSuggestions), {
|
|
22612
|
+
indexName: promptSuggestionsKey
|
|
22613
|
+
});
|
|
22614
|
+
}
|
|
22615
|
+
return showPromptSuggestions;
|
|
22616
|
+
}, [
|
|
22617
|
+
isFeedsMode,
|
|
22618
|
+
promptSuggestionsKey,
|
|
22619
|
+
showPromptSuggestions
|
|
22620
|
+
]);
|
|
22621
|
+
// In feeds-mode, remap `indexName := indexId` so downstream storage (which
|
|
22622
|
+
// matches on indexName) sees feedIDs instead of the composition index name
|
|
22623
|
+
// that connectAutocomplete sets from the helper results.
|
|
22624
|
+
// Must be memoized: useConnector's useStableValue runs dequal on each render
|
|
22625
|
+
// and treats a new function identity as a change, re-registering the widget.
|
|
22626
|
+
var effectiveTransformItems = React.useMemo(function() {
|
|
22627
|
+
return isFeedsMode ? function(items) {
|
|
22628
|
+
var remapped = items.map(function(item) {
|
|
22629
|
+
return _object_spread_props(_object_spread({}, item), {
|
|
22630
|
+
indexName: item.indexId
|
|
22631
|
+
});
|
|
22632
|
+
});
|
|
22633
|
+
return transformItems ? transformItems(remapped) : remapped;
|
|
22634
|
+
} : transformItems;
|
|
22635
|
+
}, [
|
|
22636
|
+
isFeedsMode,
|
|
22637
|
+
transformItems
|
|
22638
|
+
]);
|
|
22461
22639
|
var recentSearchConfig = showRecent ? {
|
|
22462
22640
|
headerComponent: (typeof showRecent === "undefined" ? "undefined" : _type_of(showRecent)) === 'object' ? showRecent.headerComponent : undefined,
|
|
22463
22641
|
itemComponent: (typeof showRecent === "undefined" ? "undefined" : _type_of(showRecent)) === 'object' && showRecent.itemComponent ? showRecent.itemComponent : AutocompleteRecentSearch,
|
|
@@ -22473,15 +22651,88 @@
|
|
|
22473
22651
|
}, [
|
|
22474
22652
|
indexRenderState
|
|
22475
22653
|
]);
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22481
|
-
|
|
22482
|
-
|
|
22483
|
-
|
|
22484
|
-
|
|
22654
|
+
restProps.indices; restProps.feeds; var forwardedProps = _object_without_properties(restProps, [
|
|
22655
|
+
"indices",
|
|
22656
|
+
"feeds"
|
|
22657
|
+
]);
|
|
22658
|
+
var instance = useInstantSearchContext();
|
|
22659
|
+
var detached = useDetachedMode(detachedMediaQuery);
|
|
22660
|
+
var isDetached = detached.isDetached, setIsModalOpen = detached.setIsModalOpen;
|
|
22661
|
+
// Lazy activation only: when `activated` flips from false to true, the
|
|
22662
|
+
// newly-mounted isolated `<Index>` schedules the parent's search even
|
|
22663
|
+
// though the parent's state hasn't changed. Cancel it so only the
|
|
22664
|
+
// autocomplete's own search fires on activation. Skip when `autoFocus`
|
|
22665
|
+
// mounts the inner eagerly — the parent's legitimate initial search
|
|
22666
|
+
// shares the same defer slot and must not be cancelled.
|
|
22667
|
+
var initialActivatedRef = React.useRef(activated);
|
|
22668
|
+
React.useLayoutEffect(function() {
|
|
22669
|
+
if (activated && !initialActivatedRef.current) {
|
|
22670
|
+
initialActivatedRef.current = true;
|
|
22671
|
+
instance.scheduleSearch.cancel();
|
|
22672
|
+
}
|
|
22673
|
+
}, [
|
|
22674
|
+
activated,
|
|
22675
|
+
instance
|
|
22676
|
+
]);
|
|
22677
|
+
if (!activated) {
|
|
22678
|
+
var _indexUiState_query, _indexUiState_query1;
|
|
22679
|
+
restProps.indices; restProps.feeds; restProps.autoFocus; restProps.placeholder; restProps.classNames; restProps.aiMode; restProps.panelComponent; restProps.getSearchPageURL; restProps.onSelect; var shellRootProps = _object_without_properties(restProps, [
|
|
22680
|
+
"indices",
|
|
22681
|
+
"feeds",
|
|
22682
|
+
"autoFocus",
|
|
22683
|
+
"placeholder",
|
|
22684
|
+
"classNames",
|
|
22685
|
+
"aiMode",
|
|
22686
|
+
"panelComponent",
|
|
22687
|
+
"getSearchPageURL",
|
|
22688
|
+
"onSelect"
|
|
22689
|
+
]);
|
|
22690
|
+
var activateWithQueryMirror = function activateWithQueryMirror() {
|
|
22691
|
+
// Routing only fills the parent index's UI state, not the
|
|
22692
|
+
// autocomplete's isolated one, so without this, the autocomplete
|
|
22693
|
+
// would activate with an empty query and fire a useless search.
|
|
22694
|
+
// We copy the parent's query into the autocomplete's slot of
|
|
22695
|
+
// `_initialUiState` right before flipping `activated`: that's the
|
|
22696
|
+
// moment the isolated `<Index>` is about to mount and read it.
|
|
22697
|
+
// Doing this later would mean firing a second search to correct
|
|
22698
|
+
// the first.
|
|
22699
|
+
if (indexUiState.query) {
|
|
22700
|
+
var isoIndexId = "ais-autocomplete-".concat(instanceKey);
|
|
22701
|
+
var initial = instance._initialUiState;
|
|
22702
|
+
initial[isoIndexId] = _object_spread_props(_object_spread({}, initial[isoIndexId]), {
|
|
22703
|
+
query: indexUiState.query
|
|
22704
|
+
});
|
|
22705
|
+
}
|
|
22706
|
+
setActivated(true);
|
|
22707
|
+
};
|
|
22708
|
+
return /*#__PURE__*/ React.createElement(Autocomplete, _object_spread_props(_object_spread({}, shellRootProps), {
|
|
22709
|
+
classNames: classNames
|
|
22710
|
+
}), isDetached ? /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
22711
|
+
query: (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '',
|
|
22712
|
+
placeholder: placeholder,
|
|
22713
|
+
classNames: classNames,
|
|
22714
|
+
translations: translations,
|
|
22715
|
+
onClick: function onClick() {
|
|
22716
|
+
setIsModalOpen(true);
|
|
22717
|
+
activateWithQueryMirror();
|
|
22718
|
+
}
|
|
22719
|
+
}) : /*#__PURE__*/ React.createElement(AutocompleteSearch, {
|
|
22720
|
+
inputProps: {
|
|
22721
|
+
id: "autocomplete".concat(domId, "input"),
|
|
22722
|
+
role: 'combobox',
|
|
22723
|
+
placeholder: placeholder,
|
|
22724
|
+
onFocus: activateWithQueryMirror
|
|
22725
|
+
},
|
|
22726
|
+
clearQuery: function clearQuery() {},
|
|
22727
|
+
query: (_indexUiState_query1 = indexUiState.query) !== null && _indexUiState_query1 !== void 0 ? _indexUiState_query1 : '',
|
|
22728
|
+
isSearchStalled: false,
|
|
22729
|
+
classNames: classNames
|
|
22730
|
+
}));
|
|
22731
|
+
}
|
|
22732
|
+
var innerAutocomplete = /*#__PURE__*/ React.createElement(InnerAutocomplete, _object_spread_props(_object_spread({}, forwardedProps), {
|
|
22733
|
+
autoFocus: true,
|
|
22734
|
+
domId: domId,
|
|
22735
|
+
detached: detached,
|
|
22485
22736
|
indicesConfig: indicesConfig,
|
|
22486
22737
|
refineSearchBox: refine,
|
|
22487
22738
|
isSearchStalled: isSearchStalled,
|
|
@@ -22489,15 +22740,37 @@
|
|
|
22489
22740
|
isSearchPage: isSearchPage,
|
|
22490
22741
|
showRecent: showRecent,
|
|
22491
22742
|
recentSearchConfig: recentSearchConfig,
|
|
22492
|
-
showQuerySuggestions:
|
|
22493
|
-
detachedMediaQuery: detachedMediaQuery,
|
|
22743
|
+
showQuerySuggestions: normalizedShowQuerySuggestions,
|
|
22494
22744
|
translations: translations,
|
|
22495
|
-
showPromptSuggestions:
|
|
22745
|
+
showPromptSuggestions: normalizedShowPromptSuggestions,
|
|
22746
|
+
transformItems: effectiveTransformItems,
|
|
22496
22747
|
chatRenderState: indexRenderState.chat
|
|
22497
|
-
}))
|
|
22748
|
+
}));
|
|
22749
|
+
if (isFeedsMode) {
|
|
22750
|
+
return /*#__PURE__*/ React.createElement(Index, {
|
|
22751
|
+
EXPERIMENTAL_isolated: true,
|
|
22752
|
+
indexName: compositionID,
|
|
22753
|
+
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
22754
|
+
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), /*#__PURE__*/ React.createElement(Feeds, {
|
|
22755
|
+
isolated: false,
|
|
22756
|
+
renderFeed: function renderFeed() {
|
|
22757
|
+
return null;
|
|
22758
|
+
}
|
|
22759
|
+
}), innerAutocomplete);
|
|
22760
|
+
}
|
|
22761
|
+
return /*#__PURE__*/ React.createElement(Index, {
|
|
22762
|
+
EXPERIMENTAL_isolated: true,
|
|
22763
|
+
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
22764
|
+
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), indicesConfig.map(function(index) {
|
|
22765
|
+
return /*#__PURE__*/ React.createElement(Index, {
|
|
22766
|
+
key: index.indexName,
|
|
22767
|
+
indexName: index.indexName,
|
|
22768
|
+
indexId: "ais-autocomplete-".concat(instanceKey, "-").concat(index.indexName)
|
|
22769
|
+
}, /*#__PURE__*/ React.createElement(Configure, index.searchParameters));
|
|
22770
|
+
}), innerAutocomplete);
|
|
22498
22771
|
}
|
|
22499
22772
|
function InnerAutocomplete(_0) {
|
|
22500
|
-
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,
|
|
22773
|
+
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, [
|
|
22501
22774
|
"indicesConfig",
|
|
22502
22775
|
"refineSearchBox",
|
|
22503
22776
|
"isSearchStalled",
|
|
@@ -22514,10 +22787,11 @@
|
|
|
22514
22787
|
"transformItems",
|
|
22515
22788
|
"placeholder",
|
|
22516
22789
|
"autoFocus",
|
|
22517
|
-
"detachedMediaQuery",
|
|
22518
22790
|
"translations",
|
|
22519
22791
|
"classNames",
|
|
22520
|
-
"aiMode"
|
|
22792
|
+
"aiMode",
|
|
22793
|
+
"domId",
|
|
22794
|
+
"detached"
|
|
22521
22795
|
]);
|
|
22522
22796
|
var _indexUiState_query, _ref;
|
|
22523
22797
|
var _showPromptSuggestions_searchParameters;
|
|
@@ -22528,7 +22802,7 @@
|
|
|
22528
22802
|
}
|
|
22529
22803
|
}), indices = _useAutocomplete.indices, refineAutocomplete = _useAutocomplete.refine, currentRefinement = _useAutocomplete.currentRefinement;
|
|
22530
22804
|
var resolvedQuery = currentRefinement !== undefined ? currentRefinement : (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '';
|
|
22531
|
-
var
|
|
22805
|
+
var isDetached = detached.isDetached, isModalDetached = detached.isModalDetached, isModalOpen = detached.isModalOpen, setIsModalOpen = detached.setIsModalOpen;
|
|
22532
22806
|
var previousIsDetachedRef = React.useRef(isDetached);
|
|
22533
22807
|
var _useStorage = useStorage({
|
|
22534
22808
|
showRecent: showRecent,
|
|
@@ -22594,6 +22868,7 @@
|
|
|
22594
22868
|
});
|
|
22595
22869
|
var shouldHideEmptyPanel = allIndicesEmpty && recentEmpty && !hasNoResultsTemplate && !PanelComponent;
|
|
22596
22870
|
var _usePropGetters = usePropGetters({
|
|
22871
|
+
id: domId,
|
|
22597
22872
|
indices: indicesForPropGettersWithPromptSuggestions,
|
|
22598
22873
|
indicesConfig: indicesConfigForPropGetters,
|
|
22599
22874
|
onRefine: function onRefine(query) {
|
|
@@ -22718,7 +22993,7 @@
|
|
|
22718
22993
|
NoResultsComponent: currentIndexConfig.noResultsComponent,
|
|
22719
22994
|
items: hits.map(function(item) {
|
|
22720
22995
|
return _object_spread_props(_object_spread({}, item), {
|
|
22721
|
-
__indexName:
|
|
22996
|
+
__indexName: indexName
|
|
22722
22997
|
});
|
|
22723
22998
|
}),
|
|
22724
22999
|
getItemProps: getItemProps,
|
|
@@ -23119,7 +23394,8 @@
|
|
|
23119
23394
|
|
|
23120
23395
|
var ChatUiComponent = createChatComponent({
|
|
23121
23396
|
createElement: React.createElement,
|
|
23122
|
-
Fragment: React.Fragment
|
|
23397
|
+
Fragment: React.Fragment,
|
|
23398
|
+
memo: React.memo
|
|
23123
23399
|
});
|
|
23124
23400
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
23125
23401
|
var _obj;
|
|
@@ -23207,6 +23483,23 @@
|
|
|
23207
23483
|
}, [
|
|
23208
23484
|
open
|
|
23209
23485
|
]);
|
|
23486
|
+
// Keep the conversation pinned to the bottom while streaming. The stick-to-
|
|
23487
|
+
// bottom ResizeObserver only reacts to content *height* changes, but tool
|
|
23488
|
+
// results such as a horizontally-growing carousel stream in without changing
|
|
23489
|
+
// height — so we also re-pin on every message/status update. Passing
|
|
23490
|
+
// `preserveScrollPosition` reuses the existing "only if already at the
|
|
23491
|
+
// bottom" gate, so this never fights a user who has scrolled up to read.
|
|
23492
|
+
React.useEffect(function() {
|
|
23493
|
+
if (status === 'streaming' || status === 'submitted') {
|
|
23494
|
+
scrollToBottom({
|
|
23495
|
+
preserveScrollPosition: true
|
|
23496
|
+
});
|
|
23497
|
+
}
|
|
23498
|
+
}, [
|
|
23499
|
+
messages,
|
|
23500
|
+
status,
|
|
23501
|
+
scrollToBottom
|
|
23502
|
+
]);
|
|
23210
23503
|
if (error) {
|
|
23211
23504
|
throw error;
|
|
23212
23505
|
}
|