react-instantsearch 7.32.3 → 7.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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, onCancel = param.onCancel, isDetached = param.isDetached, submitTitle = param.submitTitle, onAiModeClick = param.onAiModeClick, classNames = param.classNames;
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, aiModeButtonDisabled = param.aiModeButtonDisabled, classNames = param.classNames;
23
23
  return /*#__PURE__*/ _react.default.createElement(AutocompleteSearchComponent, {
24
24
  inputProps: _object_spread_props._(_object_spread._({}, inputProps), {
25
25
  onChange: function onChange(event) {
@@ -34,6 +34,7 @@ function AutocompleteSearch(param) {
34
34
  isDetached: isDetached,
35
35
  submitTitle: submitTitle,
36
36
  onAiModeClick: onAiModeClick,
37
+ aiModeButtonDisabled: aiModeButtonDisabled,
37
38
  classNames: classNames
38
39
  });
39
40
  }
@@ -94,7 +94,7 @@ function DefaultAiModeIcon(param) {
94
94
  }));
95
95
  }
96
96
  function SearchBox(_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, [
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_aiModeButtonDisabled = _0.aiModeButtonDisabled, aiModeButtonDisabled = _0_aiModeButtonDisabled === void 0 ? false : _0_aiModeButtonDisabled, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _object_without_properties._(_0, [
98
98
  "formRef",
99
99
  "inputRef",
100
100
  "inputProps",
@@ -110,6 +110,7 @@ function SearchBox(_0) {
110
110
  "loadingIconComponent",
111
111
  "aiModeIconComponent",
112
112
  "onAiModeClick",
113
+ "aiModeButtonDisabled",
113
114
  "classNames",
114
115
  "translations"
115
116
  ]);
@@ -173,6 +174,7 @@ function SearchBox(_0) {
173
174
  className: (0, _instantsearchuicomponents.cx)('ais-AiModeButton', classNames.aiModeButton),
174
175
  type: "button",
175
176
  title: translations.aiModeButtonTitle || 'AI Mode',
177
+ disabled: aiModeButtonDisabled,
176
178
  onClick: function onClick(e) {
177
179
  e.preventDefault();
178
180
  onAiModeClick();
@@ -17,6 +17,7 @@ var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
17
17
  var _to_consumable_array = require("@swc/helpers/_/_to_consumable_array");
18
18
  var _type_of = require("@swc/helpers/_/_type_of");
19
19
  var _instantsearchuicomponents = require("instantsearch-ui-components");
20
+ var _chat = require("instantsearch.js/cjs/lib/chat");
20
21
  require("instantsearch.js/cjs/lib/utils");
21
22
  var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
22
23
  var _reactinstantsearchcore = require("react-instantsearch-core");
@@ -429,14 +430,13 @@ function InnerAutocomplete(_0) {
429
430
  onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function(param) {
430
431
  var item = param.item, query = param.query, setQuery = param.setQuery, url = param.url;
431
432
  if ((0, _instantsearchuicomponents.isPromptSuggestion)(item)) {
432
- var chatRenderStateWithFocus = chatRenderState;
433
- if (chatRenderStateWithFocus) {
434
- var _chatRenderStateWithFocus_setOpen, _chatRenderStateWithFocus_focusInput, _chatRenderStateWithFocus_sendMessage;
435
- (_chatRenderStateWithFocus_setOpen = chatRenderStateWithFocus.setOpen) === null || _chatRenderStateWithFocus_setOpen === void 0 ? void 0 : _chatRenderStateWithFocus_setOpen.call(chatRenderStateWithFocus, true);
436
- (_chatRenderStateWithFocus_focusInput = chatRenderStateWithFocus.focusInput) === null || _chatRenderStateWithFocus_focusInput === void 0 ? void 0 : _chatRenderStateWithFocus_focusInput.call(chatRenderStateWithFocus);
437
- (_chatRenderStateWithFocus_sendMessage = chatRenderStateWithFocus.sendMessage) === null || _chatRenderStateWithFocus_sendMessage === void 0 ? void 0 : _chatRenderStateWithFocus_sendMessage.call(chatRenderStateWithFocus, {
438
- text: item.prompt
439
- });
433
+ if (chatRenderState) {
434
+ if ((0, _chat.openChat)(chatRenderState, {
435
+ message: item.prompt,
436
+ referer: 'prompt-suggestions'
437
+ })) {
438
+ setQuery('');
439
+ }
440
440
  return;
441
441
  }
442
442
  }
@@ -572,17 +572,15 @@ function InnerAutocomplete(_0) {
572
572
  if (isDetached) {
573
573
  setIsModalOpen(false);
574
574
  }
575
- if (chatRenderState) {
576
- var _chatRenderState_setOpen;
577
- (_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
578
- if (resolvedQuery.trim()) {
579
- var _chatRenderState_sendMessage;
580
- (_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
581
- text: resolvedQuery
582
- });
583
- }
575
+ if ((0, _chat.openChat)(chatRenderState, {
576
+ message: resolvedQuery,
577
+ referer: 'ai-mode'
578
+ })) {
579
+ refineSearchBox('');
580
+ refineAutocomplete('');
584
581
  }
585
582
  } : undefined,
583
+ aiModeButtonDisabled: aiMode ? (0, _chat.isChatBusy)(chatRenderState) : undefined,
586
584
  classNames: classNames
587
585
  });
588
586
  var panelContent = /*#__PURE__*/ _react.default.createElement(AutocompletePanel, _object_spread_props._(_object_spread._({}, getPanelProps()), {
@@ -13,6 +13,7 @@ var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcar
13
13
  var _object_spread = require("@swc/helpers/_/_object_spread");
14
14
  var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
15
15
  var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
16
+ var _chat = require("instantsearch.js/cjs/lib/chat");
16
17
  var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
17
18
  var _reactinstantsearchcore = require("react-instantsearch-core");
18
19
  var _SearchBox = require("../ui/SearchBox");
@@ -63,6 +64,7 @@ function SearchBox(_0) {
63
64
  if (query !== inputValue && document.activeElement !== inputRef.current) {
64
65
  setInputValue(query);
65
66
  }
67
+ var chatRenderState = indexRenderState.chat;
66
68
  var uiProps = {
67
69
  inputRef: inputRef,
68
70
  isSearchStalled: isSearchStalled,
@@ -70,18 +72,14 @@ function SearchBox(_0) {
70
72
  onReset: onReset,
71
73
  onSubmit: onSubmit,
72
74
  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
- }
75
+ if ((0, _chat.openChat)(chatRenderState, {
76
+ message: inputValue,
77
+ referer: 'ai-mode'
78
+ })) {
79
+ onReset();
83
80
  }
84
81
  } : undefined,
82
+ aiModeButtonDisabled: aiMode ? (0, _chat.isChatBusy)(chatRenderState) : undefined,
85
83
  value: inputValue,
86
84
  translations: _object_spread._({
87
85
  submitButtonTitle: 'Submit the search query',
@@ -10,6 +10,7 @@ export type AutocompleteSearchProps = {
10
10
  isDetached?: boolean;
11
11
  submitTitle?: string;
12
12
  onAiModeClick?: () => void;
13
+ aiModeButtonDisabled?: boolean;
13
14
  classNames?: Partial<AutocompleteClassNames>;
14
15
  };
15
- export declare function AutocompleteSearch({ inputProps, clearQuery, onQueryChange, query, isSearchStalled, onCancel, isDetached, submitTitle, onAiModeClick, classNames, }: AutocompleteSearchProps): React.JSX.Element;
16
+ export declare function AutocompleteSearch({ inputProps, clearQuery, onQueryChange, query, isSearchStalled, onCancel, isDetached, submitTitle, onAiModeClick, aiModeButtonDisabled, classNames, }: 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, onCancel = param.onCancel, isDetached = param.isDetached, submitTitle = param.submitTitle, onAiModeClick = param.onAiModeClick, classNames = param.classNames;
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, aiModeButtonDisabled = param.aiModeButtonDisabled, classNames = param.classNames;
12
12
  return /*#__PURE__*/ React.createElement(AutocompleteSearchComponent, {
13
13
  inputProps: _(_$1({}, inputProps), {
14
14
  onChange: function onChange(event) {
@@ -23,6 +23,7 @@ function AutocompleteSearch(param) {
23
23
  isDetached: isDetached,
24
24
  submitTitle: submitTitle,
25
25
  onAiModeClick: onAiModeClick,
26
+ aiModeButtonDisabled: aiModeButtonDisabled,
26
27
  classNames: classNames
27
28
  });
28
29
  }
@@ -74,7 +74,8 @@ export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onR
74
74
  loadingIconComponent?: React.JSXElementConstructor<IconProps>;
75
75
  aiModeIconComponent?: React.JSXElementConstructor<IconProps>;
76
76
  onAiModeClick?: () => void;
77
+ aiModeButtonDisabled?: boolean;
77
78
  classNames?: Partial<SearchBoxClassNames>;
78
79
  translations: SearchBoxTranslations;
79
80
  };
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;
81
+ export declare function SearchBox({ formRef, inputRef, inputProps, isSearchStalled, onChange, onReset, onSubmit, placeholder, value, autoFocus, resetIconComponent: ResetIcon, submitIconComponent: SubmitIcon, loadingIconComponent: LoadingIcon, aiModeIconComponent: AiModeIcon, onAiModeClick, aiModeButtonDisabled, classNames, translations, ...props }: SearchBoxProps): React.JSX.Element;
@@ -83,7 +83,7 @@ function DefaultAiModeIcon(param) {
83
83
  }));
84
84
  }
85
85
  function SearchBox(_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, [
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_aiModeButtonDisabled = _0.aiModeButtonDisabled, aiModeButtonDisabled = _0_aiModeButtonDisabled === void 0 ? false : _0_aiModeButtonDisabled, _0_classNames = _0.classNames, classNames = _0_classNames === void 0 ? {} : _0_classNames, translations = _0.translations, props = _(_0, [
87
87
  "formRef",
88
88
  "inputRef",
89
89
  "inputProps",
@@ -99,6 +99,7 @@ function SearchBox(_0) {
99
99
  "loadingIconComponent",
100
100
  "aiModeIconComponent",
101
101
  "onAiModeClick",
102
+ "aiModeButtonDisabled",
102
103
  "classNames",
103
104
  "translations"
104
105
  ]);
@@ -162,6 +163,7 @@ function SearchBox(_0) {
162
163
  className: cx('ais-AiModeButton', classNames.aiModeButton),
163
164
  type: "button",
164
165
  title: translations.aiModeButtonTitle || 'AI Mode',
166
+ disabled: aiModeButtonDisabled,
165
167
  onClick: function onClick(e) {
166
168
  e.preventDefault();
167
169
  onAiModeClick();
@@ -5,6 +5,7 @@ import { _ as _$5 } from '@swc/helpers/esm/_sliced_to_array.js';
5
5
  import { _ as _$2 } from '@swc/helpers/esm/_to_consumable_array.js';
6
6
  import { _ as _$3 } from '@swc/helpers/esm/_type_of.js';
7
7
  import { createAutocompleteComponent, createAutocompletePanelComponent, createAutocompleteIndexComponent, createAutocompleteSuggestionComponent, createAutocompletePromptSuggestionComponent, createAutocompleteRecentSearchComponent, createAutocompleteDetachedContainerComponent, createAutocompleteDetachedOverlayComponent, createAutocompleteDetachedFormContainerComponent, createAutocompleteDetachedSearchButtonComponent, createAutocompletePropGetters, createAutocompleteStorage, cx, getPromptSuggestionHits, isPromptSuggestion } from 'instantsearch-ui-components';
8
+ import { openChat, isChatBusy } from 'instantsearch.js/es/lib/chat/index.js';
8
9
  import 'instantsearch.js/es/lib/utils/index.js';
9
10
  import React, { createElement, Fragment, useEffect, useMemo, useRef, useState } from 'react';
10
11
  import { useInstantSearch, useSearchBox, Index, Configure, useAutocomplete } from 'react-instantsearch-core';
@@ -418,14 +419,13 @@ function InnerAutocomplete(_0) {
418
419
  onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function(param) {
419
420
  var item = param.item, query = param.query, setQuery = param.setQuery, url = param.url;
420
421
  if (isPromptSuggestion(item)) {
421
- var chatRenderStateWithFocus = chatRenderState;
422
- if (chatRenderStateWithFocus) {
423
- var _chatRenderStateWithFocus_setOpen, _chatRenderStateWithFocus_focusInput, _chatRenderStateWithFocus_sendMessage;
424
- (_chatRenderStateWithFocus_setOpen = chatRenderStateWithFocus.setOpen) === null || _chatRenderStateWithFocus_setOpen === void 0 ? void 0 : _chatRenderStateWithFocus_setOpen.call(chatRenderStateWithFocus, true);
425
- (_chatRenderStateWithFocus_focusInput = chatRenderStateWithFocus.focusInput) === null || _chatRenderStateWithFocus_focusInput === void 0 ? void 0 : _chatRenderStateWithFocus_focusInput.call(chatRenderStateWithFocus);
426
- (_chatRenderStateWithFocus_sendMessage = chatRenderStateWithFocus.sendMessage) === null || _chatRenderStateWithFocus_sendMessage === void 0 ? void 0 : _chatRenderStateWithFocus_sendMessage.call(chatRenderStateWithFocus, {
427
- text: item.prompt
428
- });
422
+ if (chatRenderState) {
423
+ if (openChat(chatRenderState, {
424
+ message: item.prompt,
425
+ referer: 'prompt-suggestions'
426
+ })) {
427
+ setQuery('');
428
+ }
429
429
  return;
430
430
  }
431
431
  }
@@ -561,17 +561,15 @@ function InnerAutocomplete(_0) {
561
561
  if (isDetached) {
562
562
  setIsModalOpen(false);
563
563
  }
564
- if (chatRenderState) {
565
- var _chatRenderState_setOpen;
566
- (_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
567
- if (resolvedQuery.trim()) {
568
- var _chatRenderState_sendMessage;
569
- (_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
570
- text: resolvedQuery
571
- });
572
- }
564
+ if (openChat(chatRenderState, {
565
+ message: resolvedQuery,
566
+ referer: 'ai-mode'
567
+ })) {
568
+ refineSearchBox('');
569
+ refineAutocomplete('');
573
570
  }
574
571
  } : undefined,
572
+ aiModeButtonDisabled: aiMode ? isChatBusy(chatRenderState) : undefined,
575
573
  classNames: classNames
576
574
  });
577
575
  var panelContent = /*#__PURE__*/ React.createElement(AutocompletePanel, _$4(_$1({}, getPanelProps()), {
@@ -16,5 +16,8 @@ export type FilterSuggestionsProps = Omit<FilterSuggestionsUiComponentProps, key
16
16
  */
17
17
  emptyComponent?: FilterSuggestionsUiComponentProps['emptyComponent'];
18
18
  };
19
+ /**
20
+ * @deprecated Filter suggestions are deprecated and will be removed in a future major version.
21
+ */
19
22
  export declare function FilterSuggestions({ agentId, attributes, maxSuggestions, debounceMs, hitsToSample, transformItems, itemComponent, headerComponent, emptyComponent, transport, ...props }: FilterSuggestionsProps): React.JSX.Element;
20
23
  export {};
@@ -8,7 +8,9 @@ var FilterSuggestionsUiComponent = createFilterSuggestionsComponent({
8
8
  createElement: createElement,
9
9
  Fragment: Fragment
10
10
  });
11
- function FilterSuggestions(_0) {
11
+ /**
12
+ * @deprecated Filter suggestions are deprecated and will be removed in a future major version.
13
+ */ function FilterSuggestions(_0) {
12
14
  var agentId = _0.agentId, attributes = _0.attributes, maxSuggestions = _0.maxSuggestions, debounceMs = _0.debounceMs, hitsToSample = _0.hitsToSample, transformItems = _0.transformItems, itemComponent = _0.itemComponent, headerComponent = _0.headerComponent, emptyComponent = _0.emptyComponent, transport = _0.transport, props = _(_0, [
13
15
  "agentId",
14
16
  "attributes",
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import type { SearchBoxProps as SearchBoxUiComponentProps } from '../ui/SearchBox';
3
3
  import type { UseSearchBoxProps } from 'react-instantsearch-core';
4
- type UiProps = Pick<SearchBoxUiComponentProps, 'inputRef' | 'isSearchStalled' | 'onChange' | 'onReset' | 'onSubmit' | 'onAiModeClick' | 'value' | 'autoFocus' | 'translations'>;
4
+ type UiProps = Pick<SearchBoxUiComponentProps, 'inputRef' | 'isSearchStalled' | 'onChange' | 'onReset' | 'onSubmit' | 'onAiModeClick' | 'aiModeButtonDisabled' | 'value' | 'autoFocus' | 'translations'>;
5
5
  export type SearchBoxProps = Omit<SearchBoxUiComponentProps, Exclude<keyof UiProps, 'onSubmit' | 'autoFocus'>> & UseSearchBoxProps & {
6
6
  /**
7
7
  * Whether to trigger the search only on submit.
@@ -1,6 +1,7 @@
1
1
  import { _ as _$2 } from '@swc/helpers/esm/_object_spread.js';
2
2
  import { _ } from '@swc/helpers/esm/_object_without_properties.js';
3
3
  import { _ as _$1 } from '@swc/helpers/esm/_sliced_to_array.js';
4
+ import { openChat, isChatBusy } from 'instantsearch.js/es/lib/chat/index.js';
4
5
  import React, { useState, useRef } from 'react';
5
6
  import { useSearchBox, useInstantSearch } from 'react-instantsearch-core';
6
7
  import { SearchBox as SearchBox$1 } from '../ui/SearchBox.js';
@@ -52,6 +53,7 @@ function SearchBox(_0) {
52
53
  if (query !== inputValue && document.activeElement !== inputRef.current) {
53
54
  setInputValue(query);
54
55
  }
56
+ var chatRenderState = indexRenderState.chat;
55
57
  var uiProps = {
56
58
  inputRef: inputRef,
57
59
  isSearchStalled: isSearchStalled,
@@ -59,18 +61,14 @@ function SearchBox(_0) {
59
61
  onReset: onReset,
60
62
  onSubmit: onSubmit,
61
63
  onAiModeClick: aiMode ? function() {
62
- var chatRenderState = indexRenderState.chat;
63
- if (chatRenderState) {
64
- var _chatRenderState_setOpen;
65
- (_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
66
- if (inputValue.trim()) {
67
- var _chatRenderState_sendMessage;
68
- (_chatRenderState_sendMessage = chatRenderState.sendMessage) === null || _chatRenderState_sendMessage === void 0 ? void 0 : _chatRenderState_sendMessage.call(chatRenderState, {
69
- text: inputValue
70
- });
71
- }
64
+ if (openChat(chatRenderState, {
65
+ message: inputValue,
66
+ referer: 'ai-mode'
67
+ })) {
68
+ onReset();
72
69
  }
73
70
  } : undefined,
71
+ aiModeButtonDisabled: aiMode ? isChatBusy(chatRenderState) : undefined,
74
72
  value: inputValue,
75
73
  translations: _$2({
76
74
  submitButtonTitle: 'Submit the search query',