react-instantsearch 7.35.1 → 7.36.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 +192 -77
- package/dist/cjs/widgets/Chat.js +19 -1
- package/dist/es/widgets/Autocomplete.d.ts +78 -27
- package/dist/es/widgets/Autocomplete.js +210 -95
- package/dist/es/widgets/Chat.js +20 -2
- package/dist/umd/ReactInstantSearch.js +252 -87
- 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.36.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.36.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.102.0';
|
|
10825
10825
|
|
|
10826
10826
|
var withUsage$r = createDocumentationMessageGenerator({
|
|
10827
10827
|
name: 'instantsearch'
|
|
@@ -20018,7 +20018,7 @@
|
|
|
20018
20018
|
createElement: createElement
|
|
20019
20019
|
});
|
|
20020
20020
|
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, [
|
|
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, _userProps_parseMarkdown = userProps.parseMarkdown, parseMarkdown = _userProps_parseMarkdown === void 0 ? true : _userProps_parseMarkdown, props = _object_without_properties(userProps, [
|
|
20022
20022
|
"classNames",
|
|
20023
20023
|
"message",
|
|
20024
20024
|
"status",
|
|
@@ -20035,7 +20035,8 @@
|
|
|
20035
20035
|
"messages",
|
|
20036
20036
|
"onClose",
|
|
20037
20037
|
"translations",
|
|
20038
|
-
"suggestionsElement"
|
|
20038
|
+
"suggestionsElement",
|
|
20039
|
+
"parseMarkdown"
|
|
20039
20040
|
]);
|
|
20040
20041
|
var translations = _object_spread({
|
|
20041
20042
|
messageLabel: 'Message',
|
|
@@ -20064,6 +20065,18 @@
|
|
|
20064
20065
|
if (part.text.startsWith('<context>') && part.text.endsWith('</context>')) {
|
|
20065
20066
|
return null;
|
|
20066
20067
|
}
|
|
20068
|
+
if (!parseMarkdown) {
|
|
20069
|
+
// Render the literal text. The `ais-ChatMessage-text` class applies
|
|
20070
|
+
// `white-space: pre-wrap` to preserve the newlines that markdown
|
|
20071
|
+
// would otherwise collapse, and streaming deltas append cleanly
|
|
20072
|
+
// because there's no parser state to get into a half-parsed entity.
|
|
20073
|
+
// Wrapped in a `<p>` to keep some structure for screen readers
|
|
20074
|
+
// (markdown produces semantic elements; a bare text node would not).
|
|
20075
|
+
return /*#__PURE__*/ createElement("p", {
|
|
20076
|
+
key: "".concat(message.id, "-").concat(index),
|
|
20077
|
+
className: "ais-ChatMessage-text"
|
|
20078
|
+
}, part.text);
|
|
20079
|
+
}
|
|
20067
20080
|
var markdown = We(part.text, {
|
|
20068
20081
|
createElement: createElement,
|
|
20069
20082
|
disableParsingRawHTML: true
|
|
@@ -20263,6 +20276,20 @@
|
|
|
20263
20276
|
var copyToClipboard = function copyToClipboard(message) {
|
|
20264
20277
|
navigator.clipboard.writeText(getTextContent(message));
|
|
20265
20278
|
};
|
|
20279
|
+
/**
|
|
20280
|
+
* Memoization comparator for a message row. `replaceMessage` only clones the
|
|
20281
|
+
* message being updated, so completed messages keep a stable reference across
|
|
20282
|
+
* streaming deltas. We compare just what affects a row's render — `message`,
|
|
20283
|
+
* `status`, `suggestionsElement`, and this message's feedback — and ignore the
|
|
20284
|
+
* props that get a fresh reference every render but don't change the output
|
|
20285
|
+
* (`tools`, `messages`, callbacks, `indexUiState`). `indexUiState` in
|
|
20286
|
+
* particular can't be compared: `getUiState()` returns a new object each render
|
|
20287
|
+
* and would defeat the memo. Trade-off: a completed row keeps the callbacks/
|
|
20288
|
+
* `indexUiState` it last rendered with until its next genuine render.
|
|
20289
|
+
*/ function areMessagePropsEqual(prev, next) {
|
|
20290
|
+
var _prev_feedbackState, _next_feedbackState;
|
|
20291
|
+
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]);
|
|
20292
|
+
}
|
|
20266
20293
|
function createDefaultMessageComponent(param) {
|
|
20267
20294
|
var createElement = param.createElement, Fragment = param.Fragment;
|
|
20268
20295
|
var ChatMessage = createChatMessageComponent({
|
|
@@ -20370,7 +20397,7 @@
|
|
|
20370
20397
|
};
|
|
20371
20398
|
}
|
|
20372
20399
|
function createChatMessagesComponent(param) {
|
|
20373
|
-
var createElement = param.createElement, Fragment = param.Fragment;
|
|
20400
|
+
var createElement = param.createElement, Fragment = param.Fragment, memo = param.memo;
|
|
20374
20401
|
var Button = createButtonComponent({
|
|
20375
20402
|
createElement: createElement
|
|
20376
20403
|
});
|
|
@@ -20378,6 +20405,10 @@
|
|
|
20378
20405
|
createElement: createElement,
|
|
20379
20406
|
Fragment: Fragment
|
|
20380
20407
|
});
|
|
20408
|
+
// Skip re-rendering (and re-compiling the markdown of) completed messages on
|
|
20409
|
+
// every streaming delta. Falls back to the plain component when the host
|
|
20410
|
+
// renderer doesn't provide a `memo` HOC.
|
|
20411
|
+
var MemoizedDefaultMessage = memo ? memo(DefaultMessageComponent, areMessagePropsEqual) : DefaultMessageComponent;
|
|
20381
20412
|
var DefaultLoaderComponent = createChatMessageLoaderComponent({
|
|
20382
20413
|
createElement: createElement
|
|
20383
20414
|
});
|
|
@@ -20440,7 +20471,7 @@
|
|
|
20440
20471
|
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
20472
|
var showLoader = getShowLoader(status, lastPart, tools);
|
|
20442
20473
|
var showEmpty = messages.length === 0 && !showLoader && !isClearing && status !== 'error';
|
|
20443
|
-
var DefaultMessage = MessageComponent ||
|
|
20474
|
+
var DefaultMessage = MessageComponent || MemoizedDefaultMessage;
|
|
20444
20475
|
var DefaultLoader = LoaderComponent || DefaultLoaderComponent;
|
|
20445
20476
|
var DefaultError = ErrorComponent || DefaultErrorComponent;
|
|
20446
20477
|
return /*#__PURE__*/ createElement("div", _object_spread_props(_object_spread({}, props), {
|
|
@@ -20755,14 +20786,15 @@
|
|
|
20755
20786
|
}
|
|
20756
20787
|
|
|
20757
20788
|
function createChatComponent(param) {
|
|
20758
|
-
var createElement = param.createElement, Fragment = param.Fragment;
|
|
20789
|
+
var createElement = param.createElement, Fragment = param.Fragment, memo = param.memo;
|
|
20759
20790
|
var ChatHeader = createChatHeaderComponent({
|
|
20760
20791
|
createElement: createElement,
|
|
20761
20792
|
Fragment: Fragment
|
|
20762
20793
|
});
|
|
20763
20794
|
var ChatMessages = createChatMessagesComponent({
|
|
20764
20795
|
createElement: createElement,
|
|
20765
|
-
Fragment: Fragment
|
|
20796
|
+
Fragment: Fragment,
|
|
20797
|
+
memo: memo
|
|
20766
20798
|
});
|
|
20767
20799
|
var ChatPrompt = createChatPromptComponent({
|
|
20768
20800
|
createElement: createElement,
|
|
@@ -22238,6 +22270,13 @@
|
|
|
22238
22270
|
Fragment: React.Fragment
|
|
22239
22271
|
});
|
|
22240
22272
|
var id = 0;
|
|
22273
|
+
var useAutocompleteInstanceId = React.useId ? function() {
|
|
22274
|
+
return React.useId().replace(/:/g, '');
|
|
22275
|
+
} : function() {
|
|
22276
|
+
return React.useState(function() {
|
|
22277
|
+
return "a".concat(id++);
|
|
22278
|
+
})[0];
|
|
22279
|
+
};
|
|
22241
22280
|
var usePropGetters = createAutocompletePropGetters({
|
|
22242
22281
|
useEffect: React.useEffect,
|
|
22243
22282
|
useId: React.useId || function() {
|
|
@@ -22373,91 +22412,182 @@
|
|
|
22373
22412
|
setIsModalOpen: setIsModalOpen
|
|
22374
22413
|
};
|
|
22375
22414
|
}
|
|
22376
|
-
function EXPERIMENTAL_Autocomplete(
|
|
22377
|
-
var
|
|
22378
|
-
|
|
22415
|
+
function EXPERIMENTAL_Autocomplete(props) {
|
|
22416
|
+
var _showRecent_classNames, _showRecent_classNames1, _showRecent_classNames2, _showRecent_classNames3;
|
|
22417
|
+
var indices = 'indices' in props ? props.indices : undefined;
|
|
22418
|
+
var feeds = 'feeds' in props ? props.feeds : undefined;
|
|
22419
|
+
var isFeedsMode = feeds !== undefined;
|
|
22420
|
+
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
22421
|
"showQuerySuggestions",
|
|
22380
22422
|
"showPromptSuggestions",
|
|
22381
22423
|
"showRecent",
|
|
22382
22424
|
"searchParameters",
|
|
22383
22425
|
"detachedMediaQuery",
|
|
22384
22426
|
"translations",
|
|
22385
|
-
"
|
|
22427
|
+
"transformItems"
|
|
22386
22428
|
]);
|
|
22387
|
-
var _showRecent_classNames, _showRecent_classNames1, _showRecent_classNames2, _showRecent_classNames3;
|
|
22388
22429
|
var translations = _object_spread({}, DEFAULT_TRANSLATIONS, userTranslations);
|
|
22389
22430
|
var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, indexRenderState = _useInstantSearch.indexRenderState, status = _useInstantSearch.status;
|
|
22431
|
+
var compositionID = useInstantSearchContext().compositionID;
|
|
22390
22432
|
var refine = useSearchBox({}, _object_spread({
|
|
22391
22433
|
$$type: 'ais.autocomplete',
|
|
22392
22434
|
$$widgetType: 'ais.autocomplete'
|
|
22393
|
-
}, aiMode ? {
|
|
22435
|
+
}, props.aiMode ? {
|
|
22394
22436
|
opensChat: true
|
|
22395
22437
|
} : {})).refine;
|
|
22438
|
+
// In feeds-mode, indexId disambiguates multiple Autocomplete instances
|
|
22439
|
+
// sharing the same compositionID. Mirrors the fallback at line 111 for React <18.
|
|
22440
|
+
var instanceKey = useAutocompleteInstanceId();
|
|
22441
|
+
if (isFeedsMode && indices !== undefined) {
|
|
22442
|
+
throw new Error('EXPERIMENTAL_Autocomplete: `feeds` and `indices` are mutually exclusive.');
|
|
22443
|
+
}
|
|
22444
|
+
if (isFeedsMode && !compositionID) {
|
|
22445
|
+
throw new Error('EXPERIMENTAL_Autocomplete in feeds-mode requires a composition-based <InstantSearch> (compositionID must be set).');
|
|
22446
|
+
}
|
|
22396
22447
|
var isSearchStalled = status === 'stalled';
|
|
22397
22448
|
var searchParameters = _object_spread({
|
|
22398
22449
|
hitsPerPage: 5
|
|
22399
22450
|
}, 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({
|
|
22451
|
+
// In feeds-mode `indexName` carries the feedID so downstream matching
|
|
22452
|
+
// (section building, dedupe in createAutocompleteStorage) treats feeds
|
|
22453
|
+
// like indices without any changes to InnerAutocomplete.
|
|
22454
|
+
var querySuggestionsKey = isFeedsMode ? showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.feedID : showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName;
|
|
22455
|
+
var promptSuggestionsKey = isFeedsMode ? showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.feedID : showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName;
|
|
22456
|
+
var indicesConfig = React.useMemo(function() {
|
|
22457
|
+
var config = isFeedsMode ? feeds.map(function(feed) {
|
|
22458
|
+
return {
|
|
22459
|
+
indexName: feed.feedID,
|
|
22460
|
+
headerComponent: feed.headerComponent,
|
|
22461
|
+
itemComponent: feed.itemComponent,
|
|
22462
|
+
noResultsComponent: feed.noResultsComponent,
|
|
22463
|
+
getURL: feed.getURL,
|
|
22464
|
+
getQuery: feed.getQuery,
|
|
22465
|
+
classNames: feed.classNames
|
|
22466
|
+
};
|
|
22467
|
+
}) : _to_consumable_array(indices !== null && indices !== void 0 ? indices : []);
|
|
22468
|
+
if (querySuggestionsKey) {
|
|
22469
|
+
var _showQuerySuggestions_classNames, _showQuerySuggestions_classNames1, _showQuerySuggestions_classNames2, _showQuerySuggestions_classNames3;
|
|
22470
|
+
var querySuggestionsSearchParameters = isFeedsMode ? undefined : _object_spread({
|
|
22423
22471
|
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
|
-
|
|
22472
|
+
}, showQuerySuggestions.searchParameters);
|
|
22473
|
+
config.unshift({
|
|
22474
|
+
indexName: querySuggestionsKey,
|
|
22475
|
+
headerComponent: showQuerySuggestions.headerComponent,
|
|
22476
|
+
itemComponent: showQuerySuggestions.itemComponent || function(param) {
|
|
22477
|
+
var item = param.item, onSelect = param.onSelect, onApply = param.onApply;
|
|
22478
|
+
return /*#__PURE__*/ React.createElement(AutocompleteSuggestion, {
|
|
22479
|
+
item: item,
|
|
22480
|
+
onSelect: onSelect,
|
|
22481
|
+
onApply: onApply
|
|
22482
|
+
}, /*#__PURE__*/ React.createElement(ConditionalReverseHighlight, {
|
|
22483
|
+
item: item
|
|
22484
|
+
}));
|
|
22485
|
+
},
|
|
22486
|
+
classNames: {
|
|
22487
|
+
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),
|
|
22488
|
+
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),
|
|
22489
|
+
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),
|
|
22490
|
+
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)
|
|
22491
|
+
},
|
|
22492
|
+
searchParameters: querySuggestionsSearchParameters,
|
|
22493
|
+
getQuery: function getQuery(item) {
|
|
22494
|
+
return item.query;
|
|
22495
|
+
},
|
|
22496
|
+
getURL: showQuerySuggestions.getURL
|
|
22497
|
+
});
|
|
22498
|
+
}
|
|
22499
|
+
if (promptSuggestionsKey) {
|
|
22500
|
+
var _showPromptSuggestions_classNames, _showPromptSuggestions_classNames1, _showPromptSuggestions_classNames2, _showPromptSuggestions_classNames3;
|
|
22501
|
+
var promptSuggestionsSearchParameters = isFeedsMode ? undefined : _object_spread({
|
|
22453
22502
|
hitsPerPage: 3
|
|
22454
|
-
}, showPromptSuggestions.searchParameters)
|
|
22455
|
-
|
|
22456
|
-
|
|
22457
|
-
|
|
22458
|
-
|
|
22459
|
-
|
|
22460
|
-
|
|
22503
|
+
}, showPromptSuggestions.searchParameters);
|
|
22504
|
+
config.push({
|
|
22505
|
+
indexName: promptSuggestionsKey,
|
|
22506
|
+
headerComponent: showPromptSuggestions.headerComponent,
|
|
22507
|
+
itemComponent: showPromptSuggestions.itemComponent || function(param) {
|
|
22508
|
+
var item = param.item, onSelect = param.onSelect;
|
|
22509
|
+
return /*#__PURE__*/ React.createElement(AutocompletePromptSuggestion, {
|
|
22510
|
+
item: item,
|
|
22511
|
+
onSelect: onSelect
|
|
22512
|
+
}, /*#__PURE__*/ React.createElement(ConditionalHighlight, {
|
|
22513
|
+
item: item,
|
|
22514
|
+
attribute: "prompt"
|
|
22515
|
+
}));
|
|
22516
|
+
},
|
|
22517
|
+
classNames: {
|
|
22518
|
+
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),
|
|
22519
|
+
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),
|
|
22520
|
+
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),
|
|
22521
|
+
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)
|
|
22522
|
+
},
|
|
22523
|
+
searchParameters: promptSuggestionsSearchParameters,
|
|
22524
|
+
getQuery: function getQuery(item) {
|
|
22525
|
+
return item.prompt;
|
|
22526
|
+
},
|
|
22527
|
+
getURL: showPromptSuggestions.getURL
|
|
22528
|
+
});
|
|
22529
|
+
}
|
|
22530
|
+
return config;
|
|
22531
|
+
}, [
|
|
22532
|
+
feeds,
|
|
22533
|
+
indices,
|
|
22534
|
+
isFeedsMode,
|
|
22535
|
+
promptSuggestionsKey,
|
|
22536
|
+
querySuggestionsKey,
|
|
22537
|
+
showPromptSuggestions,
|
|
22538
|
+
showQuerySuggestions
|
|
22539
|
+
]);
|
|
22540
|
+
// Normalize `show*` for InnerAutocomplete: always surface `indexName`
|
|
22541
|
+
// (in feeds-mode it carries the feedID). Keeps downstream dedupe in
|
|
22542
|
+
// createAutocompleteStorage (suggestionsIndexName === index.indexName) working.
|
|
22543
|
+
var normalizedShowQuerySuggestions = React.useMemo(function() {
|
|
22544
|
+
if (!showQuerySuggestions) {
|
|
22545
|
+
return undefined;
|
|
22546
|
+
}
|
|
22547
|
+
if (isFeedsMode) {
|
|
22548
|
+
return _object_spread_props(_object_spread({}, showQuerySuggestions), {
|
|
22549
|
+
indexName: querySuggestionsKey
|
|
22550
|
+
});
|
|
22551
|
+
}
|
|
22552
|
+
return showQuerySuggestions;
|
|
22553
|
+
}, [
|
|
22554
|
+
isFeedsMode,
|
|
22555
|
+
querySuggestionsKey,
|
|
22556
|
+
showQuerySuggestions
|
|
22557
|
+
]);
|
|
22558
|
+
var normalizedShowPromptSuggestions = React.useMemo(function() {
|
|
22559
|
+
if (!showPromptSuggestions) {
|
|
22560
|
+
return undefined;
|
|
22561
|
+
}
|
|
22562
|
+
if (isFeedsMode) {
|
|
22563
|
+
return _object_spread_props(_object_spread({}, showPromptSuggestions), {
|
|
22564
|
+
indexName: promptSuggestionsKey
|
|
22565
|
+
});
|
|
22566
|
+
}
|
|
22567
|
+
return showPromptSuggestions;
|
|
22568
|
+
}, [
|
|
22569
|
+
isFeedsMode,
|
|
22570
|
+
promptSuggestionsKey,
|
|
22571
|
+
showPromptSuggestions
|
|
22572
|
+
]);
|
|
22573
|
+
// In feeds-mode, remap `indexName := indexId` so downstream storage (which
|
|
22574
|
+
// matches on indexName) sees feedIDs instead of the composition index name
|
|
22575
|
+
// that connectAutocomplete sets from the helper results.
|
|
22576
|
+
// Must be memoized: useConnector's useStableValue runs dequal on each render
|
|
22577
|
+
// and treats a new function identity as a change, re-registering the widget.
|
|
22578
|
+
var effectiveTransformItems = React.useMemo(function() {
|
|
22579
|
+
return isFeedsMode ? function(items) {
|
|
22580
|
+
var remapped = items.map(function(item) {
|
|
22581
|
+
return _object_spread_props(_object_spread({}, item), {
|
|
22582
|
+
indexName: item.indexId
|
|
22583
|
+
});
|
|
22584
|
+
});
|
|
22585
|
+
return transformItems ? transformItems(remapped) : remapped;
|
|
22586
|
+
} : transformItems;
|
|
22587
|
+
}, [
|
|
22588
|
+
isFeedsMode,
|
|
22589
|
+
transformItems
|
|
22590
|
+
]);
|
|
22461
22591
|
var recentSearchConfig = showRecent ? {
|
|
22462
22592
|
headerComponent: (typeof showRecent === "undefined" ? "undefined" : _type_of(showRecent)) === 'object' ? showRecent.headerComponent : undefined,
|
|
22463
22593
|
itemComponent: (typeof showRecent === "undefined" ? "undefined" : _type_of(showRecent)) === 'object' && showRecent.itemComponent ? showRecent.itemComponent : AutocompleteRecentSearch,
|
|
@@ -22473,15 +22603,11 @@
|
|
|
22473
22603
|
}, [
|
|
22474
22604
|
indexRenderState
|
|
22475
22605
|
]);
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22481
|
-
indexName: index.indexName
|
|
22482
|
-
}, /*#__PURE__*/ React.createElement(Configure, index.searchParameters));
|
|
22483
|
-
}), /*#__PURE__*/ React.createElement(InnerAutocomplete, _object_spread_props(_object_spread({}, props), {
|
|
22484
|
-
aiMode: aiMode,
|
|
22606
|
+
restProps.indices; restProps.feeds; var forwardedProps = _object_without_properties(restProps, [
|
|
22607
|
+
"indices",
|
|
22608
|
+
"feeds"
|
|
22609
|
+
]);
|
|
22610
|
+
var innerAutocomplete = /*#__PURE__*/ React.createElement(InnerAutocomplete, _object_spread_props(_object_spread({}, forwardedProps), {
|
|
22485
22611
|
indicesConfig: indicesConfig,
|
|
22486
22612
|
refineSearchBox: refine,
|
|
22487
22613
|
isSearchStalled: isSearchStalled,
|
|
@@ -22489,12 +22615,33 @@
|
|
|
22489
22615
|
isSearchPage: isSearchPage,
|
|
22490
22616
|
showRecent: showRecent,
|
|
22491
22617
|
recentSearchConfig: recentSearchConfig,
|
|
22492
|
-
showQuerySuggestions:
|
|
22618
|
+
showQuerySuggestions: normalizedShowQuerySuggestions,
|
|
22493
22619
|
detachedMediaQuery: detachedMediaQuery,
|
|
22494
22620
|
translations: translations,
|
|
22495
|
-
showPromptSuggestions:
|
|
22621
|
+
showPromptSuggestions: normalizedShowPromptSuggestions,
|
|
22622
|
+
transformItems: effectiveTransformItems,
|
|
22496
22623
|
chatRenderState: indexRenderState.chat
|
|
22497
|
-
}))
|
|
22624
|
+
}));
|
|
22625
|
+
if (isFeedsMode) {
|
|
22626
|
+
return /*#__PURE__*/ React.createElement(Index, {
|
|
22627
|
+
EXPERIMENTAL_isolated: true,
|
|
22628
|
+
indexName: compositionID,
|
|
22629
|
+
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
22630
|
+
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), /*#__PURE__*/ React.createElement(Feeds, {
|
|
22631
|
+
isolated: false,
|
|
22632
|
+
renderFeed: function renderFeed() {
|
|
22633
|
+
return null;
|
|
22634
|
+
}
|
|
22635
|
+
}), innerAutocomplete);
|
|
22636
|
+
}
|
|
22637
|
+
return /*#__PURE__*/ React.createElement(Index, {
|
|
22638
|
+
EXPERIMENTAL_isolated: true
|
|
22639
|
+
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), indicesConfig.map(function(index) {
|
|
22640
|
+
return /*#__PURE__*/ React.createElement(Index, {
|
|
22641
|
+
key: index.indexName,
|
|
22642
|
+
indexName: index.indexName
|
|
22643
|
+
}, /*#__PURE__*/ React.createElement(Configure, index.searchParameters));
|
|
22644
|
+
}), innerAutocomplete);
|
|
22498
22645
|
}
|
|
22499
22646
|
function InnerAutocomplete(_0) {
|
|
22500
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, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, aiMode = _0.aiMode, props = _object_without_properties(_0, [
|
|
@@ -23119,7 +23266,8 @@
|
|
|
23119
23266
|
|
|
23120
23267
|
var ChatUiComponent = createChatComponent({
|
|
23121
23268
|
createElement: React.createElement,
|
|
23122
|
-
Fragment: React.Fragment
|
|
23269
|
+
Fragment: React.Fragment,
|
|
23270
|
+
memo: React.memo
|
|
23123
23271
|
});
|
|
23124
23272
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
23125
23273
|
var _obj;
|
|
@@ -23207,6 +23355,23 @@
|
|
|
23207
23355
|
}, [
|
|
23208
23356
|
open
|
|
23209
23357
|
]);
|
|
23358
|
+
// Keep the conversation pinned to the bottom while streaming. The stick-to-
|
|
23359
|
+
// bottom ResizeObserver only reacts to content *height* changes, but tool
|
|
23360
|
+
// results such as a horizontally-growing carousel stream in without changing
|
|
23361
|
+
// height — so we also re-pin on every message/status update. Passing
|
|
23362
|
+
// `preserveScrollPosition` reuses the existing "only if already at the
|
|
23363
|
+
// bottom" gate, so this never fights a user who has scrolled up to read.
|
|
23364
|
+
React.useEffect(function() {
|
|
23365
|
+
if (status === 'streaming' || status === 'submitted') {
|
|
23366
|
+
scrollToBottom({
|
|
23367
|
+
preserveScrollPosition: true
|
|
23368
|
+
});
|
|
23369
|
+
}
|
|
23370
|
+
}, [
|
|
23371
|
+
messages,
|
|
23372
|
+
status,
|
|
23373
|
+
scrollToBottom
|
|
23374
|
+
]);
|
|
23210
23375
|
if (error) {
|
|
23211
23376
|
throw error;
|
|
23212
23377
|
}
|