react-instantsearch 7.30.0 → 7.32.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 +4 -1
- package/dist/cjs/components/ChatMessageLoader.js +16 -0
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/widgets/Autocomplete.js +19 -11
- package/dist/cjs/widgets/Chat.js +8 -4
- package/dist/cjs/widgets/chat/tools/DisplayResultsTool.js +69 -0
- package/dist/es/components/AutocompleteSearch.d.ts +4 -1
- package/dist/es/components/AutocompleteSearch.js +4 -1
- package/dist/es/components/ChatMessageLoader.d.ts +1 -0
- package/dist/es/components/ChatMessageLoader.js +8 -0
- package/dist/es/components/index.d.ts +1 -0
- package/dist/es/components/index.js +1 -0
- package/dist/es/index.js +2 -1
- package/dist/es/widgets/Autocomplete.js +19 -11
- package/dist/es/widgets/Chat.d.ts +3 -3
- package/dist/es/widgets/Chat.js +7 -6
- package/dist/es/widgets/chat/tools/DisplayResultsTool.d.ts +4 -0
- package/dist/es/widgets/chat/tools/DisplayResultsTool.js +60 -0
- package/dist/es/widgets/index.js +1 -1
- package/dist/umd/ReactInstantSearch.js +2733 -1875
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
|
@@ -19,7 +19,7 @@ var AutocompleteSearchComponent = (0, _instantsearchuicomponents.createAutocompl
|
|
|
19
19
|
Fragment: _react.Fragment
|
|
20
20
|
});
|
|
21
21
|
function AutocompleteSearch(param) {
|
|
22
|
-
var inputProps = param.inputProps, clearQuery = param.clearQuery, onQueryChange = param.onQueryChange, query = param.query, isSearchStalled = param.isSearchStalled, onAiModeClick = param.onAiModeClick;
|
|
22
|
+
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;
|
|
23
23
|
return /*#__PURE__*/ _react.default.createElement(AutocompleteSearchComponent, {
|
|
24
24
|
inputProps: _object_spread_props._(_object_spread._({}, inputProps), {
|
|
25
25
|
onChange: function onChange(event) {
|
|
@@ -30,6 +30,9 @@ function AutocompleteSearch(param) {
|
|
|
30
30
|
onClear: clearQuery,
|
|
31
31
|
query: query,
|
|
32
32
|
isSearchStalled: isSearchStalled,
|
|
33
|
+
onCancel: onCancel,
|
|
34
|
+
isDetached: isDetached,
|
|
35
|
+
submitTitle: submitTitle,
|
|
33
36
|
onAiModeClick: onAiModeClick
|
|
34
37
|
});
|
|
35
38
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ChatMessageLoader", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return ChatMessageLoader;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var ChatMessageLoader = (0, _instantsearchuicomponents.createChatMessageLoaderComponent)({
|
|
15
|
+
createElement: _react.createElement
|
|
16
|
+
});
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
var _export_star = require("@swc/helpers/_/_export_star");
|
|
7
7
|
_export_star._(require("./Carousel"), exports);
|
|
8
|
+
_export_star._(require("./ChatMessageLoader"), exports);
|
|
8
9
|
_export_star._(require("./ChatOverlayLayout"), exports);
|
|
9
10
|
_export_star._(require("./ChatInlineLayout"), exports);
|
|
10
11
|
_export_star._(require("./ChatSidePanelLayout"), exports);
|
|
@@ -515,7 +515,7 @@ function InnerAutocomplete(_0) {
|
|
|
515
515
|
});
|
|
516
516
|
}
|
|
517
517
|
indicesForPanel.forEach(function(param) {
|
|
518
|
-
var indexId = param.indexId, indexName = param.indexName, hits = param.hits;
|
|
518
|
+
var indexId = param.indexId, indexName = param.indexName, hits = param.hits, sendEvent = param.sendEvent;
|
|
519
519
|
var elementId = indexName;
|
|
520
520
|
if (indexName === (showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName)) {
|
|
521
521
|
elementId = 'suggestions';
|
|
@@ -541,9 +541,14 @@ function InnerAutocomplete(_0) {
|
|
|
541
541
|
});
|
|
542
542
|
}),
|
|
543
543
|
getItemProps: getItemProps,
|
|
544
|
+
sendEvent: sendEvent,
|
|
544
545
|
classNames: currentIndexConfig.classNames
|
|
545
546
|
});
|
|
546
547
|
});
|
|
548
|
+
var handleCancel = function handleCancel() {
|
|
549
|
+
setIsModalOpen(false);
|
|
550
|
+
setIsOpen(false);
|
|
551
|
+
};
|
|
547
552
|
var searchBoxContent = /*#__PURE__*/ _react.default.createElement(_AutocompleteSearch.AutocompleteSearch, {
|
|
548
553
|
inputProps: getInputProps(),
|
|
549
554
|
clearQuery: function clearQuery() {
|
|
@@ -555,7 +560,18 @@ function InnerAutocomplete(_0) {
|
|
|
555
560
|
},
|
|
556
561
|
query: resolvedQuery,
|
|
557
562
|
isSearchStalled: isSearchStalled,
|
|
563
|
+
onCancel: function onCancel() {
|
|
564
|
+
if (isDetached) {
|
|
565
|
+
handleCancel();
|
|
566
|
+
}
|
|
567
|
+
},
|
|
568
|
+
isDetached: isDetached,
|
|
569
|
+
submitTitle: isDetached ? translations.detachedCancelButtonText : undefined,
|
|
558
570
|
onAiModeClick: aiMode ? function() {
|
|
571
|
+
setIsOpen(false);
|
|
572
|
+
if (isDetached) {
|
|
573
|
+
setIsModalOpen(false);
|
|
574
|
+
}
|
|
559
575
|
if (chatRenderState) {
|
|
560
576
|
var _chatRenderState_setOpen;
|
|
561
577
|
(_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
|
|
@@ -599,19 +615,11 @@ function InnerAutocomplete(_0) {
|
|
|
599
615
|
translations: translations
|
|
600
616
|
}), isModalOpen && /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedOverlay, {
|
|
601
617
|
classNames: classNames,
|
|
602
|
-
onClose:
|
|
603
|
-
setIsModalOpen(false);
|
|
604
|
-
setIsOpen(false);
|
|
605
|
-
}
|
|
618
|
+
onClose: handleCancel
|
|
606
619
|
}, /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedContainer, {
|
|
607
620
|
classNames: detachedContainerClassNames
|
|
608
621
|
}, /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedFormContainer, {
|
|
609
|
-
classNames: classNames
|
|
610
|
-
onCancel: function onCancel() {
|
|
611
|
-
setIsModalOpen(false);
|
|
612
|
-
setIsOpen(false);
|
|
613
|
-
},
|
|
614
|
-
translations: translations
|
|
622
|
+
classNames: classNames
|
|
615
623
|
}, searchBoxContent), panelContent)));
|
|
616
624
|
}
|
|
617
625
|
// Normal (non-detached) rendering
|
package/dist/cjs/widgets/Chat.js
CHANGED
|
@@ -13,6 +13,9 @@ _export(exports, {
|
|
|
13
13
|
get Chat () {
|
|
14
14
|
return Chat;
|
|
15
15
|
},
|
|
16
|
+
get DisplayResultsToolType () {
|
|
17
|
+
return _chat.DisplayResultsToolType;
|
|
18
|
+
},
|
|
16
19
|
get MemorizeToolType () {
|
|
17
20
|
return _chat.MemorizeToolType;
|
|
18
21
|
},
|
|
@@ -44,6 +47,7 @@ var _chat = require("instantsearch.js/cjs/lib/chat");
|
|
|
44
47
|
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
45
48
|
var _reactinstantsearchcore = require("react-instantsearch-core");
|
|
46
49
|
var _useStickToBottom = require("../lib/useStickToBottom");
|
|
50
|
+
var _DisplayResultsTool = require("./chat/tools/DisplayResultsTool");
|
|
47
51
|
var _SearchIndexTool = require("./chat/tools/SearchIndexTool");
|
|
48
52
|
var ChatUiComponent = (0, _instantsearchuicomponents.createChatComponent)({
|
|
49
53
|
createElement: _react.createElement,
|
|
@@ -51,13 +55,13 @@ var ChatUiComponent = (0, _instantsearchuicomponents.createChatComponent)({
|
|
|
51
55
|
});
|
|
52
56
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
53
57
|
var _obj;
|
|
54
|
-
return _obj = {}, _define_property._(_obj, _chat.SearchIndexToolType, (0, _SearchIndexTool.createCarouselTool)(true, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.RecommendToolType, (0, _SearchIndexTool.createCarouselTool)(false, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.MemorizeToolType, {}), _define_property._(_obj, _chat.MemorySearchToolType, {}), _define_property._(_obj, _chat.PonderToolType, {}), _obj;
|
|
58
|
+
return _obj = {}, _define_property._(_obj, _chat.SearchIndexToolType, (0, _SearchIndexTool.createCarouselTool)(true, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.RecommendToolType, (0, _SearchIndexTool.createCarouselTool)(false, itemComponent, getSearchPageURL)), _define_property._(_obj, _chat.DisplayResultsToolType, (0, _DisplayResultsTool.createDisplayResultsTool)(itemComponent)), _define_property._(_obj, _chat.MemorizeToolType, {}), _define_property._(_obj, _chat.MemorySearchToolType, {}), _define_property._(_obj, _chat.PonderToolType, {}), _obj;
|
|
55
59
|
}
|
|
56
60
|
function ChatInner(_0, _1) {
|
|
57
61
|
var _ref = [
|
|
58
62
|
_0,
|
|
59
63
|
_1
|
|
60
|
-
], _ref1 = _to_array._(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, toggleButtonProps = _ref2.toggleButtonProps, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, toggleButtonComponent = _ref2.toggleButtonComponent, toggleButtonIconComponent = _ref2.toggleButtonIconComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent,
|
|
64
|
+
], _ref1 = _to_array._(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, toggleButtonProps = _ref2.toggleButtonProps, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, toggleButtonComponent = _ref2.toggleButtonComponent, toggleButtonIconComponent = _ref2.toggleButtonIconComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, loaderComponent = _ref2.loaderComponent, messagesErrorComponent = _ref2.messagesErrorComponent, promptComponent = _ref2.promptComponent, promptHeaderComponent = _ref2.promptHeaderComponent, promptFooterComponent = _ref2.promptFooterComponent, assistantMessageLeadingComponent = _ref2.assistantMessageLeadingComponent, assistantMessageFooterComponent = _ref2.assistantMessageFooterComponent, userMessageLeadingComponent = _ref2.userMessageLeadingComponent, userMessageFooterComponent = _ref2.userMessageFooterComponent, emptyComponent = _ref2.emptyComponent, actionsComponent = _ref2.actionsComponent, suggestionsComponent = _ref2.suggestionsComponent, classNames = _ref2.classNames, _ref_translations = _ref2.translations, translations = _ref_translations === void 0 ? {} : _ref_translations, title = _ref2.title, getSearchPageURL = _ref2.getSearchPageURL, props = _object_without_properties._(_ref2, [
|
|
61
65
|
"tools",
|
|
62
66
|
"toggleButtonProps",
|
|
63
67
|
"headerProps",
|
|
@@ -72,7 +76,7 @@ function ChatInner(_0, _1) {
|
|
|
72
76
|
"headerCloseIconComponent",
|
|
73
77
|
"headerMinimizeIconComponent",
|
|
74
78
|
"headerMaximizeIconComponent",
|
|
75
|
-
"
|
|
79
|
+
"loaderComponent",
|
|
76
80
|
"messagesErrorComponent",
|
|
77
81
|
"promptComponent",
|
|
78
82
|
"promptHeaderComponent",
|
|
@@ -191,7 +195,7 @@ function ChatInner(_0, _1) {
|
|
|
191
195
|
scrollRef: scrollRef,
|
|
192
196
|
contentRef: contentRef,
|
|
193
197
|
onScrollToBottom: scrollToBottom,
|
|
194
|
-
loaderComponent:
|
|
198
|
+
loaderComponent: loaderComponent,
|
|
195
199
|
errorComponent: messagesErrorComponent,
|
|
196
200
|
emptyComponent: emptyComponent,
|
|
197
201
|
actionsComponent: actionsComponent,
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "createDisplayResultsTool", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return createDisplayResultsTool;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
14
|
+
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
15
|
+
var _components = require("../../../components");
|
|
16
|
+
function createDisplayResultsTool(itemComponent) {
|
|
17
|
+
var DisplayResultsUIComponent = (0, _instantsearchuicomponents.createDisplayResultsToolComponent)({
|
|
18
|
+
createElement: _react.createElement,
|
|
19
|
+
Fragment: _react.Fragment
|
|
20
|
+
});
|
|
21
|
+
var Button = (0, _instantsearchuicomponents.createButtonComponent)({
|
|
22
|
+
createElement: _react.createElement
|
|
23
|
+
});
|
|
24
|
+
var DisplayResultsLayoutComponent = function DisplayResultsLayoutComponent(toolProps) {
|
|
25
|
+
return /*#__PURE__*/ _react.default.createElement(DisplayResultsUIComponent, {
|
|
26
|
+
toolProps: toolProps,
|
|
27
|
+
groupCarouselComponent: function groupCarouselComponent(param) {
|
|
28
|
+
var items = param.items, sendEvent = param.sendEvent;
|
|
29
|
+
return /*#__PURE__*/ _react.default.createElement(_components.Carousel, {
|
|
30
|
+
items: items,
|
|
31
|
+
itemComponent: itemComponent,
|
|
32
|
+
sendEvent: sendEvent,
|
|
33
|
+
showNavigation: false,
|
|
34
|
+
headerComponent: function headerComponent(param) {
|
|
35
|
+
var canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight;
|
|
36
|
+
return /*#__PURE__*/ _react.default.createElement("div", {
|
|
37
|
+
className: "ais-ChatToolDisplayResultsCarouselHeader"
|
|
38
|
+
}, /*#__PURE__*/ _react.default.createElement("div", {
|
|
39
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderCount"
|
|
40
|
+
}, items.length, " result", items.length > 1 ? 's' : ''), /*#__PURE__*/ _react.default.createElement("div", {
|
|
41
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButtons"
|
|
42
|
+
}, /*#__PURE__*/ _react.default.createElement(Button, {
|
|
43
|
+
variant: "outline",
|
|
44
|
+
size: "sm",
|
|
45
|
+
iconOnly: true,
|
|
46
|
+
onClick: scrollLeft,
|
|
47
|
+
disabled: !canScrollLeft,
|
|
48
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
|
|
49
|
+
}, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronLeftIcon, {
|
|
50
|
+
createElement: _react.createElement
|
|
51
|
+
})), /*#__PURE__*/ _react.default.createElement(Button, {
|
|
52
|
+
variant: "outline",
|
|
53
|
+
size: "sm",
|
|
54
|
+
iconOnly: true,
|
|
55
|
+
onClick: scrollRight,
|
|
56
|
+
disabled: !canScrollRight,
|
|
57
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
|
|
58
|
+
}, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronRightIcon, {
|
|
59
|
+
createElement: _react.createElement
|
|
60
|
+
}))));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
return {
|
|
67
|
+
layoutComponent: DisplayResultsLayoutComponent
|
|
68
|
+
};
|
|
69
|
+
}
|
|
@@ -6,6 +6,9 @@ export type AutocompleteSearchProps = {
|
|
|
6
6
|
onQueryChange?: (query: string) => void;
|
|
7
7
|
query: string;
|
|
8
8
|
isSearchStalled: boolean;
|
|
9
|
+
onCancel?: () => void;
|
|
10
|
+
isDetached?: boolean;
|
|
11
|
+
submitTitle?: string;
|
|
9
12
|
onAiModeClick?: () => void;
|
|
10
13
|
};
|
|
11
|
-
export declare function AutocompleteSearch({ inputProps, clearQuery, onQueryChange, query, isSearchStalled, onAiModeClick, }: AutocompleteSearchProps): React.JSX.Element;
|
|
14
|
+
export declare function AutocompleteSearch({ inputProps, clearQuery, onQueryChange, query, isSearchStalled, onCancel, isDetached, submitTitle, onAiModeClick, }: AutocompleteSearchProps): React.JSX.Element;
|
|
@@ -8,7 +8,7 @@ var AutocompleteSearchComponent = createAutocompleteSearchComponent({
|
|
|
8
8
|
Fragment: Fragment
|
|
9
9
|
});
|
|
10
10
|
function AutocompleteSearch(param) {
|
|
11
|
-
var inputProps = param.inputProps, clearQuery = param.clearQuery, onQueryChange = param.onQueryChange, query = param.query, isSearchStalled = param.isSearchStalled, onAiModeClick = param.onAiModeClick;
|
|
11
|
+
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;
|
|
12
12
|
return /*#__PURE__*/ React.createElement(AutocompleteSearchComponent, {
|
|
13
13
|
inputProps: _(_$1({}, inputProps), {
|
|
14
14
|
onChange: function onChange(event) {
|
|
@@ -19,6 +19,9 @@ function AutocompleteSearch(param) {
|
|
|
19
19
|
onClear: clearQuery,
|
|
20
20
|
query: query,
|
|
21
21
|
isSearchStalled: isSearchStalled,
|
|
22
|
+
onCancel: onCancel,
|
|
23
|
+
isDetached: isDetached,
|
|
24
|
+
submitTitle: submitTitle,
|
|
22
25
|
onAiModeClick: onAiModeClick
|
|
23
26
|
});
|
|
24
27
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ChatMessageLoader: (userProps: import("instantsearch-ui-components").ChatMessageLoaderProps) => JSX.Element;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { Carousel } from './Carousel.js';
|
|
2
|
+
export { ChatMessageLoader } from './ChatMessageLoader.js';
|
|
2
3
|
export { ChatOverlayLayout } from './ChatOverlayLayout.js';
|
|
3
4
|
export { ChatInlineLayout } from './ChatInlineLayout.js';
|
|
4
5
|
export { ChatSidePanelLayout } from './ChatSidePanelLayout.js';
|
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 { EXPERIMENTAL_Autocomplete } from './widgets/Autocomplete.js';
|
|
4
4
|
export { Breadcrumb } from './widgets/Breadcrumb.js';
|
|
5
|
-
export { MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
5
|
+
export { DisplayResultsToolType, 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 { ClearRefinements } from './widgets/ClearRefinements.js';
|
|
8
8
|
export { CurrentRefinements } from './widgets/CurrentRefinements.js';
|
|
@@ -29,6 +29,7 @@ export { TrendingItems } from './widgets/TrendingItems.js';
|
|
|
29
29
|
export { TrendingFacets } from './widgets/TrendingFacets.js';
|
|
30
30
|
export { FilterSuggestions } from './widgets/FilterSuggestions.js';
|
|
31
31
|
export { Carousel } from './components/Carousel.js';
|
|
32
|
+
export { ChatMessageLoader } from './components/ChatMessageLoader.js';
|
|
32
33
|
export { ChatOverlayLayout } from './components/ChatOverlayLayout.js';
|
|
33
34
|
export { ChatInlineLayout } from './components/ChatInlineLayout.js';
|
|
34
35
|
export { ChatSidePanelLayout } from './components/ChatSidePanelLayout.js';
|
|
@@ -504,7 +504,7 @@ function InnerAutocomplete(_0) {
|
|
|
504
504
|
});
|
|
505
505
|
}
|
|
506
506
|
indicesForPanel.forEach(function(param) {
|
|
507
|
-
var indexId = param.indexId, indexName = param.indexName, hits = param.hits;
|
|
507
|
+
var indexId = param.indexId, indexName = param.indexName, hits = param.hits, sendEvent = param.sendEvent;
|
|
508
508
|
var elementId = indexName;
|
|
509
509
|
if (indexName === (showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName)) {
|
|
510
510
|
elementId = 'suggestions';
|
|
@@ -530,9 +530,14 @@ function InnerAutocomplete(_0) {
|
|
|
530
530
|
});
|
|
531
531
|
}),
|
|
532
532
|
getItemProps: getItemProps,
|
|
533
|
+
sendEvent: sendEvent,
|
|
533
534
|
classNames: currentIndexConfig.classNames
|
|
534
535
|
});
|
|
535
536
|
});
|
|
537
|
+
var handleCancel = function handleCancel() {
|
|
538
|
+
setIsModalOpen(false);
|
|
539
|
+
setIsOpen(false);
|
|
540
|
+
};
|
|
536
541
|
var searchBoxContent = /*#__PURE__*/ React.createElement(AutocompleteSearch, {
|
|
537
542
|
inputProps: getInputProps(),
|
|
538
543
|
clearQuery: function clearQuery() {
|
|
@@ -544,7 +549,18 @@ function InnerAutocomplete(_0) {
|
|
|
544
549
|
},
|
|
545
550
|
query: resolvedQuery,
|
|
546
551
|
isSearchStalled: isSearchStalled,
|
|
552
|
+
onCancel: function onCancel() {
|
|
553
|
+
if (isDetached) {
|
|
554
|
+
handleCancel();
|
|
555
|
+
}
|
|
556
|
+
},
|
|
557
|
+
isDetached: isDetached,
|
|
558
|
+
submitTitle: isDetached ? translations.detachedCancelButtonText : undefined,
|
|
547
559
|
onAiModeClick: aiMode ? function() {
|
|
560
|
+
setIsOpen(false);
|
|
561
|
+
if (isDetached) {
|
|
562
|
+
setIsModalOpen(false);
|
|
563
|
+
}
|
|
548
564
|
if (chatRenderState) {
|
|
549
565
|
var _chatRenderState_setOpen;
|
|
550
566
|
(_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
|
|
@@ -588,19 +604,11 @@ function InnerAutocomplete(_0) {
|
|
|
588
604
|
translations: translations
|
|
589
605
|
}), isModalOpen && /*#__PURE__*/ React.createElement(AutocompleteDetachedOverlay, {
|
|
590
606
|
classNames: classNames,
|
|
591
|
-
onClose:
|
|
592
|
-
setIsModalOpen(false);
|
|
593
|
-
setIsOpen(false);
|
|
594
|
-
}
|
|
607
|
+
onClose: handleCancel
|
|
595
608
|
}, /*#__PURE__*/ React.createElement(AutocompleteDetachedContainer, {
|
|
596
609
|
classNames: detachedContainerClassNames
|
|
597
610
|
}, /*#__PURE__*/ React.createElement(AutocompleteDetachedFormContainer, {
|
|
598
|
-
classNames: classNames
|
|
599
|
-
onCancel: function onCancel() {
|
|
600
|
-
setIsModalOpen(false);
|
|
601
|
-
setIsOpen(false);
|
|
602
|
-
},
|
|
603
|
-
translations: translations
|
|
611
|
+
classNames: classNames
|
|
604
612
|
}, searchBoxContent), panelContent)));
|
|
605
613
|
}
|
|
606
614
|
// Normal (non-detached) rendering
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat';
|
|
1
|
+
import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType } from 'instantsearch.js/es/lib/chat';
|
|
2
2
|
import React from 'react';
|
|
3
|
-
export { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, };
|
|
3
|
+
export { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, DisplayResultsToolType, };
|
|
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';
|
|
@@ -30,11 +30,11 @@ export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<
|
|
|
30
30
|
headerCloseIconComponent?: ChatUiProps['headerProps']['closeIconComponent'];
|
|
31
31
|
headerMinimizeIconComponent?: ChatUiProps['headerProps']['minimizeIconComponent'];
|
|
32
32
|
headerMaximizeIconComponent?: ChatUiProps['headerProps']['maximizeIconComponent'];
|
|
33
|
-
messagesLoaderComponent?: ChatUiProps['messagesProps']['loaderComponent'];
|
|
34
33
|
messagesErrorComponent?: ChatUiProps['messagesProps']['errorComponent'];
|
|
35
34
|
promptComponent?: ChatUiProps['promptComponent'];
|
|
36
35
|
promptHeaderComponent?: ChatUiProps['promptProps']['headerComponent'];
|
|
37
36
|
promptFooterComponent?: ChatUiProps['promptProps']['footerComponent'];
|
|
37
|
+
loaderComponent?: ChatUiProps['messagesProps']['loaderComponent'];
|
|
38
38
|
emptyComponent?: ChatUiProps['messagesProps']['emptyComponent'];
|
|
39
39
|
actionsComponent?: ChatUiProps['messagesProps']['actionsComponent'];
|
|
40
40
|
assistantMessageLeadingComponent?: ChatMessageProps['leadingComponent'];
|
package/dist/es/widgets/Chat.js
CHANGED
|
@@ -5,11 +5,12 @@ import { _ as _$2 } from '@swc/helpers/esm/_object_without_properties.js';
|
|
|
5
5
|
import { _ as _$3 } from '@swc/helpers/esm/_sliced_to_array.js';
|
|
6
6
|
import { _ as _$1 } from '@swc/helpers/esm/_to_array.js';
|
|
7
7
|
import { createChatComponent } from 'instantsearch-ui-components';
|
|
8
|
-
import { SearchIndexToolType, RecommendToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
9
|
-
export { MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
8
|
+
import { SearchIndexToolType, RecommendToolType, DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
9
|
+
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
10
10
|
import React, { createElement, Fragment, useState, useRef, useMemo, useImperativeHandle, useEffect } from 'react';
|
|
11
11
|
import { useInstantSearch, useChat } from 'react-instantsearch-core';
|
|
12
12
|
import { useStickToBottom } from '../lib/useStickToBottom.js';
|
|
13
|
+
import { createDisplayResultsTool } from './chat/tools/DisplayResultsTool.js';
|
|
13
14
|
import { createCarouselTool } from './chat/tools/SearchIndexTool.js';
|
|
14
15
|
|
|
15
16
|
var ChatUiComponent = createChatComponent({
|
|
@@ -18,13 +19,13 @@ var ChatUiComponent = createChatComponent({
|
|
|
18
19
|
});
|
|
19
20
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
20
21
|
var _obj;
|
|
21
|
-
return _obj = {}, _(_obj, SearchIndexToolType, createCarouselTool(true, itemComponent, getSearchPageURL)), _(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _(_obj, MemorizeToolType, {}), _(_obj, MemorySearchToolType, {}), _(_obj, PonderToolType, {}), _obj;
|
|
22
|
+
return _obj = {}, _(_obj, SearchIndexToolType, createCarouselTool(true, itemComponent, getSearchPageURL)), _(_obj, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _(_obj, DisplayResultsToolType, createDisplayResultsTool(itemComponent)), _(_obj, MemorizeToolType, {}), _(_obj, MemorySearchToolType, {}), _(_obj, PonderToolType, {}), _obj;
|
|
22
23
|
}
|
|
23
24
|
function ChatInner(_0, _1) {
|
|
24
25
|
var _ref = [
|
|
25
26
|
_0,
|
|
26
27
|
_1
|
|
27
|
-
], _ref1 = _$1(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, toggleButtonProps = _ref2.toggleButtonProps, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, toggleButtonComponent = _ref2.toggleButtonComponent, toggleButtonIconComponent = _ref2.toggleButtonIconComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent,
|
|
28
|
+
], _ref1 = _$1(_ref), _ref2 = _ref1[0], _rest = _ref1.slice(1), userTools = _ref2.tools, toggleButtonProps = _ref2.toggleButtonProps, headerProps = _ref2.headerProps, messagesProps = _ref2.messagesProps, promptProps = _ref2.promptProps, itemComponent = _ref2.itemComponent, layoutComponent = _ref2.layoutComponent, toggleButtonComponent = _ref2.toggleButtonComponent, toggleButtonIconComponent = _ref2.toggleButtonIconComponent, headerComponent = _ref2.headerComponent, headerTitleIconComponent = _ref2.headerTitleIconComponent, headerCloseIconComponent = _ref2.headerCloseIconComponent, headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent, headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent, loaderComponent = _ref2.loaderComponent, messagesErrorComponent = _ref2.messagesErrorComponent, promptComponent = _ref2.promptComponent, promptHeaderComponent = _ref2.promptHeaderComponent, promptFooterComponent = _ref2.promptFooterComponent, assistantMessageLeadingComponent = _ref2.assistantMessageLeadingComponent, assistantMessageFooterComponent = _ref2.assistantMessageFooterComponent, userMessageLeadingComponent = _ref2.userMessageLeadingComponent, userMessageFooterComponent = _ref2.userMessageFooterComponent, emptyComponent = _ref2.emptyComponent, actionsComponent = _ref2.actionsComponent, suggestionsComponent = _ref2.suggestionsComponent, classNames = _ref2.classNames, _ref_translations = _ref2.translations, translations = _ref_translations === void 0 ? {} : _ref_translations, title = _ref2.title, getSearchPageURL = _ref2.getSearchPageURL, props = _$2(_ref2, [
|
|
28
29
|
"tools",
|
|
29
30
|
"toggleButtonProps",
|
|
30
31
|
"headerProps",
|
|
@@ -39,7 +40,7 @@ function ChatInner(_0, _1) {
|
|
|
39
40
|
"headerCloseIconComponent",
|
|
40
41
|
"headerMinimizeIconComponent",
|
|
41
42
|
"headerMaximizeIconComponent",
|
|
42
|
-
"
|
|
43
|
+
"loaderComponent",
|
|
43
44
|
"messagesErrorComponent",
|
|
44
45
|
"promptComponent",
|
|
45
46
|
"promptHeaderComponent",
|
|
@@ -158,7 +159,7 @@ function ChatInner(_0, _1) {
|
|
|
158
159
|
scrollRef: scrollRef,
|
|
159
160
|
contentRef: contentRef,
|
|
160
161
|
onScrollToBottom: scrollToBottom,
|
|
161
|
-
loaderComponent:
|
|
162
|
+
loaderComponent: loaderComponent,
|
|
162
163
|
errorComponent: messagesErrorComponent,
|
|
163
164
|
emptyComponent: emptyComponent,
|
|
164
165
|
actionsComponent: actionsComponent,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { RecommendComponentProps, RecordWithObjectID, UserClientSideTool } from 'instantsearch-ui-components';
|
|
2
|
+
type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent'];
|
|
3
|
+
declare function createDisplayResultsTool<TObject extends RecordWithObjectID>(itemComponent?: ItemComponent<TObject>): UserClientSideTool;
|
|
4
|
+
export { createDisplayResultsTool };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createDisplayResultsToolComponent, createButtonComponent, ChevronLeftIcon, ChevronRightIcon } from 'instantsearch-ui-components';
|
|
2
|
+
import React, { createElement, Fragment } from 'react';
|
|
3
|
+
import { Carousel } from '../../../components/Carousel.js';
|
|
4
|
+
|
|
5
|
+
function createDisplayResultsTool(itemComponent) {
|
|
6
|
+
var DisplayResultsUIComponent = createDisplayResultsToolComponent({
|
|
7
|
+
createElement: createElement,
|
|
8
|
+
Fragment: Fragment
|
|
9
|
+
});
|
|
10
|
+
var Button = createButtonComponent({
|
|
11
|
+
createElement: createElement
|
|
12
|
+
});
|
|
13
|
+
var DisplayResultsLayoutComponent = function DisplayResultsLayoutComponent(toolProps) {
|
|
14
|
+
return /*#__PURE__*/ React.createElement(DisplayResultsUIComponent, {
|
|
15
|
+
toolProps: toolProps,
|
|
16
|
+
groupCarouselComponent: function groupCarouselComponent(param) {
|
|
17
|
+
var items = param.items, sendEvent = param.sendEvent;
|
|
18
|
+
return /*#__PURE__*/ React.createElement(Carousel, {
|
|
19
|
+
items: items,
|
|
20
|
+
itemComponent: itemComponent,
|
|
21
|
+
sendEvent: sendEvent,
|
|
22
|
+
showNavigation: false,
|
|
23
|
+
headerComponent: function headerComponent(param) {
|
|
24
|
+
var canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight;
|
|
25
|
+
return /*#__PURE__*/ React.createElement("div", {
|
|
26
|
+
className: "ais-ChatToolDisplayResultsCarouselHeader"
|
|
27
|
+
}, /*#__PURE__*/ React.createElement("div", {
|
|
28
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderCount"
|
|
29
|
+
}, items.length, " result", items.length > 1 ? 's' : ''), /*#__PURE__*/ React.createElement("div", {
|
|
30
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButtons"
|
|
31
|
+
}, /*#__PURE__*/ React.createElement(Button, {
|
|
32
|
+
variant: "outline",
|
|
33
|
+
size: "sm",
|
|
34
|
+
iconOnly: true,
|
|
35
|
+
onClick: scrollLeft,
|
|
36
|
+
disabled: !canScrollLeft,
|
|
37
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
|
|
38
|
+
}, /*#__PURE__*/ React.createElement(ChevronLeftIcon, {
|
|
39
|
+
createElement: createElement
|
|
40
|
+
})), /*#__PURE__*/ React.createElement(Button, {
|
|
41
|
+
variant: "outline",
|
|
42
|
+
size: "sm",
|
|
43
|
+
iconOnly: true,
|
|
44
|
+
onClick: scrollRight,
|
|
45
|
+
disabled: !canScrollRight,
|
|
46
|
+
className: "ais-ChatToolDisplayResultsCarouselHeaderScrollButton"
|
|
47
|
+
}, /*#__PURE__*/ React.createElement(ChevronRightIcon, {
|
|
48
|
+
createElement: createElement
|
|
49
|
+
}))));
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
return {
|
|
56
|
+
layoutComponent: DisplayResultsLayoutComponent
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { createDisplayResultsTool };
|
package/dist/es/widgets/index.js
CHANGED
|
@@ -25,4 +25,4 @@ export { ToggleRefinement } from './ToggleRefinement.js';
|
|
|
25
25
|
export { TrendingItems } from './TrendingItems.js';
|
|
26
26
|
export { TrendingFacets } from './TrendingFacets.js';
|
|
27
27
|
export { FilterSuggestions } from './FilterSuggestions.js';
|
|
28
|
-
export { MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
28
|
+
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|