react-instantsearch 7.48.0 → 7.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/widgets/Chat.js +7 -5
- package/dist/cjs/widgets/PromptSuggestions.js +8 -1
- package/dist/cjs/widgets/chat/tools/DisplayResultsTool.js +3 -3
- package/dist/es/index.js +1 -1
- package/dist/es/widgets/Chat.d.ts +2 -2
- package/dist/es/widgets/Chat.js +7 -8
- package/dist/es/widgets/PromptSuggestions.js +8 -1
- package/dist/es/widgets/chat/tools/DisplayResultsTool.d.ts +2 -2
- package/dist/es/widgets/chat/tools/DisplayResultsTool.js +2 -2
- package/dist/es/widgets/index.js +1 -1
- package/dist/umd/ReactInstantSearch.js +392 -128
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
package/dist/cjs/widgets/Chat.js
CHANGED
|
@@ -16,6 +16,9 @@ _export(exports, {
|
|
|
16
16
|
get DisplayResultsToolType () {
|
|
17
17
|
return _chat.DisplayResultsToolType;
|
|
18
18
|
},
|
|
19
|
+
get GroupedResultsToolType () {
|
|
20
|
+
return _chat.GroupedResultsToolType;
|
|
21
|
+
},
|
|
19
22
|
get MemorizeToolType () {
|
|
20
23
|
return _chat.MemorizeToolType;
|
|
21
24
|
},
|
|
@@ -65,14 +68,14 @@ var ChatUiComponent = (0, _instantsearchuicomponents.createChatComponent)({
|
|
|
65
68
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
66
69
|
var _obj;
|
|
67
70
|
return _obj = {}, _define_property._(_obj, _chat.SearchIndexToolType, _object_spread_props._(_object_spread._({}, (0, _SearchIndexTool.createCarouselTool)(true, itemComponent, getSearchPageURL)), {
|
|
68
|
-
// The agent decides per turn whether the richer
|
|
71
|
+
// The agent decides per turn whether the richer Grouped Results tool
|
|
69
72
|
// takes over the rendering of the search results.
|
|
70
73
|
shouldRender: isDisplayResultsDisabled
|
|
71
|
-
})), _define_property._(_obj, _chat.RecommendToolType, (0, _SearchIndexTool.createCarouselTool)(false, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.DisplayResultsToolType, (0, _DisplayResultsTool.
|
|
74
|
+
})), _define_property._(_obj, _chat.RecommendToolType, (0, _SearchIndexTool.createCarouselTool)(false, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.DisplayResultsToolType, (0, _DisplayResultsTool.createGroupedResultsTool)(itemComponent)), _define_property._(_obj, _chat.GroupedResultsToolType, (0, _DisplayResultsTool.createGroupedResultsTool)(itemComponent)), _define_property._(_obj, _chat.MemorizeToolType, {}), _define_property._(_obj, _chat.MemorySearchToolType, {}), _define_property._(_obj, _chat.PonderToolType, {}), _obj;
|
|
72
75
|
}
|
|
73
76
|
/**
|
|
74
77
|
* Whether the search tool renders its own results, i.e. the agent did not hand
|
|
75
|
-
* the turn to the
|
|
78
|
+
* the turn to the Grouped Results tool. Set on the message by the backend.
|
|
76
79
|
*/ function isDisplayResultsDisabled(param) {
|
|
77
80
|
var parentMessage = param.parentMessage;
|
|
78
81
|
var _parentMessage_metadata;
|
|
@@ -203,7 +206,7 @@ function ChatInner(_0, _1) {
|
|
|
203
206
|
tools: tools,
|
|
204
207
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
205
208
|
}));
|
|
206
|
-
var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions,
|
|
209
|
+
var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
|
|
207
210
|
var sendMessageAndScrollToBottom = (0, _react.useCallback)(function() {
|
|
208
211
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
209
212
|
args[_key] = arguments[_key];
|
|
@@ -361,7 +364,6 @@ function ChatInner(_0, _1) {
|
|
|
361
364
|
}),
|
|
362
365
|
suggestionsProps: {
|
|
363
366
|
suggestions: suggestions,
|
|
364
|
-
isLoading: suggestionsStatus === 'loading',
|
|
365
367
|
onSuggestionClick: function onSuggestionClick(suggestion) {
|
|
366
368
|
sendMessageAndScrollToBottom({
|
|
367
369
|
text: suggestion
|
|
@@ -47,9 +47,16 @@ function PromptSuggestions(_0) {
|
|
|
47
47
|
}), {
|
|
48
48
|
$$widgetType: 'ais.promptSuggestions'
|
|
49
49
|
}), suggestions = _usePromptSuggestions.suggestions, isLoading = _usePromptSuggestions.isLoading, error = _usePromptSuggestions.error, onSuggestionClick = _usePromptSuggestions.onSuggestionClick, isChatBusy = _usePromptSuggestions.isChatBusy, sendToChat = _usePromptSuggestions.sendToChat;
|
|
50
|
+
if (!sendToChat && !onSuggestionClickOverride) {
|
|
51
|
+
throw new Error('No <Chat> widget is mounted on this index, so there is nothing to send a clicked suggestion to. Mount a <Chat> on the same index, or pass `onSuggestionClick` to handle the click yourself.');
|
|
52
|
+
}
|
|
50
53
|
var handleClick = onSuggestionClickOverride ? function(prompt) {
|
|
51
54
|
return onSuggestionClickOverride(prompt, {
|
|
52
|
-
sendToChat
|
|
55
|
+
// `sendToChat` is only absent when the override above owns the click,
|
|
56
|
+
// in which case falling through to the chat is a no-op.
|
|
57
|
+
sendToChat: sendToChat !== null && sendToChat !== void 0 ? sendToChat : function() {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
53
60
|
});
|
|
54
61
|
} : onSuggestionClick;
|
|
55
62
|
if (LayoutComponent) {
|
|
@@ -3,17 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "createGroupedResultsTool", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function() {
|
|
9
|
-
return
|
|
9
|
+
return createGroupedResultsTool;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
13
|
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
14
14
|
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
15
15
|
var _components = require("../../../components");
|
|
16
|
-
function
|
|
16
|
+
function createGroupedResultsTool(itemComponent) {
|
|
17
17
|
var DisplayResultsUIComponent = (0, _instantsearchuicomponents.createDisplayResultsToolComponent)({
|
|
18
18
|
createElement: _react.createElement,
|
|
19
19
|
Fragment: _react.Fragment,
|
package/dist/es/index.js
CHANGED
|
@@ -2,7 +2,7 @@ export * from 'react-instantsearch-core';
|
|
|
2
2
|
export { useStickToBottom } from './lib/useStickToBottom.js';
|
|
3
3
|
export { Autocomplete, EXPERIMENTAL_Autocomplete } from './widgets/Autocomplete.js';
|
|
4
4
|
export { Breadcrumb } from './widgets/Breadcrumb.js';
|
|
5
|
-
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
5
|
+
export { DisplayResultsToolType, GroupedResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
6
6
|
export { Chat, createDefaultTools } from './widgets/Chat.js';
|
|
7
7
|
export { PromptSuggestions } from './widgets/PromptSuggestions.js';
|
|
8
8
|
export { ChatTrigger } from './widgets/ChatTrigger.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType } from 'instantsearch.js/es/lib/chat';
|
|
1
|
+
import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType, GroupedResultsToolType } from 'instantsearch.js/es/lib/chat';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType, };
|
|
3
|
+
export { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType, GroupedResultsToolType, };
|
|
4
4
|
import type { ChatProps as ChatUiProps, ChatLayoutOwnProps, RecommendComponentProps, RecordWithObjectID, UserClientSideTool, UserClientSideTools, ChatMessageProps } from 'instantsearch-ui-components';
|
|
5
5
|
import type { IndexUiState } from 'instantsearch.js';
|
|
6
6
|
import type { UIMessage } from 'instantsearch.js/es/lib/chat';
|
package/dist/es/widgets/Chat.js
CHANGED
|
@@ -10,13 +10,13 @@ import { _ as _$9 } from '@swc/helpers/esm/_sliced_to_array.js';
|
|
|
10
10
|
import { _ as _$7 } from '@swc/helpers/esm/_to_array.js';
|
|
11
11
|
import { _ as _$a } from '@swc/helpers/esm/_to_consumable_array.js';
|
|
12
12
|
import { createChatComponent } from 'instantsearch-ui-components';
|
|
13
|
-
import { SearchIndexToolType, RecommendToolType, DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
14
|
-
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
13
|
+
import { SearchIndexToolType, RecommendToolType, DisplayResultsToolType, GroupedResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
14
|
+
export { DisplayResultsToolType, GroupedResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
15
15
|
import { getActiveContainerAnimations, holdContainerInertUntilReveal, restoreContainerInertUntilReveal, focusAfterReveal } from 'instantsearch.js/es/lib/chat/focusAfterReveal.js';
|
|
16
16
|
import React, { createElement, Fragment, useMemo, useState, useEffect, useRef, useCallback, useImperativeHandle } from 'react';
|
|
17
17
|
import { useInstantSearch, useChat } from 'react-instantsearch-core';
|
|
18
18
|
import { useStickToBottom } from '../lib/useStickToBottom.js';
|
|
19
|
-
import {
|
|
19
|
+
import { createGroupedResultsTool } from './chat/tools/DisplayResultsTool.js';
|
|
20
20
|
import { createCarouselTool } from './chat/tools/SearchIndexTool.js';
|
|
21
21
|
|
|
22
22
|
var ChatUiComponent = createChatComponent({
|
|
@@ -29,14 +29,14 @@ var ChatUiComponent = createChatComponent({
|
|
|
29
29
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
30
30
|
var _obj;
|
|
31
31
|
return _obj = {}, _$4(_obj, SearchIndexToolType, _$5(_$6({}, createCarouselTool(true, itemComponent, getSearchPageURL)), {
|
|
32
|
-
// The agent decides per turn whether the richer
|
|
32
|
+
// The agent decides per turn whether the richer Grouped Results tool
|
|
33
33
|
// takes over the rendering of the search results.
|
|
34
34
|
shouldRender: isDisplayResultsDisabled
|
|
35
|
-
})), _$4(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _$4(_obj, DisplayResultsToolType,
|
|
35
|
+
})), _$4(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _$4(_obj, DisplayResultsToolType, createGroupedResultsTool(itemComponent)), _$4(_obj, GroupedResultsToolType, createGroupedResultsTool(itemComponent)), _$4(_obj, MemorizeToolType, {}), _$4(_obj, MemorySearchToolType, {}), _$4(_obj, PonderToolType, {}), _obj;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Whether the search tool renders its own results, i.e. the agent did not hand
|
|
39
|
-
* the turn to the
|
|
39
|
+
* the turn to the Grouped Results tool. Set on the message by the backend.
|
|
40
40
|
*/ function isDisplayResultsDisabled(param) {
|
|
41
41
|
var parentMessage = param.parentMessage;
|
|
42
42
|
var _parentMessage_metadata;
|
|
@@ -167,7 +167,7 @@ function ChatInner(_0, _1) {
|
|
|
167
167
|
tools: tools,
|
|
168
168
|
disableTriggerValidation: effectiveDisableTriggerValidation
|
|
169
169
|
}));
|
|
170
|
-
var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions,
|
|
170
|
+
var messages = chatState.messages, sendMessage = chatState.sendMessage, status = chatState.status, regenerate = chatState.regenerate, stop = chatState.stop, error = chatState.error, input = chatState.input, setInput = chatState.setInput, open = chatState.open, setOpen = chatState.setOpen, clearMessages = chatState.clearMessages, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState, consumeInputFocus = chatState['~consumeInputFocus'], isOpenStatePersistenceEnabled = chatState['~isOpenStatePersistenceEnabled'];
|
|
171
171
|
var sendMessageAndScrollToBottom = useCallback(function() {
|
|
172
172
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
173
173
|
args[_key] = arguments[_key];
|
|
@@ -325,7 +325,6 @@ function ChatInner(_0, _1) {
|
|
|
325
325
|
}),
|
|
326
326
|
suggestionsProps: {
|
|
327
327
|
suggestions: suggestions,
|
|
328
|
-
isLoading: suggestionsStatus === 'loading',
|
|
329
328
|
onSuggestionClick: function onSuggestionClick(suggestion) {
|
|
330
329
|
sendMessageAndScrollToBottom({
|
|
331
330
|
text: suggestion
|
|
@@ -36,9 +36,16 @@ function PromptSuggestions(_0) {
|
|
|
36
36
|
}), {
|
|
37
37
|
$$widgetType: 'ais.promptSuggestions'
|
|
38
38
|
}), suggestions = _usePromptSuggestions.suggestions, isLoading = _usePromptSuggestions.isLoading, error = _usePromptSuggestions.error, onSuggestionClick = _usePromptSuggestions.onSuggestionClick, isChatBusy = _usePromptSuggestions.isChatBusy, sendToChat = _usePromptSuggestions.sendToChat;
|
|
39
|
+
if (!sendToChat && !onSuggestionClickOverride) {
|
|
40
|
+
throw new Error('No <Chat> widget is mounted on this index, so there is nothing to send a clicked suggestion to. Mount a <Chat> on the same index, or pass `onSuggestionClick` to handle the click yourself.');
|
|
41
|
+
}
|
|
39
42
|
var handleClick = onSuggestionClickOverride ? function(prompt) {
|
|
40
43
|
return onSuggestionClickOverride(prompt, {
|
|
41
|
-
sendToChat
|
|
44
|
+
// `sendToChat` is only absent when the override above owns the click,
|
|
45
|
+
// in which case falling through to the chat is a no-op.
|
|
46
|
+
sendToChat: sendToChat !== null && sendToChat !== void 0 ? sendToChat : function() {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
42
49
|
});
|
|
43
50
|
} : onSuggestionClick;
|
|
44
51
|
if (LayoutComponent) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { RecommendComponentProps, RecordWithObjectID, UserClientSideTool } from 'instantsearch-ui-components';
|
|
2
2
|
type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent'];
|
|
3
|
-
declare function
|
|
4
|
-
export {
|
|
3
|
+
declare function createGroupedResultsTool<TObject extends RecordWithObjectID>(itemComponent?: ItemComponent<TObject>): UserClientSideTool;
|
|
4
|
+
export { createGroupedResultsTool };
|
|
@@ -2,7 +2,7 @@ import { createDisplayResultsToolComponent, createButtonComponent, ChevronLeftIc
|
|
|
2
2
|
import React, { createElement, Fragment, useEffect, useRef } from 'react';
|
|
3
3
|
import { Carousel } from '../../../components/Carousel.js';
|
|
4
4
|
|
|
5
|
-
function
|
|
5
|
+
function createGroupedResultsTool(itemComponent) {
|
|
6
6
|
var DisplayResultsUIComponent = createDisplayResultsToolComponent({
|
|
7
7
|
createElement: createElement,
|
|
8
8
|
Fragment: Fragment,
|
|
@@ -63,4 +63,4 @@ function createDisplayResultsTool(itemComponent) {
|
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
export {
|
|
66
|
+
export { createGroupedResultsTool };
|
package/dist/es/widgets/index.js
CHANGED
|
@@ -27,4 +27,4 @@ export { ToggleRefinement } from './ToggleRefinement.js';
|
|
|
27
27
|
export { TrendingItems } from './TrendingItems.js';
|
|
28
28
|
export { TrendingFacets } from './TrendingFacets.js';
|
|
29
29
|
export { FilterSuggestions } from './FilterSuggestions.js';
|
|
30
|
-
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
30
|
+
export { DisplayResultsToolType, GroupedResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|