react-instantsearch 7.32.3 → 7.33.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/components/AutocompleteSearch.js +2 -1
- package/dist/cjs/ui/SearchBox.js +3 -1
- package/dist/cjs/widgets/Autocomplete.js +15 -17
- package/dist/cjs/widgets/SearchBox.js +8 -10
- package/dist/es/components/AutocompleteSearch.d.ts +2 -1
- package/dist/es/components/AutocompleteSearch.js +2 -1
- package/dist/es/ui/SearchBox.d.ts +2 -1
- package/dist/es/ui/SearchBox.js +3 -1
- package/dist/es/widgets/Autocomplete.js +15 -17
- package/dist/es/widgets/FilterSuggestions.d.ts +3 -0
- package/dist/es/widgets/FilterSuggestions.js +3 -1
- package/dist/es/widgets/SearchBox.d.ts +1 -1
- package/dist/es/widgets/SearchBox.js +8 -10
- package/dist/umd/ReactInstantSearch.js +101 -48
- 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.33.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.33.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.98.0';
|
|
10825
10825
|
|
|
10826
10826
|
var withUsage$q = createDocumentationMessageGenerator({
|
|
10827
10827
|
name: 'instantsearch'
|
|
@@ -12536,6 +12536,12 @@
|
|
|
12536
12536
|
}
|
|
12537
12537
|
});
|
|
12538
12538
|
/**
|
|
12539
|
+
* Regenerate the chat id. Use this to start a fresh conversation on the
|
|
12540
|
+
* server while keeping the same Chat instance and its registered listeners.
|
|
12541
|
+
*/ _define_property(this, "regenerateId", function() {
|
|
12542
|
+
_this.id = _this.generateId();
|
|
12543
|
+
});
|
|
12544
|
+
/**
|
|
12539
12545
|
* Add a tool result for a tool call.
|
|
12540
12546
|
*/ _define_property(this, "addToolResult", function(param) {
|
|
12541
12547
|
var tool = param.tool, toolCallId = param.toolCallId, output = param.output;
|
|
@@ -13412,6 +13418,41 @@
|
|
|
13412
13418
|
return Chat;
|
|
13413
13419
|
}(AbstractChat);
|
|
13414
13420
|
|
|
13421
|
+
// Centralizes the "open the chat from an entry point" behavior shared by the
|
|
13422
|
+
// SearchBox AI button, the Autocomplete AI button, prompt suggestions, and any
|
|
13423
|
+
// future entry point. The chat is always opened; the message is only sent when
|
|
13424
|
+
// it is non-empty and the chat is not already processing a message.
|
|
13425
|
+
// Returns true when a message was submitted, so callers can clear their input.
|
|
13426
|
+
function openChat(chatRenderState) {
|
|
13427
|
+
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, message = _ref.message, referer = _ref.referer;
|
|
13428
|
+
var _ref1;
|
|
13429
|
+
var _chatRenderState_setOpen;
|
|
13430
|
+
if (!chatRenderState) {
|
|
13431
|
+
return false;
|
|
13432
|
+
}
|
|
13433
|
+
(_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
|
|
13434
|
+
var trimmed = (_ref1 = message === null || message === void 0 ? void 0 : message.trim()) !== null && _ref1 !== void 0 ? _ref1 : '';
|
|
13435
|
+
if (!trimmed) {
|
|
13436
|
+
var _chatRenderState_focusInput;
|
|
13437
|
+
(_chatRenderState_focusInput = chatRenderState.focusInput) === null || _chatRenderState_focusInput === void 0 ? void 0 : _chatRenderState_focusInput.call(chatRenderState);
|
|
13438
|
+
return false;
|
|
13439
|
+
}
|
|
13440
|
+
if (isChatBusy(chatRenderState) || !chatRenderState.sendMessage) {
|
|
13441
|
+
return false;
|
|
13442
|
+
}
|
|
13443
|
+
chatRenderState.sendMessage({
|
|
13444
|
+
text: trimmed
|
|
13445
|
+
}, referer ? {
|
|
13446
|
+
headers: {
|
|
13447
|
+
'x-algolia-referer': referer
|
|
13448
|
+
}
|
|
13449
|
+
} : undefined);
|
|
13450
|
+
return true;
|
|
13451
|
+
}
|
|
13452
|
+
function isChatBusy(chatRenderState) {
|
|
13453
|
+
return (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'submitted' || (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'streaming';
|
|
13454
|
+
}
|
|
13455
|
+
|
|
13415
13456
|
var SearchIndexToolType$1 = 'algolia_search_index';
|
|
13416
13457
|
var RecommendToolType = 'algolia_recommend';
|
|
13417
13458
|
var MemorizeToolType = 'algolia_memorize';
|
|
@@ -13707,12 +13748,14 @@
|
|
|
13707
13748
|
var onClearTransitionEnd = function onClearTransitionEnd() {
|
|
13708
13749
|
setMessages([]);
|
|
13709
13750
|
_chatInstance.clearError();
|
|
13751
|
+
_chatInstance.regenerateId();
|
|
13710
13752
|
feedbackState = {};
|
|
13711
13753
|
setIsClearing(false);
|
|
13712
13754
|
};
|
|
13713
13755
|
var makeChatInstance = function makeChatInstance(instantSearchInstance) {
|
|
13714
13756
|
var transport;
|
|
13715
|
-
var
|
|
13757
|
+
var client = instantSearchInstance.client;
|
|
13758
|
+
var _getAppIdAndApiKey = _sliced_to_array(getAppIdAndApiKey(client), 2), appId = _getAppIdAndApiKey[0], apiKey = _getAppIdAndApiKey[1];
|
|
13716
13759
|
// Filter out custom data parts (like data-suggestions) that the backend doesn't accept
|
|
13717
13760
|
var filterDataParts = function filterDataParts(messages) {
|
|
13718
13761
|
return messages.map(function(message) {
|
|
@@ -13729,9 +13772,16 @@
|
|
|
13729
13772
|
transport = new DefaultChatTransport(_object_spread_props(_object_spread({}, options.transport), {
|
|
13730
13773
|
prepareSendMessagesRequest: function prepareSendMessagesRequest(params) {
|
|
13731
13774
|
// Call the original prepareSendMessagesRequest if it exists,
|
|
13732
|
-
// otherwise construct
|
|
13775
|
+
// otherwise construct a minimal default body containing only the
|
|
13776
|
+
// request payload — without leaking transport metadata such as
|
|
13777
|
+
// resolved headers, api URL, credentials, or `requestMetadata`.
|
|
13733
13778
|
var preparedOrPromise = originalPrepare ? originalPrepare(params) : {
|
|
13734
|
-
body: _object_spread({
|
|
13779
|
+
body: _object_spread({
|
|
13780
|
+
id: params.id,
|
|
13781
|
+
messageId: params.messageId,
|
|
13782
|
+
trigger: params.trigger,
|
|
13783
|
+
messages: params.messages
|
|
13784
|
+
}, params.body)
|
|
13735
13785
|
};
|
|
13736
13786
|
// Then filter out data-* parts
|
|
13737
13787
|
var applyFilter = function applyFilter(prepared) {
|
|
@@ -13758,20 +13808,19 @@
|
|
|
13758
13808
|
api: baseApi,
|
|
13759
13809
|
headers: {
|
|
13760
13810
|
'x-algolia-application-id': appId,
|
|
13761
|
-
'x-algolia-api-
|
|
13762
|
-
'x-algolia-agent': getAlgoliaAgent(
|
|
13811
|
+
'x-algolia-api-key': apiKey,
|
|
13812
|
+
'x-algolia-agent': "".concat(getAlgoliaAgent(client), "; chat")
|
|
13763
13813
|
},
|
|
13764
|
-
prepareSendMessagesRequest: function prepareSendMessagesRequest(
|
|
13765
|
-
var messages =
|
|
13766
|
-
"messages",
|
|
13767
|
-
"trigger"
|
|
13768
|
-
]);
|
|
13814
|
+
prepareSendMessagesRequest: function prepareSendMessagesRequest(param) {
|
|
13815
|
+
var id = param.id, messages = param.messages, trigger = param.trigger, messageId = param.messageId;
|
|
13769
13816
|
return {
|
|
13770
13817
|
// Bypass cache when regenerating to ensure fresh responses
|
|
13771
13818
|
api: trigger === 'regenerate-message' ? "".concat(baseApi, "&cache=false") : baseApi,
|
|
13772
|
-
body:
|
|
13819
|
+
body: {
|
|
13820
|
+
id: id,
|
|
13821
|
+
messageId: messageId,
|
|
13773
13822
|
messages: filterDataParts(messages)
|
|
13774
|
-
}
|
|
13823
|
+
}
|
|
13775
13824
|
};
|
|
13776
13825
|
}
|
|
13777
13826
|
});
|
|
@@ -17565,7 +17614,9 @@
|
|
|
17565
17614
|
name: 'filter-suggestions',
|
|
17566
17615
|
connector: true
|
|
17567
17616
|
});
|
|
17568
|
-
|
|
17617
|
+
/**
|
|
17618
|
+
* @deprecated Filter suggestions are deprecated and will be removed in a future major version.
|
|
17619
|
+
*/ var connectFilterSuggestions = function connectFilterSuggestions(renderFn) {
|
|
17569
17620
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
17570
17621
|
checkRendering(renderFn, withUsage());
|
|
17571
17622
|
return function(widgetParams) {
|
|
@@ -17777,7 +17828,9 @@
|
|
|
17777
17828
|
};
|
|
17778
17829
|
};
|
|
17779
17830
|
|
|
17780
|
-
|
|
17831
|
+
/**
|
|
17832
|
+
* @deprecated Filter suggestions are deprecated and will be removed in a future major version.
|
|
17833
|
+
*/ function useFilterSuggestions(props, additionalWidgetProperties) {
|
|
17781
17834
|
return useConnector(connectFilterSuggestions, props, additionalWidgetProperties);
|
|
17782
17835
|
}
|
|
17783
17836
|
|
|
@@ -18804,7 +18857,7 @@
|
|
|
18804
18857
|
function createAutocompleteSearchComponent(param) {
|
|
18805
18858
|
var createElement = param.createElement;
|
|
18806
18859
|
return function AutocompleteSearch(userProps) {
|
|
18807
|
-
var inputProps = userProps.inputProps, onClear = userProps.onClear, query = userProps.query, isSearchStalled = userProps.isSearchStalled, onCancel = userProps.onCancel, isDetached = userProps.isDetached, submitTitle = userProps.submitTitle, onAiModeClick = userProps.onAiModeClick, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
|
|
18860
|
+
var inputProps = userProps.inputProps, onClear = userProps.onClear, query = userProps.query, isSearchStalled = userProps.isSearchStalled, onCancel = userProps.onCancel, isDetached = userProps.isDetached, submitTitle = userProps.submitTitle, onAiModeClick = userProps.onAiModeClick, _userProps_aiModeButtonDisabled = userProps.aiModeButtonDisabled, aiModeButtonDisabled = _userProps_aiModeButtonDisabled === void 0 ? false : _userProps_aiModeButtonDisabled, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
|
|
18808
18861
|
var isBackButton = Boolean(isDetached && onCancel);
|
|
18809
18862
|
var resolvedCancelTitle = submitTitle !== null && submitTitle !== void 0 ? submitTitle : 'Close';
|
|
18810
18863
|
var inputRef = inputProps.ref;
|
|
@@ -18881,6 +18934,7 @@
|
|
|
18881
18934
|
className: cx('ais-AiModeButton', classNames.aiModeButton),
|
|
18882
18935
|
type: "button",
|
|
18883
18936
|
title: "AI Mode",
|
|
18937
|
+
disabled: aiModeButtonDisabled,
|
|
18884
18938
|
onClick: function onClick(e) {
|
|
18885
18939
|
e.preventDefault();
|
|
18886
18940
|
onAiModeClick();
|
|
@@ -21696,7 +21750,7 @@
|
|
|
21696
21750
|
Fragment: React.Fragment
|
|
21697
21751
|
});
|
|
21698
21752
|
function AutocompleteSearch(param) {
|
|
21699
|
-
var inputProps = param.inputProps, clearQuery = param.clearQuery, onQueryChange = param.onQueryChange, query = param.query, isSearchStalled = param.isSearchStalled, onCancel = param.onCancel, isDetached = param.isDetached, submitTitle = param.submitTitle, onAiModeClick = param.onAiModeClick, classNames = param.classNames;
|
|
21753
|
+
var inputProps = param.inputProps, clearQuery = param.clearQuery, onQueryChange = param.onQueryChange, query = param.query, isSearchStalled = param.isSearchStalled, onCancel = param.onCancel, isDetached = param.isDetached, submitTitle = param.submitTitle, onAiModeClick = param.onAiModeClick, aiModeButtonDisabled = param.aiModeButtonDisabled, classNames = param.classNames;
|
|
21700
21754
|
return /*#__PURE__*/ React.createElement(AutocompleteSearchComponent, {
|
|
21701
21755
|
inputProps: _object_spread_props(_object_spread({}, inputProps), {
|
|
21702
21756
|
onChange: function onChange(event) {
|
|
@@ -21711,6 +21765,7 @@
|
|
|
21711
21765
|
isDetached: isDetached,
|
|
21712
21766
|
submitTitle: submitTitle,
|
|
21713
21767
|
onAiModeClick: onAiModeClick,
|
|
21768
|
+
aiModeButtonDisabled: aiModeButtonDisabled,
|
|
21714
21769
|
classNames: classNames
|
|
21715
21770
|
});
|
|
21716
21771
|
}
|
|
@@ -22207,14 +22262,13 @@
|
|
|
22207
22262
|
onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function(param) {
|
|
22208
22263
|
var item = param.item, query = param.query, setQuery = param.setQuery, url = param.url;
|
|
22209
22264
|
if (isPromptSuggestion(item)) {
|
|
22210
|
-
|
|
22211
|
-
|
|
22212
|
-
|
|
22213
|
-
|
|
22214
|
-
|
|
22215
|
-
|
|
22216
|
-
|
|
22217
|
-
});
|
|
22265
|
+
if (chatRenderState) {
|
|
22266
|
+
if (openChat(chatRenderState, {
|
|
22267
|
+
message: item.prompt,
|
|
22268
|
+
referer: 'prompt-suggestions'
|
|
22269
|
+
})) {
|
|
22270
|
+
setQuery('');
|
|
22271
|
+
}
|
|
22218
22272
|
return;
|
|
22219
22273
|
}
|
|
22220
22274
|
if ((showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName) && !hasWarnedMissingPromptSuggestionsChatRef.current) {
|
|
@@ -22354,17 +22408,15 @@
|
|
|
22354
22408
|
if (isDetached) {
|
|
22355
22409
|
setIsModalOpen(false);
|
|
22356
22410
|
}
|
|
22357
|
-
if (chatRenderState
|
|
22358
|
-
|
|
22359
|
-
|
|
22360
|
-
|
|
22361
|
-
|
|
22362
|
-
|
|
22363
|
-
text: resolvedQuery
|
|
22364
|
-
});
|
|
22365
|
-
}
|
|
22411
|
+
if (openChat(chatRenderState, {
|
|
22412
|
+
message: resolvedQuery,
|
|
22413
|
+
referer: 'ai-mode'
|
|
22414
|
+
})) {
|
|
22415
|
+
refineSearchBox('');
|
|
22416
|
+
refineAutocomplete('');
|
|
22366
22417
|
}
|
|
22367
22418
|
} : undefined,
|
|
22419
|
+
aiModeButtonDisabled: aiMode ? isChatBusy(chatRenderState) : undefined,
|
|
22368
22420
|
classNames: classNames
|
|
22369
22421
|
});
|
|
22370
22422
|
var panelContent = /*#__PURE__*/ React.createElement(AutocompletePanel, _object_spread_props(_object_spread({}, getPanelProps()), {
|
|
@@ -24013,7 +24065,7 @@
|
|
|
24013
24065
|
}));
|
|
24014
24066
|
}
|
|
24015
24067
|
function SearchBox$1(_0) {
|
|
24016
|
-
var formRef = _0.formRef, inputRef = _0.inputRef, inputProps = _0.inputProps, isSearchStalled = _0.isSearchStalled, onChange = _0.onChange, onReset = _0.onReset, onSubmit = _0.onSubmit, _0_placeholder = _0.placeholder, placeholder = _0_placeholder === void 0 ? '' : _0_placeholder, value = _0.value, autoFocus = _0.autoFocus, tmp = _0.resetIconComponent, ResetIcon = tmp === void 0 ? DefaultResetIcon : tmp, tmp1 = _0.submitIconComponent, SubmitIcon = tmp1 === void 0 ? DefaultSubmitIcon : tmp1, tmp2 = _0.loadingIconComponent, LoadingIcon = tmp2 === void 0 ? DefaultLoadingIcon : tmp2, tmp3 = _0.aiModeIconComponent, AiModeIcon = tmp3 === void 0 ? DefaultAiModeIcon : tmp3, onAiModeClick = _0.onAiModeClick, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _object_without_properties(_0, [
|
|
24068
|
+
var formRef = _0.formRef, inputRef = _0.inputRef, inputProps = _0.inputProps, isSearchStalled = _0.isSearchStalled, onChange = _0.onChange, onReset = _0.onReset, onSubmit = _0.onSubmit, _0_placeholder = _0.placeholder, placeholder = _0_placeholder === void 0 ? '' : _0_placeholder, value = _0.value, autoFocus = _0.autoFocus, tmp = _0.resetIconComponent, ResetIcon = tmp === void 0 ? DefaultResetIcon : tmp, tmp1 = _0.submitIconComponent, SubmitIcon = tmp1 === void 0 ? DefaultSubmitIcon : tmp1, tmp2 = _0.loadingIconComponent, LoadingIcon = tmp2 === void 0 ? DefaultLoadingIcon : tmp2, tmp3 = _0.aiModeIconComponent, AiModeIcon = tmp3 === void 0 ? DefaultAiModeIcon : tmp3, onAiModeClick = _0.onAiModeClick, _0_aiModeButtonDisabled = _0.aiModeButtonDisabled, aiModeButtonDisabled = _0_aiModeButtonDisabled === void 0 ? false : _0_aiModeButtonDisabled, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _object_without_properties(_0, [
|
|
24017
24069
|
"formRef",
|
|
24018
24070
|
"inputRef",
|
|
24019
24071
|
"inputProps",
|
|
@@ -24029,6 +24081,7 @@
|
|
|
24029
24081
|
"loadingIconComponent",
|
|
24030
24082
|
"aiModeIconComponent",
|
|
24031
24083
|
"onAiModeClick",
|
|
24084
|
+
"aiModeButtonDisabled",
|
|
24032
24085
|
"classNames",
|
|
24033
24086
|
"translations"
|
|
24034
24087
|
]);
|
|
@@ -24092,6 +24145,7 @@
|
|
|
24092
24145
|
className: cx('ais-AiModeButton', classNames.aiModeButton),
|
|
24093
24146
|
type: "button",
|
|
24094
24147
|
title: translations.aiModeButtonTitle || 'AI Mode',
|
|
24148
|
+
disabled: aiModeButtonDisabled,
|
|
24095
24149
|
onClick: function onClick(e) {
|
|
24096
24150
|
e.preventDefault();
|
|
24097
24151
|
onAiModeClick();
|
|
@@ -24310,6 +24364,7 @@
|
|
|
24310
24364
|
if (query !== inputValue && document.activeElement !== inputRef.current) {
|
|
24311
24365
|
setInputValue(query);
|
|
24312
24366
|
}
|
|
24367
|
+
var chatRenderState = indexRenderState.chat;
|
|
24313
24368
|
var uiProps = {
|
|
24314
24369
|
inputRef: inputRef,
|
|
24315
24370
|
isSearchStalled: isSearchStalled,
|
|
@@ -24317,18 +24372,14 @@
|
|
|
24317
24372
|
onReset: onReset,
|
|
24318
24373
|
onSubmit: onSubmit,
|
|
24319
24374
|
onAiModeClick: aiMode ? function() {
|
|
24320
|
-
|
|
24321
|
-
|
|
24322
|
-
|
|
24323
|
-
|
|
24324
|
-
|
|
24325
|
-
var _chatRenderState_sendMessage;
|
|
24326
|
-
(_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
|
|
24327
|
-
text: inputValue
|
|
24328
|
-
});
|
|
24329
|
-
}
|
|
24375
|
+
if (openChat(chatRenderState, {
|
|
24376
|
+
message: inputValue,
|
|
24377
|
+
referer: 'ai-mode'
|
|
24378
|
+
})) {
|
|
24379
|
+
onReset();
|
|
24330
24380
|
}
|
|
24331
24381
|
} : undefined,
|
|
24382
|
+
aiModeButtonDisabled: aiMode ? isChatBusy(chatRenderState) : undefined,
|
|
24332
24383
|
value: inputValue,
|
|
24333
24384
|
translations: _object_spread({
|
|
24334
24385
|
submitButtonTitle: 'Submit the search query',
|
|
@@ -24646,7 +24697,9 @@
|
|
|
24646
24697
|
createElement: React.createElement,
|
|
24647
24698
|
Fragment: React.Fragment
|
|
24648
24699
|
});
|
|
24649
|
-
|
|
24700
|
+
/**
|
|
24701
|
+
* @deprecated Filter suggestions are deprecated and will be removed in a future major version.
|
|
24702
|
+
*/ function FilterSuggestions(_0) {
|
|
24650
24703
|
var agentId = _0.agentId, attributes = _0.attributes, maxSuggestions = _0.maxSuggestions, debounceMs = _0.debounceMs, hitsToSample = _0.hitsToSample, transformItems = _0.transformItems, itemComponent = _0.itemComponent, headerComponent = _0.headerComponent, emptyComponent = _0.emptyComponent, transport = _0.transport, props = _object_without_properties(_0, [
|
|
24651
24704
|
"agentId",
|
|
24652
24705
|
"attributes",
|