react-instantsearch 7.29.0 → 7.30.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 +3 -3
- package/dist/cjs/components/ChatGreeting.js +16 -0
- package/dist/cjs/components/ChatSidePanelLayout.js +17 -0
- package/dist/cjs/components/index.js +2 -0
- package/dist/cjs/ui/SearchBox.js +38 -2
- package/dist/cjs/widgets/Autocomplete.js +24 -8
- package/dist/cjs/widgets/Chat.js +21 -3
- package/dist/cjs/widgets/SearchBox.js +18 -2
- package/dist/cjs/widgets/TrendingFacets.js +55 -0
- package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +7 -3
- package/dist/cjs/widgets/index.js +1 -0
- package/dist/es/components/AutocompleteSearch.d.ts +2 -2
- package/dist/es/components/AutocompleteSearch.js +3 -3
- package/dist/es/components/ChatGreeting.d.ts +1 -0
- package/dist/es/components/ChatGreeting.js +8 -0
- package/dist/es/components/ChatOverlayLayout.d.ts +1 -3
- package/dist/es/components/ChatSidePanelLayout.d.ts +1 -0
- package/dist/es/components/ChatSidePanelLayout.js +9 -0
- package/dist/es/components/index.d.ts +2 -0
- package/dist/es/components/index.js +2 -0
- package/dist/es/index.js +3 -0
- package/dist/es/ui/SearchBox.d.ts +15 -1
- package/dist/es/ui/SearchBox.js +38 -2
- package/dist/es/widgets/Autocomplete.d.ts +6 -0
- package/dist/es/widgets/Autocomplete.js +24 -8
- package/dist/es/widgets/Chat.d.ts +12 -2
- package/dist/es/widgets/Chat.js +35 -17
- package/dist/es/widgets/RefinementList.d.ts +3 -2
- package/dist/es/widgets/SearchBox.d.ts +8 -2
- package/dist/es/widgets/SearchBox.js +19 -3
- package/dist/es/widgets/TrendingFacets.d.ts +11 -0
- package/dist/es/widgets/TrendingFacets.js +46 -0
- package/dist/es/widgets/chat/tools/SearchIndexTool.js +7 -3
- package/dist/es/widgets/index.d.ts +1 -0
- package/dist/es/widgets/index.js +1 -0
- package/dist/umd/ReactInstantSearch.js +646 -136
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
- package/dist/cjs/widgets/index.umd.js +0 -69
- package/dist/es/widgets/index.umd.d.ts +0 -32
- package/dist/es/widgets/index.umd.js +0 -37
|
@@ -19,17 +19,17 @@ 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,
|
|
22
|
+
var inputProps = param.inputProps, clearQuery = param.clearQuery, onQueryChange = param.onQueryChange, query = param.query, isSearchStalled = param.isSearchStalled, 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) {
|
|
26
26
|
var value = event.currentTarget.value;
|
|
27
|
-
refine(value);
|
|
28
27
|
onQueryChange === null || onQueryChange === void 0 ? void 0 : onQueryChange(value);
|
|
29
28
|
}
|
|
30
29
|
}),
|
|
31
30
|
onClear: clearQuery,
|
|
32
31
|
query: query,
|
|
33
|
-
isSearchStalled: isSearchStalled
|
|
32
|
+
isSearchStalled: isSearchStalled,
|
|
33
|
+
onAiModeClick: onAiModeClick
|
|
34
34
|
});
|
|
35
35
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ChatGreeting", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return ChatGreeting;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var ChatGreeting = (0, _instantsearchuicomponents.createChatGreetingComponent)({
|
|
15
|
+
createElement: _react.createElement
|
|
16
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "ChatSidePanelLayout", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return ChatSidePanelLayout;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
13
|
+
var _react = require("react");
|
|
14
|
+
var ChatSidePanelLayout = (0, _instantsearchuicomponents.createChatSidePanelLayoutComponent)({
|
|
15
|
+
createElement: _react.createElement,
|
|
16
|
+
Fragment: _react.Fragment
|
|
17
|
+
});
|
|
@@ -7,3 +7,5 @@ var _export_star = require("@swc/helpers/_/_export_star");
|
|
|
7
7
|
_export_star._(require("./Carousel"), exports);
|
|
8
8
|
_export_star._(require("./ChatOverlayLayout"), exports);
|
|
9
9
|
_export_star._(require("./ChatInlineLayout"), exports);
|
|
10
|
+
_export_star._(require("./ChatSidePanelLayout"), exports);
|
|
11
|
+
_export_star._(require("./ChatGreeting"), exports);
|
package/dist/cjs/ui/SearchBox.js
CHANGED
|
@@ -71,8 +71,30 @@ function DefaultLoadingIcon(param) {
|
|
|
71
71
|
repeatCount: "indefinite"
|
|
72
72
|
})))));
|
|
73
73
|
}
|
|
74
|
+
function DefaultAiModeIcon(param) {
|
|
75
|
+
var classNames = param.classNames;
|
|
76
|
+
return /*#__PURE__*/ _react.default.createElement("svg", {
|
|
77
|
+
className: (0, _instantsearchuicomponents.cx)('ais-AiModeButton-icon', classNames.aiModeIcon),
|
|
78
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
79
|
+
fill: "none",
|
|
80
|
+
viewBox: "0 0 20 20",
|
|
81
|
+
width: "16",
|
|
82
|
+
height: "16",
|
|
83
|
+
"aria-hidden": "true"
|
|
84
|
+
}, /*#__PURE__*/ _react.default.createElement("path", {
|
|
85
|
+
fill: "currentColor",
|
|
86
|
+
fillRule: "evenodd",
|
|
87
|
+
d: "M10 1.875c.27 0 .51.173.594.43l1.593 4.844a1.043 1.043 0 0 0 .664.664l4.844 1.593a.625.625 0 0 1 0 1.188l-4.844 1.593a1.043 1.043 0 0 0-.664.664l-1.593 4.844a.625.625 0 0 1-1.188 0l-1.593-4.844a1.042 1.042 0 0 0-.664-.664l-4.844-1.593a.625.625 0 0 1 0-1.188l4.844-1.593a1.042 1.042 0 0 0 .664-.664l1.593-4.844a.625.625 0 0 1 .594-.43ZM9 7.539A2.292 2.292 0 0 1 7.54 9L4.5 10l3.04 1A2.292 2.292 0 0 1 9 12.46l1 3.04 1-3.04A2.293 2.293 0 0 1 12.46 11l3.04-1-3.04-1A2.292 2.292 0 0 1 11 7.54L10 4.5 9 7.54ZM4.167 1.875c.345 0 .625.28.625.625v3.333a.625.625 0 0 1-1.25 0V2.5c0-.345.28-.625.625-.625ZM15.833 13.542c.345 0 .625.28.625.625V17.5a.625.625 0 1 1-1.25 0v-3.333c0-.345.28-.625.625-.625Z",
|
|
88
|
+
clipRule: "evenodd"
|
|
89
|
+
}), /*#__PURE__*/ _react.default.createElement("path", {
|
|
90
|
+
fill: "currentColor",
|
|
91
|
+
fillRule: "evenodd",
|
|
92
|
+
d: "M1.875 4.167c0-.346.28-.625.625-.625h3.333a.625.625 0 1 1 0 1.25H2.5a.625.625 0 0 1-.625-.625ZM13.542 15.833c0-.345.28-.625.625-.625H17.5a.625.625 0 0 1 0 1.25h-3.333a.625.625 0 0 1-.625-.625Z",
|
|
93
|
+
clipRule: "evenodd"
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
74
96
|
function SearchBox(_0) {
|
|
75
|
-
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, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _object_without_properties._(_0, [
|
|
97
|
+
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, [
|
|
76
98
|
"formRef",
|
|
77
99
|
"inputRef",
|
|
78
100
|
"inputProps",
|
|
@@ -86,6 +108,8 @@ function SearchBox(_0) {
|
|
|
86
108
|
"resetIconComponent",
|
|
87
109
|
"submitIconComponent",
|
|
88
110
|
"loadingIconComponent",
|
|
111
|
+
"aiModeIconComponent",
|
|
112
|
+
"onAiModeClick",
|
|
89
113
|
"classNames",
|
|
90
114
|
"translations"
|
|
91
115
|
]);
|
|
@@ -145,7 +169,19 @@ function SearchBox(_0) {
|
|
|
145
169
|
hidden: value.length === 0 || isSearchStalled
|
|
146
170
|
}, /*#__PURE__*/ _react.default.createElement(ResetIcon, {
|
|
147
171
|
classNames: classNames
|
|
148
|
-
})), /*#__PURE__*/ _react.default.createElement("
|
|
172
|
+
})), onAiModeClick && /*#__PURE__*/ _react.default.createElement("button", {
|
|
173
|
+
className: (0, _instantsearchuicomponents.cx)('ais-AiModeButton', classNames.aiModeButton),
|
|
174
|
+
type: "button",
|
|
175
|
+
title: translations.aiModeButtonTitle || 'AI Mode',
|
|
176
|
+
onClick: function onClick(e) {
|
|
177
|
+
e.preventDefault();
|
|
178
|
+
onAiModeClick();
|
|
179
|
+
}
|
|
180
|
+
}, /*#__PURE__*/ _react.default.createElement(AiModeIcon, {
|
|
181
|
+
classNames: classNames
|
|
182
|
+
}), /*#__PURE__*/ _react.default.createElement("span", {
|
|
183
|
+
className: "ais-AiModeButton-label"
|
|
184
|
+
}, translations.aiModeButtonTitle || 'AI Mode')), /*#__PURE__*/ _react.default.createElement("span", {
|
|
149
185
|
className: (0, _instantsearchuicomponents.cx)('ais-SearchBox-loadingIndicator', classNames.loadingIndicator),
|
|
150
186
|
hidden: !isSearchStalled
|
|
151
187
|
}, /*#__PURE__*/ _react.default.createElement(LoadingIcon, {
|
|
@@ -319,7 +319,7 @@ function EXPERIMENTAL_Autocomplete(_0) {
|
|
|
319
319
|
}))));
|
|
320
320
|
}
|
|
321
321
|
function InnerAutocomplete(_0) {
|
|
322
|
-
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, props = _object_without_properties._(_0, [
|
|
322
|
+
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, [
|
|
323
323
|
"indicesConfig",
|
|
324
324
|
"refineSearchBox",
|
|
325
325
|
"isSearchStalled",
|
|
@@ -338,13 +338,18 @@ function InnerAutocomplete(_0) {
|
|
|
338
338
|
"autoFocus",
|
|
339
339
|
"detachedMediaQuery",
|
|
340
340
|
"translations",
|
|
341
|
-
"classNames"
|
|
341
|
+
"classNames",
|
|
342
|
+
"aiMode"
|
|
342
343
|
]);
|
|
343
|
-
var _ref;
|
|
344
|
+
var _indexUiState_query, _ref;
|
|
344
345
|
var _showPromptSuggestions_searchParameters;
|
|
345
346
|
var _useAutocomplete = (0, _reactinstantsearchcore.useAutocomplete)({
|
|
346
|
-
transformItems: transformItems
|
|
347
|
+
transformItems: transformItems,
|
|
348
|
+
future: {
|
|
349
|
+
undefinedEmptyQuery: true
|
|
350
|
+
}
|
|
347
351
|
}), indices = _useAutocomplete.indices, refineAutocomplete = _useAutocomplete.refine, currentRefinement = _useAutocomplete.currentRefinement;
|
|
352
|
+
var resolvedQuery = currentRefinement !== undefined ? currentRefinement : (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '';
|
|
348
353
|
var _useDetachedMode = useDetachedMode(detachedMediaQuery), isDetached = _useDetachedMode.isDetached, isModalDetached = _useDetachedMode.isModalDetached, isModalOpen = _useDetachedMode.isModalOpen, setIsModalOpen = _useDetachedMode.setIsModalOpen;
|
|
349
354
|
var previousIsDetachedRef = (0, _react.useRef)(isDetached);
|
|
350
355
|
var _useStorage = useStorage({
|
|
@@ -548,9 +553,20 @@ function InnerAutocomplete(_0) {
|
|
|
548
553
|
onQueryChange: function onQueryChange(query) {
|
|
549
554
|
refineAutocomplete(query);
|
|
550
555
|
},
|
|
551
|
-
query:
|
|
552
|
-
|
|
553
|
-
|
|
556
|
+
query: resolvedQuery,
|
|
557
|
+
isSearchStalled: isSearchStalled,
|
|
558
|
+
onAiModeClick: aiMode ? function() {
|
|
559
|
+
if (chatRenderState) {
|
|
560
|
+
var _chatRenderState_setOpen;
|
|
561
|
+
(_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
|
|
562
|
+
if (resolvedQuery.trim()) {
|
|
563
|
+
var _chatRenderState_sendMessage;
|
|
564
|
+
(_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
|
|
565
|
+
text: resolvedQuery
|
|
566
|
+
});
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
} : undefined
|
|
554
570
|
});
|
|
555
571
|
var panelContent = /*#__PURE__*/ _react.default.createElement(AutocompletePanel, getPanelProps(), PanelComponent ? /*#__PURE__*/ _react.default.createElement(PanelComponent, {
|
|
556
572
|
elements: elements,
|
|
@@ -569,7 +585,7 @@ function InnerAutocomplete(_0) {
|
|
|
569
585
|
rootRef: rootRef,
|
|
570
586
|
classNames: classNames
|
|
571
587
|
}), /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedSearchButton, {
|
|
572
|
-
query:
|
|
588
|
+
query: resolvedQuery,
|
|
573
589
|
placeholder: placeholder,
|
|
574
590
|
classNames: classNames,
|
|
575
591
|
onClick: function onClick() {
|
package/dist/cjs/widgets/Chat.js
CHANGED
|
@@ -38,6 +38,7 @@ var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
|
38
38
|
var _object_spread_props = require("@swc/helpers/_/_object_spread_props");
|
|
39
39
|
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
|
|
40
40
|
var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
|
|
41
|
+
var _to_array = require("@swc/helpers/_/_to_array");
|
|
41
42
|
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
42
43
|
var _chat = require("instantsearch.js/cjs/lib/chat");
|
|
43
44
|
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
@@ -52,8 +53,11 @@ function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
|
52
53
|
var _obj;
|
|
53
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;
|
|
54
55
|
}
|
|
55
|
-
function
|
|
56
|
-
var
|
|
56
|
+
function ChatInner(_0, _1) {
|
|
57
|
+
var _ref = [
|
|
58
|
+
_0,
|
|
59
|
+
_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, messagesLoaderComponent = _ref2.messagesLoaderComponent, 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, [
|
|
57
61
|
"tools",
|
|
58
62
|
"toggleButtonProps",
|
|
59
63
|
"headerProps",
|
|
@@ -77,13 +81,14 @@ function Chat(_0) {
|
|
|
77
81
|
"assistantMessageFooterComponent",
|
|
78
82
|
"userMessageLeadingComponent",
|
|
79
83
|
"userMessageFooterComponent",
|
|
84
|
+
"emptyComponent",
|
|
80
85
|
"actionsComponent",
|
|
81
86
|
"suggestionsComponent",
|
|
82
87
|
"classNames",
|
|
83
88
|
"translations",
|
|
84
89
|
"title",
|
|
85
90
|
"getSearchPageURL"
|
|
86
|
-
]);
|
|
91
|
+
]), _rest1 = _sliced_to_array._(_rest, 1), ref = _rest1[0];
|
|
87
92
|
var promptTranslations = translations.prompt, headerTranslations = translations.header, messageTranslations = translations.message, messagesTranslations = translations.messages;
|
|
88
93
|
var _useInstantSearch = (0, _reactinstantsearchcore.useInstantSearch)(), indexUiState = _useInstantSearch.indexUiState, setIndexUiState = _useInstantSearch.setIndexUiState;
|
|
89
94
|
var _useState = _sliced_to_array._((0, _react.useState)(false), 2), maximized = _useState[0], setMaximized = _useState[1];
|
|
@@ -104,6 +109,15 @@ function Chat(_0) {
|
|
|
104
109
|
tools: tools
|
|
105
110
|
}));
|
|
106
111
|
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, isClearing = chatState.isClearing, clearMessages = chatState.clearMessages, onClearTransitionEnd = chatState.onClearTransitionEnd, toolsFromConnector = chatState.tools, suggestions = chatState.suggestions, onFeedback = chatState.sendChatMessageFeedback, feedbackState = chatState.feedbackState;
|
|
112
|
+
(0, _react.useImperativeHandle)(ref, function() {
|
|
113
|
+
return {
|
|
114
|
+
setOpen: setOpen,
|
|
115
|
+
sendMessage: function sendMessage1(params) {
|
|
116
|
+
return sendMessage(params);
|
|
117
|
+
},
|
|
118
|
+
setInput: setInput
|
|
119
|
+
};
|
|
120
|
+
});
|
|
107
121
|
var wasOpenRef = (0, _react.useRef)(false);
|
|
108
122
|
(0, _react.useEffect)(function() {
|
|
109
123
|
var shouldFocusPrompt = !wasOpenRef.current && open;
|
|
@@ -163,6 +177,8 @@ function Chat(_0) {
|
|
|
163
177
|
onClose: function onClose() {
|
|
164
178
|
return setOpen(false);
|
|
165
179
|
},
|
|
180
|
+
sendMessage: sendMessage,
|
|
181
|
+
setInput: setInput,
|
|
166
182
|
onFeedback: onFeedback,
|
|
167
183
|
feedbackState: feedbackState,
|
|
168
184
|
messages: messages,
|
|
@@ -177,6 +193,7 @@ function Chat(_0) {
|
|
|
177
193
|
onScrollToBottom: scrollToBottom,
|
|
178
194
|
loaderComponent: messagesLoaderComponent,
|
|
179
195
|
errorComponent: messagesErrorComponent,
|
|
196
|
+
emptyComponent: emptyComponent,
|
|
180
197
|
actionsComponent: actionsComponent,
|
|
181
198
|
assistantMessageProps: _object_spread._({
|
|
182
199
|
leadingComponent: assistantMessageLeadingComponent,
|
|
@@ -220,3 +237,4 @@ function Chat(_0) {
|
|
|
220
237
|
classNames: classNames
|
|
221
238
|
});
|
|
222
239
|
}
|
|
240
|
+
var Chat = /*#__PURE__*/ _react.default.forwardRef(ChatInner);
|
|
@@ -17,10 +17,11 @@ var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
|
17
17
|
var _reactinstantsearchcore = require("react-instantsearch-core");
|
|
18
18
|
var _SearchBox = require("../ui/SearchBox");
|
|
19
19
|
function SearchBox(_0) {
|
|
20
|
-
var queryHook = _0.queryHook, _0_searchAsYouType = _0.searchAsYouType, searchAsYouType = _0_searchAsYouType === void 0 ? true : _0_searchAsYouType, _0_ignoreCompositionEvents = _0.ignoreCompositionEvents, ignoreCompositionEvents = _0_ignoreCompositionEvents === void 0 ? false : _0_ignoreCompositionEvents, translations = _0.translations, props = _object_without_properties._(_0, [
|
|
20
|
+
var queryHook = _0.queryHook, _0_searchAsYouType = _0.searchAsYouType, searchAsYouType = _0_searchAsYouType === void 0 ? true : _0_searchAsYouType, _0_ignoreCompositionEvents = _0.ignoreCompositionEvents, ignoreCompositionEvents = _0_ignoreCompositionEvents === void 0 ? false : _0_ignoreCompositionEvents, aiMode = _0.aiMode, translations = _0.translations, props = _object_without_properties._(_0, [
|
|
21
21
|
"queryHook",
|
|
22
22
|
"searchAsYouType",
|
|
23
23
|
"ignoreCompositionEvents",
|
|
24
|
+
"aiMode",
|
|
24
25
|
"translations"
|
|
25
26
|
]);
|
|
26
27
|
var _useSearchBox = (0, _reactinstantsearchcore.useSearchBox)({
|
|
@@ -28,6 +29,7 @@ function SearchBox(_0) {
|
|
|
28
29
|
}, {
|
|
29
30
|
$$widgetType: 'ais.searchBox'
|
|
30
31
|
}), query = _useSearchBox.query, refine = _useSearchBox.refine, isSearchStalled = _useSearchBox.isSearchStalled;
|
|
32
|
+
var indexRenderState = (0, _reactinstantsearchcore.useInstantSearch)().indexRenderState;
|
|
31
33
|
var _useState = _sliced_to_array._((0, _react.useState)(query), 2), inputValue = _useState[0], setInputValue = _useState[1];
|
|
32
34
|
var inputRef = (0, _react.useRef)(null);
|
|
33
35
|
function setQuery(newQuery) {
|
|
@@ -67,10 +69,24 @@ function SearchBox(_0) {
|
|
|
67
69
|
onChange: onChange,
|
|
68
70
|
onReset: onReset,
|
|
69
71
|
onSubmit: onSubmit,
|
|
72
|
+
onAiModeClick: aiMode ? function() {
|
|
73
|
+
var chatRenderState = indexRenderState.chat;
|
|
74
|
+
if (chatRenderState) {
|
|
75
|
+
var _chatRenderState_setOpen;
|
|
76
|
+
(_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
|
|
77
|
+
if (inputValue.trim()) {
|
|
78
|
+
var _chatRenderState_sendMessage;
|
|
79
|
+
(_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
|
|
80
|
+
text: inputValue
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
} : undefined,
|
|
70
85
|
value: inputValue,
|
|
71
86
|
translations: _object_spread._({
|
|
72
87
|
submitButtonTitle: 'Submit the search query',
|
|
73
|
-
resetButtonTitle: 'Clear the search query'
|
|
88
|
+
resetButtonTitle: 'Clear the search query',
|
|
89
|
+
aiModeButtonTitle: 'AI Mode'
|
|
74
90
|
}, translations)
|
|
75
91
|
};
|
|
76
92
|
return /*#__PURE__*/ _react.default.createElement(_SearchBox.SearchBox, _object_spread._({}, props, uiProps));
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "TrendingFacets", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function() {
|
|
9
|
+
return TrendingFacets;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
+
var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
14
|
+
var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
|
|
15
|
+
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
16
|
+
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
17
|
+
var _reactinstantsearchcore = require("react-instantsearch-core");
|
|
18
|
+
var TrendingFacetsUiComponent = (0, _instantsearchuicomponents.createTrendingFacetsComponent)({
|
|
19
|
+
createElement: _react.createElement,
|
|
20
|
+
Fragment: _react.Fragment
|
|
21
|
+
});
|
|
22
|
+
function TrendingFacets(_0) {
|
|
23
|
+
var facetName = _0.facetName, limit = _0.limit, threshold = _0.threshold, fallbackParameters = _0.fallbackParameters, queryParameters = _0.queryParameters, escapeHTML = _0.escapeHTML, transformItems = _0.transformItems, itemComponent = _0.itemComponent, headerComponent = _0.headerComponent, emptyComponent = _0.emptyComponent, props = _object_without_properties._(_0, [
|
|
24
|
+
"facetName",
|
|
25
|
+
"limit",
|
|
26
|
+
"threshold",
|
|
27
|
+
"fallbackParameters",
|
|
28
|
+
"queryParameters",
|
|
29
|
+
"escapeHTML",
|
|
30
|
+
"transformItems",
|
|
31
|
+
"itemComponent",
|
|
32
|
+
"headerComponent",
|
|
33
|
+
"emptyComponent"
|
|
34
|
+
]);
|
|
35
|
+
var status = (0, _reactinstantsearchcore.useInstantSearch)().status;
|
|
36
|
+
var items = (0, _reactinstantsearchcore.useTrendingFacets)({
|
|
37
|
+
facetName: facetName,
|
|
38
|
+
limit: limit,
|
|
39
|
+
threshold: threshold,
|
|
40
|
+
fallbackParameters: fallbackParameters,
|
|
41
|
+
queryParameters: queryParameters,
|
|
42
|
+
escapeHTML: escapeHTML,
|
|
43
|
+
transformItems: transformItems
|
|
44
|
+
}, {
|
|
45
|
+
$$widgetType: 'ais.trendingFacets'
|
|
46
|
+
}).items;
|
|
47
|
+
var uiProps = {
|
|
48
|
+
items: items,
|
|
49
|
+
itemComponent: itemComponent,
|
|
50
|
+
headerComponent: headerComponent,
|
|
51
|
+
emptyComponent: emptyComponent,
|
|
52
|
+
status: status
|
|
53
|
+
};
|
|
54
|
+
return /*#__PURE__*/ _react.default.createElement(TrendingFacetsUiComponent, _object_spread._({}, props, uiProps));
|
|
55
|
+
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "createCarouselTool", {
|
|
|
12
12
|
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
13
|
var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
14
14
|
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
15
|
+
var _utils = require("instantsearch.js/cjs/lib/utils");
|
|
15
16
|
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
16
17
|
var _components = require("../../../components");
|
|
17
18
|
function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
@@ -19,10 +20,13 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
|
19
20
|
createElement: _react.createElement
|
|
20
21
|
});
|
|
21
22
|
function SearchLayoutComponent(param) {
|
|
22
|
-
var message = param.message, applyFilters = param.applyFilters, onClose = param.onClose;
|
|
23
|
+
var message = param.message, applyFilters = param.applyFilters, onClose = param.onClose, sendEvent = param.sendEvent;
|
|
24
|
+
var _ref;
|
|
25
|
+
var _output_hits;
|
|
23
26
|
var input = message === null || message === void 0 ? void 0 : message.input;
|
|
24
27
|
var output = message === null || message === void 0 ? void 0 : message.output;
|
|
25
|
-
var
|
|
28
|
+
var hitsWithAbsolutePosition = (0, _utils.addAbsolutePosition)((output === null || output === void 0 ? void 0 : output.hits) || [], 0, ((_ref = input === null || input === void 0 ? void 0 : input.number_of_results) !== null && _ref !== void 0 ? _ref : output === null || output === void 0 ? void 0 : (_output_hits = output.hits) === null || _output_hits === void 0 ? void 0 : _output_hits.length) || 5);
|
|
29
|
+
var items = (0, _utils.addQueryID)(hitsWithAbsolutePosition, output === null || output === void 0 ? void 0 : output.queryID);
|
|
26
30
|
var MemoedHeaderComponent = _react.default.useMemo(function() {
|
|
27
31
|
return function(props) {
|
|
28
32
|
return /*#__PURE__*/ _react.default.createElement(HeaderComponent, _object_spread._({
|
|
@@ -43,7 +47,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
|
43
47
|
return /*#__PURE__*/ _react.default.createElement(_components.Carousel, {
|
|
44
48
|
items: items,
|
|
45
49
|
itemComponent: itemComponent,
|
|
46
|
-
sendEvent:
|
|
50
|
+
sendEvent: sendEvent,
|
|
47
51
|
showNavigation: false,
|
|
48
52
|
headerComponent: MemoedHeaderComponent
|
|
49
53
|
});
|
|
@@ -29,4 +29,5 @@ _export_star._(require("./SortBy"), exports);
|
|
|
29
29
|
_export_star._(require("./Stats"), exports);
|
|
30
30
|
_export_star._(require("./ToggleRefinement"), exports);
|
|
31
31
|
_export_star._(require("./TrendingItems"), exports);
|
|
32
|
+
_export_star._(require("./TrendingFacets"), exports);
|
|
32
33
|
_export_star._(require("./FilterSuggestions"), exports);
|
|
@@ -5,7 +5,7 @@ export type AutocompleteSearchProps = {
|
|
|
5
5
|
clearQuery: () => void;
|
|
6
6
|
onQueryChange?: (query: string) => void;
|
|
7
7
|
query: string;
|
|
8
|
-
refine: (query: string) => void;
|
|
9
8
|
isSearchStalled: boolean;
|
|
9
|
+
onAiModeClick?: () => void;
|
|
10
10
|
};
|
|
11
|
-
export declare function AutocompleteSearch({ inputProps, clearQuery, onQueryChange, query,
|
|
11
|
+
export declare function AutocompleteSearch({ inputProps, clearQuery, onQueryChange, query, isSearchStalled, onAiModeClick, }: AutocompleteSearchProps): React.JSX.Element;
|
|
@@ -8,18 +8,18 @@ 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,
|
|
11
|
+
var inputProps = param.inputProps, clearQuery = param.clearQuery, onQueryChange = param.onQueryChange, query = param.query, isSearchStalled = param.isSearchStalled, onAiModeClick = param.onAiModeClick;
|
|
12
12
|
return /*#__PURE__*/ React.createElement(AutocompleteSearchComponent, {
|
|
13
13
|
inputProps: _(_$1({}, inputProps), {
|
|
14
14
|
onChange: function onChange(event) {
|
|
15
15
|
var value = event.currentTarget.value;
|
|
16
|
-
refine(value);
|
|
17
16
|
onQueryChange === null || onQueryChange === void 0 ? void 0 : onQueryChange(value);
|
|
18
17
|
}
|
|
19
18
|
}),
|
|
20
19
|
onClear: clearQuery,
|
|
21
20
|
query: query,
|
|
22
|
-
isSearchStalled: isSearchStalled
|
|
21
|
+
isSearchStalled: isSearchStalled,
|
|
22
|
+
onAiModeClick: onAiModeClick
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ChatGreeting: (userProps: import("instantsearch-ui-components").ChatGreetingProps) => JSX.Element;
|
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type { ChatLayoutOwnProps };
|
|
3
|
-
export declare const ChatOverlayLayout: (userProps: ChatLayoutOwnProps) => JSX.Element;
|
|
1
|
+
export declare const ChatOverlayLayout: (userProps: import("instantsearch-ui-components").ChatLayoutOwnProps) => JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ChatSidePanelLayout: (userProps: import("instantsearch-ui-components").ChatSidePanelLayoutProps) => JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { createChatSidePanelLayoutComponent } from 'instantsearch-ui-components';
|
|
2
|
+
import { createElement, Fragment } from 'react';
|
|
3
|
+
|
|
4
|
+
var ChatSidePanelLayout = createChatSidePanelLayoutComponent({
|
|
5
|
+
createElement: createElement,
|
|
6
|
+
Fragment: Fragment
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
export { ChatSidePanelLayout };
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { Carousel } from './Carousel.js';
|
|
2
2
|
export { ChatOverlayLayout } from './ChatOverlayLayout.js';
|
|
3
3
|
export { ChatInlineLayout } from './ChatInlineLayout.js';
|
|
4
|
+
export { ChatSidePanelLayout } from './ChatSidePanelLayout.js';
|
|
5
|
+
export { ChatGreeting } from './ChatGreeting.js';
|
package/dist/es/index.js
CHANGED
|
@@ -26,7 +26,10 @@ export { SortBy } from './widgets/SortBy.js';
|
|
|
26
26
|
export { Stats } from './widgets/Stats.js';
|
|
27
27
|
export { ToggleRefinement } from './widgets/ToggleRefinement.js';
|
|
28
28
|
export { TrendingItems } from './widgets/TrendingItems.js';
|
|
29
|
+
export { TrendingFacets } from './widgets/TrendingFacets.js';
|
|
29
30
|
export { FilterSuggestions } from './widgets/FilterSuggestions.js';
|
|
30
31
|
export { Carousel } from './components/Carousel.js';
|
|
31
32
|
export { ChatOverlayLayout } from './components/ChatOverlayLayout.js';
|
|
32
33
|
export { ChatInlineLayout } from './components/ChatInlineLayout.js';
|
|
34
|
+
export { ChatSidePanelLayout } from './components/ChatSidePanelLayout.js';
|
|
35
|
+
export { ChatGreeting } from './components/ChatGreeting.js';
|
|
@@ -39,6 +39,14 @@ export type SearchBoxClassNames = {
|
|
|
39
39
|
* Class names to apply to the loading icon
|
|
40
40
|
*/
|
|
41
41
|
loadingIcon: string;
|
|
42
|
+
/**
|
|
43
|
+
* Class names to apply to the AI mode button
|
|
44
|
+
*/
|
|
45
|
+
aiModeButton: string;
|
|
46
|
+
/**
|
|
47
|
+
* Class names to apply to the AI mode icon
|
|
48
|
+
*/
|
|
49
|
+
aiModeIcon: string;
|
|
42
50
|
};
|
|
43
51
|
export type SearchBoxTranslations = {
|
|
44
52
|
/**
|
|
@@ -49,6 +57,10 @@ export type SearchBoxTranslations = {
|
|
|
49
57
|
* The alternative text of the reset button.
|
|
50
58
|
*/
|
|
51
59
|
resetButtonTitle: string;
|
|
60
|
+
/**
|
|
61
|
+
* The alternative text of the AI mode button.
|
|
62
|
+
*/
|
|
63
|
+
aiModeButtonTitle?: string;
|
|
52
64
|
};
|
|
53
65
|
export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onReset' | 'onChange'> & Pick<React.ComponentProps<'form'>, 'onSubmit'> & Required<Pick<React.ComponentProps<'form'>, 'onReset'>> & Pick<React.ComponentProps<'input'>, 'placeholder' | 'autoFocus'> & {
|
|
54
66
|
onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.CompositionEvent<HTMLInputElement>) => void;
|
|
@@ -60,7 +72,9 @@ export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onR
|
|
|
60
72
|
resetIconComponent?: React.JSXElementConstructor<IconProps>;
|
|
61
73
|
submitIconComponent?: React.JSXElementConstructor<IconProps>;
|
|
62
74
|
loadingIconComponent?: React.JSXElementConstructor<IconProps>;
|
|
75
|
+
aiModeIconComponent?: React.JSXElementConstructor<IconProps>;
|
|
76
|
+
onAiModeClick?: () => void;
|
|
63
77
|
classNames?: Partial<SearchBoxClassNames>;
|
|
64
78
|
translations: SearchBoxTranslations;
|
|
65
79
|
};
|
|
66
|
-
export declare function SearchBox({ formRef, inputRef, inputProps, isSearchStalled, onChange, onReset, onSubmit, placeholder, value, autoFocus, resetIconComponent: ResetIcon, submitIconComponent: SubmitIcon, loadingIconComponent: LoadingIcon, classNames, translations, ...props }: SearchBoxProps): React.JSX.Element;
|
|
80
|
+
export declare function SearchBox({ formRef, inputRef, inputProps, isSearchStalled, onChange, onReset, onSubmit, placeholder, value, autoFocus, resetIconComponent: ResetIcon, submitIconComponent: SubmitIcon, loadingIconComponent: LoadingIcon, aiModeIconComponent: AiModeIcon, onAiModeClick, classNames, translations, ...props }: SearchBoxProps): React.JSX.Element;
|
package/dist/es/ui/SearchBox.js
CHANGED
|
@@ -60,8 +60,30 @@ function DefaultLoadingIcon(param) {
|
|
|
60
60
|
repeatCount: "indefinite"
|
|
61
61
|
})))));
|
|
62
62
|
}
|
|
63
|
+
function DefaultAiModeIcon(param) {
|
|
64
|
+
var classNames = param.classNames;
|
|
65
|
+
return /*#__PURE__*/ React.createElement("svg", {
|
|
66
|
+
className: cx('ais-AiModeButton-icon', classNames.aiModeIcon),
|
|
67
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
68
|
+
fill: "none",
|
|
69
|
+
viewBox: "0 0 20 20",
|
|
70
|
+
width: "16",
|
|
71
|
+
height: "16",
|
|
72
|
+
"aria-hidden": "true"
|
|
73
|
+
}, /*#__PURE__*/ React.createElement("path", {
|
|
74
|
+
fill: "currentColor",
|
|
75
|
+
fillRule: "evenodd",
|
|
76
|
+
d: "M10 1.875c.27 0 .51.173.594.43l1.593 4.844a1.043 1.043 0 0 0 .664.664l4.844 1.593a.625.625 0 0 1 0 1.188l-4.844 1.593a1.043 1.043 0 0 0-.664.664l-1.593 4.844a.625.625 0 0 1-1.188 0l-1.593-4.844a1.042 1.042 0 0 0-.664-.664l-4.844-1.593a.625.625 0 0 1 0-1.188l4.844-1.593a1.042 1.042 0 0 0 .664-.664l1.593-4.844a.625.625 0 0 1 .594-.43ZM9 7.539A2.292 2.292 0 0 1 7.54 9L4.5 10l3.04 1A2.292 2.292 0 0 1 9 12.46l1 3.04 1-3.04A2.293 2.293 0 0 1 12.46 11l3.04-1-3.04-1A2.292 2.292 0 0 1 11 7.54L10 4.5 9 7.54ZM4.167 1.875c.345 0 .625.28.625.625v3.333a.625.625 0 0 1-1.25 0V2.5c0-.345.28-.625.625-.625ZM15.833 13.542c.345 0 .625.28.625.625V17.5a.625.625 0 1 1-1.25 0v-3.333c0-.345.28-.625.625-.625Z",
|
|
77
|
+
clipRule: "evenodd"
|
|
78
|
+
}), /*#__PURE__*/ React.createElement("path", {
|
|
79
|
+
fill: "currentColor",
|
|
80
|
+
fillRule: "evenodd",
|
|
81
|
+
d: "M1.875 4.167c0-.346.28-.625.625-.625h3.333a.625.625 0 1 1 0 1.25H2.5a.625.625 0 0 1-.625-.625ZM13.542 15.833c0-.345.28-.625.625-.625H17.5a.625.625 0 0 1 0 1.25h-3.333a.625.625 0 0 1-.625-.625Z",
|
|
82
|
+
clipRule: "evenodd"
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
63
85
|
function SearchBox(_0) {
|
|
64
|
-
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, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _(_0, [
|
|
86
|
+
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 = _(_0, [
|
|
65
87
|
"formRef",
|
|
66
88
|
"inputRef",
|
|
67
89
|
"inputProps",
|
|
@@ -75,6 +97,8 @@ function SearchBox(_0) {
|
|
|
75
97
|
"resetIconComponent",
|
|
76
98
|
"submitIconComponent",
|
|
77
99
|
"loadingIconComponent",
|
|
100
|
+
"aiModeIconComponent",
|
|
101
|
+
"onAiModeClick",
|
|
78
102
|
"classNames",
|
|
79
103
|
"translations"
|
|
80
104
|
]);
|
|
@@ -134,7 +158,19 @@ function SearchBox(_0) {
|
|
|
134
158
|
hidden: value.length === 0 || isSearchStalled
|
|
135
159
|
}, /*#__PURE__*/ React.createElement(ResetIcon, {
|
|
136
160
|
classNames: classNames
|
|
137
|
-
})), /*#__PURE__*/ React.createElement("
|
|
161
|
+
})), onAiModeClick && /*#__PURE__*/ React.createElement("button", {
|
|
162
|
+
className: cx('ais-AiModeButton', classNames.aiModeButton),
|
|
163
|
+
type: "button",
|
|
164
|
+
title: translations.aiModeButtonTitle || 'AI Mode',
|
|
165
|
+
onClick: function onClick(e) {
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
onAiModeClick();
|
|
168
|
+
}
|
|
169
|
+
}, /*#__PURE__*/ React.createElement(AiModeIcon, {
|
|
170
|
+
classNames: classNames
|
|
171
|
+
}), /*#__PURE__*/ React.createElement("span", {
|
|
172
|
+
className: "ais-AiModeButton-label"
|
|
173
|
+
}, translations.aiModeButtonTitle || 'AI Mode')), /*#__PURE__*/ React.createElement("span", {
|
|
138
174
|
className: cx('ais-SearchBox-loadingIndicator', classNames.loadingIndicator),
|
|
139
175
|
hidden: !isSearchStalled
|
|
140
176
|
}, /*#__PURE__*/ React.createElement(LoadingIcon, {
|
|
@@ -77,6 +77,12 @@ export type AutocompleteProps<TItem extends BaseHit> = ComponentProps<'div'> & {
|
|
|
77
77
|
* Translations for the Autocomplete widget.
|
|
78
78
|
*/
|
|
79
79
|
translations?: Partial<AutocompleteTranslations>;
|
|
80
|
+
/**
|
|
81
|
+
* When true, renders an AI mode button inside the search input
|
|
82
|
+
* that opens the Chat widget and sends the current query.
|
|
83
|
+
* Requires a Chat widget on the same index.
|
|
84
|
+
*/
|
|
85
|
+
aiMode?: boolean;
|
|
80
86
|
};
|
|
81
87
|
export declare function EXPERIMENTAL_Autocomplete<TItem extends BaseHit = BaseHit>({ indices, showQuerySuggestions, showPromptSuggestions, showRecent, searchParameters: userSearchParameters, detachedMediaQuery, translations: userTranslations, ...props }: AutocompleteProps<TItem>): React.JSX.Element;
|
|
82
88
|
export {};
|