react-instantsearch 7.26.1 → 7.28.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.
Files changed (66) hide show
  1. package/dist/cjs/components/AutocompleteSearch.js +18 -11
  2. package/dist/cjs/components/Carousel.js +24 -17
  3. package/dist/cjs/components/index.js +5 -5
  4. package/dist/cjs/index.js +8 -88
  5. package/dist/cjs/lib/useStickToBottom.js +17 -11
  6. package/dist/cjs/types/PartialKeys.js +3 -0
  7. package/dist/cjs/types/Translatable.js +3 -0
  8. package/dist/cjs/types/index.js +6 -0
  9. package/dist/cjs/ui/Breadcrumb.js +31 -24
  10. package/dist/cjs/ui/ClearRefinements.js +19 -12
  11. package/dist/cjs/ui/CurrentRefinements.js +32 -26
  12. package/dist/cjs/ui/HierarchicalMenu.js +35 -28
  13. package/dist/cjs/ui/Highlight.js +20 -13
  14. package/dist/cjs/ui/HitsPerPage.js +21 -14
  15. package/dist/cjs/ui/InfiniteHits.js +38 -31
  16. package/dist/cjs/ui/InternalHighlight.js +14 -8
  17. package/dist/cjs/ui/Menu.js +32 -25
  18. package/dist/cjs/ui/Pagination.js +39 -32
  19. package/dist/cjs/ui/PoweredBy.js +23 -16
  20. package/dist/cjs/ui/RangeInput.js +34 -27
  21. package/dist/cjs/ui/RefinementList.js +40 -33
  22. package/dist/cjs/ui/ReverseHighlight.js +20 -13
  23. package/dist/cjs/ui/SearchBox.js +43 -36
  24. package/dist/cjs/ui/ShowMoreButton.js +13 -6
  25. package/dist/cjs/ui/Snippet.js +20 -13
  26. package/dist/cjs/ui/SortBy.js +21 -14
  27. package/dist/cjs/ui/Stats.js +18 -11
  28. package/dist/cjs/ui/ToggleRefinement.js +23 -16
  29. package/dist/cjs/ui/lib/capitalize.js +9 -2
  30. package/dist/cjs/ui/lib/index.js +6 -7
  31. package/dist/cjs/ui/lib/isModifierClick.js +9 -2
  32. package/dist/cjs/widgets/Autocomplete.js +262 -120
  33. package/dist/cjs/widgets/Breadcrumb.js +17 -10
  34. package/dist/cjs/widgets/Chat.js +69 -47
  35. package/dist/cjs/widgets/ClearRefinements.js +17 -10
  36. package/dist/cjs/widgets/CurrentRefinements.js +17 -10
  37. package/dist/cjs/widgets/FilterSuggestions.js +20 -13
  38. package/dist/cjs/widgets/FrequentlyBoughtTogether.js +23 -16
  39. package/dist/cjs/widgets/HierarchicalMenu.js +18 -11
  40. package/dist/cjs/widgets/Highlight.js +19 -12
  41. package/dist/cjs/widgets/Hits.js +24 -17
  42. package/dist/cjs/widgets/HitsPerPage.js +17 -10
  43. package/dist/cjs/widgets/InfiniteHits.js +17 -10
  44. package/dist/cjs/widgets/LookingSimilar.js +23 -16
  45. package/dist/cjs/widgets/Menu.js +18 -11
  46. package/dist/cjs/widgets/Pagination.js +18 -11
  47. package/dist/cjs/widgets/PoweredBy.js +16 -9
  48. package/dist/cjs/widgets/RangeInput.js +17 -10
  49. package/dist/cjs/widgets/RefinementList.js +23 -16
  50. package/dist/cjs/widgets/RelatedProducts.js +23 -16
  51. package/dist/cjs/widgets/ReverseHighlight.js +19 -12
  52. package/dist/cjs/widgets/SearchBox.js +20 -13
  53. package/dist/cjs/widgets/Snippet.js +19 -12
  54. package/dist/cjs/widgets/SortBy.js +17 -10
  55. package/dist/cjs/widgets/Stats.js +17 -10
  56. package/dist/cjs/widgets/ToggleRefinement.js +17 -10
  57. package/dist/cjs/widgets/TrendingItems.js +23 -16
  58. package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +32 -25
  59. package/dist/cjs/widgets/index.js +29 -76
  60. package/dist/cjs/widgets/index.umd.js +58 -59
  61. package/dist/es/widgets/Autocomplete.d.ts +13 -4
  62. package/dist/es/widgets/Autocomplete.js +167 -32
  63. package/dist/es/widgets/Chat.js +17 -4
  64. package/dist/umd/ReactInstantSearch.js +1222 -1012
  65. package/dist/umd/ReactInstantSearch.min.js +3 -3
  66. package/package.json +5 -5
@@ -1,69 +1,84 @@
1
1
  'use strict';
2
2
 
3
- var _object_spread = require('@swc/helpers/_/_object_spread');
4
- var _object_spread_props = require('@swc/helpers/_/_object_spread_props');
5
- var _object_without_properties = require('@swc/helpers/_/_object_without_properties');
6
- var _sliced_to_array = require('@swc/helpers/_/_sliced_to_array');
7
- var _to_consumable_array = require('@swc/helpers/_/_to_consumable_array');
8
- var _type_of = require('@swc/helpers/_/_type_of');
9
- var instantsearchUiComponents = require('instantsearch-ui-components');
10
- var React = require('react');
11
- var reactInstantsearchCore = require('react-instantsearch-core');
12
- var AutocompleteSearch = require('../components/AutocompleteSearch.js');
13
- var ReverseHighlight = require('./ReverseHighlight.js');
14
-
15
- var Autocomplete = instantsearchUiComponents.createAutocompleteComponent({
16
- createElement: React.createElement,
17
- Fragment: React.Fragment
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "EXPERIMENTAL_Autocomplete", {
7
+ enumerable: true,
8
+ get: function() {
9
+ return EXPERIMENTAL_Autocomplete;
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_spread_props = require("@swc/helpers/_/_object_spread_props");
15
+ var _object_without_properties = require("@swc/helpers/_/_object_without_properties");
16
+ var _sliced_to_array = require("@swc/helpers/_/_sliced_to_array");
17
+ var _to_consumable_array = require("@swc/helpers/_/_to_consumable_array");
18
+ var _type_of = require("@swc/helpers/_/_type_of");
19
+ var _instantsearchuicomponents = require("instantsearch-ui-components");
20
+ require("instantsearch.js/cjs/lib/utils");
21
+ var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
22
+ var _reactinstantsearchcore = require("react-instantsearch-core");
23
+ var _AutocompleteSearch = require("../components/AutocompleteSearch");
24
+ var _Highlight = require("./Highlight");
25
+ var _ReverseHighlight = require("./ReverseHighlight");
26
+ var Autocomplete = (0, _instantsearchuicomponents.createAutocompleteComponent)({
27
+ createElement: _react.createElement,
28
+ Fragment: _react.Fragment
29
+ });
30
+ var AutocompletePanel = (0, _instantsearchuicomponents.createAutocompletePanelComponent)({
31
+ createElement: _react.createElement,
32
+ Fragment: _react.Fragment
18
33
  });
19
- var AutocompletePanel = instantsearchUiComponents.createAutocompletePanelComponent({
20
- createElement: React.createElement,
21
- Fragment: React.Fragment
34
+ var AutocompleteIndex = (0, _instantsearchuicomponents.createAutocompleteIndexComponent)({
35
+ createElement: _react.createElement,
36
+ Fragment: _react.Fragment
22
37
  });
23
- var AutocompleteIndex = instantsearchUiComponents.createAutocompleteIndexComponent({
24
- createElement: React.createElement,
25
- Fragment: React.Fragment
38
+ var AutocompleteSuggestion = (0, _instantsearchuicomponents.createAutocompleteSuggestionComponent)({
39
+ createElement: _react.createElement,
40
+ Fragment: _react.Fragment
26
41
  });
27
- var AutocompleteSuggestion = instantsearchUiComponents.createAutocompleteSuggestionComponent({
28
- createElement: React.createElement,
29
- Fragment: React.Fragment
42
+ var AutocompletePromptSuggestion = (0, _instantsearchuicomponents.createAutocompletePromptSuggestionComponent)({
43
+ createElement: _react.createElement,
44
+ Fragment: _react.Fragment
30
45
  });
31
- var AutocompleteRecentSearch = instantsearchUiComponents.createAutocompleteRecentSearchComponent({
32
- createElement: React.createElement,
33
- Fragment: React.Fragment
46
+ var AutocompleteRecentSearch = (0, _instantsearchuicomponents.createAutocompleteRecentSearchComponent)({
47
+ createElement: _react.createElement,
48
+ Fragment: _react.Fragment
34
49
  });
35
- var AutocompleteDetachedContainer = instantsearchUiComponents.createAutocompleteDetachedContainerComponent({
36
- createElement: React.createElement,
37
- Fragment: React.Fragment
50
+ var AutocompleteDetachedContainer = (0, _instantsearchuicomponents.createAutocompleteDetachedContainerComponent)({
51
+ createElement: _react.createElement,
52
+ Fragment: _react.Fragment
38
53
  });
39
- var AutocompleteDetachedOverlay = instantsearchUiComponents.createAutocompleteDetachedOverlayComponent({
40
- createElement: React.createElement,
41
- Fragment: React.Fragment
54
+ var AutocompleteDetachedOverlay = (0, _instantsearchuicomponents.createAutocompleteDetachedOverlayComponent)({
55
+ createElement: _react.createElement,
56
+ Fragment: _react.Fragment
42
57
  });
43
- var AutocompleteDetachedFormContainer = instantsearchUiComponents.createAutocompleteDetachedFormContainerComponent({
44
- createElement: React.createElement,
45
- Fragment: React.Fragment
58
+ var AutocompleteDetachedFormContainer = (0, _instantsearchuicomponents.createAutocompleteDetachedFormContainerComponent)({
59
+ createElement: _react.createElement,
60
+ Fragment: _react.Fragment
46
61
  });
47
- var AutocompleteDetachedSearchButton = instantsearchUiComponents.createAutocompleteDetachedSearchButtonComponent({
48
- createElement: React.createElement,
49
- Fragment: React.Fragment
62
+ var AutocompleteDetachedSearchButton = (0, _instantsearchuicomponents.createAutocompleteDetachedSearchButtonComponent)({
63
+ createElement: _react.createElement,
64
+ Fragment: _react.Fragment
50
65
  });
51
66
  var id = 0;
52
- var usePropGetters = instantsearchUiComponents.createAutocompletePropGetters({
53
- useEffect: React.useEffect,
54
- useId: React.useId || function() {
55
- return React.useState(function() {
67
+ var usePropGetters = (0, _instantsearchuicomponents.createAutocompletePropGetters)({
68
+ useEffect: _react.useEffect,
69
+ useId: _react.default.useId || function() {
70
+ return _react.default.useState(function() {
56
71
  return (id++).toString();
57
72
  });
58
73
  },
59
- useMemo: React.useMemo,
60
- useRef: React.useRef,
61
- useState: React.useState
74
+ useMemo: _react.useMemo,
75
+ useRef: _react.useRef,
76
+ useState: _react.useState
62
77
  });
63
- var useStorage = instantsearchUiComponents.createAutocompleteStorage({
64
- useEffect: React.useEffect,
65
- useMemo: React.useMemo,
66
- useState: React.useState
78
+ var useStorage = (0, _instantsearchuicomponents.createAutocompleteStorage)({
79
+ useEffect: _react.useEffect,
80
+ useMemo: _react.useMemo,
81
+ useState: _react.useState
67
82
  });
68
83
  var DEFAULT_DETACHED_MEDIA_QUERY = '(max-width: 680px)';
69
84
  var DEFAULT_DETACHED_MODAL_MEDIA_QUERY = '(min-width: 680px)';
@@ -98,18 +113,18 @@ function getMediaQueryList(mediaQuery) {
98
113
  /**
99
114
  * Hook to manage detached (mobile) mode state
100
115
  */ function useDetachedMode(mediaQuery) {
101
- var resolvedMediaQuery = React.useMemo(function() {
116
+ var resolvedMediaQuery = (0, _react.useMemo)(function() {
102
117
  return resolveMediaQuery(mediaQuery, DETACHED_MEDIA_QUERY_CSS_VAR, DEFAULT_DETACHED_MEDIA_QUERY);
103
118
  }, [
104
119
  mediaQuery
105
120
  ]);
106
- var _useState = _sliced_to_array._(React.useState(function() {
121
+ var _useState = _sliced_to_array._((0, _react.useState)(function() {
107
122
  var _getMediaQueryList;
108
123
  return resolvedMediaQuery ? Boolean((_getMediaQueryList = getMediaQueryList(resolvedMediaQuery)) === null || _getMediaQueryList === void 0 ? void 0 : _getMediaQueryList.matches) : false;
109
124
  }), 2), isDetached = _useState[0], setIsDetached = _useState[1];
110
- var _useState1 = _sliced_to_array._(React.useState(false), 2), isModalOpen = _useState1[0], setIsModalOpen = _useState1[1];
111
- var _useState2 = _sliced_to_array._(React.useState(false), 2), isModalDetached = _useState2[0], setIsModalDetached = _useState2[1];
112
- React.useEffect(function() {
125
+ var _useState1 = _sliced_to_array._((0, _react.useState)(false), 2), isModalOpen = _useState1[0], setIsModalOpen = _useState1[1];
126
+ var _useState2 = _sliced_to_array._((0, _react.useState)(false), 2), isModalDetached = _useState2[0], setIsModalDetached = _useState2[1];
127
+ (0, _react.useEffect)(function() {
113
128
  if (!resolvedMediaQuery) {
114
129
  setIsDetached(false);
115
130
  return function() {};
@@ -135,7 +150,7 @@ function getMediaQueryList(mediaQuery) {
135
150
  resolvedMediaQuery,
136
151
  isDetached
137
152
  ]);
138
- React.useEffect(function() {
153
+ (0, _react.useEffect)(function() {
139
154
  if (!isDetached) {
140
155
  setIsModalDetached(false);
141
156
  return function() {};
@@ -161,7 +176,7 @@ function getMediaQueryList(mediaQuery) {
161
176
  }, [
162
177
  isDetached
163
178
  ]);
164
- React.useEffect(function() {
179
+ (0, _react.useEffect)(function() {
165
180
  if (typeof document === 'undefined') return function() {};
166
181
  if (isModalOpen) {
167
182
  var scrollY = window.scrollY;
@@ -185,9 +200,10 @@ function getMediaQueryList(mediaQuery) {
185
200
  };
186
201
  }
187
202
  function EXPERIMENTAL_Autocomplete(_0) {
188
- var _0_indices = _0.indices, indices = _0_indices === void 0 ? [] : _0_indices, showSuggestions = _0.showSuggestions, showRecent = _0.showRecent, userSearchParameters = _0.searchParameters, detachedMediaQuery = _0.detachedMediaQuery, tmp = _0.translations, userTranslations = tmp === void 0 ? {} : tmp, props = _object_without_properties._(_0, [
203
+ var _0_indices = _0.indices, indices = _0_indices === void 0 ? [] : _0_indices, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, showRecent = _0.showRecent, userSearchParameters = _0.searchParameters, detachedMediaQuery = _0.detachedMediaQuery, tmp = _0.translations, userTranslations = tmp === void 0 ? {} : tmp, props = _object_without_properties._(_0, [
189
204
  "indices",
190
- "showSuggestions",
205
+ "showQuerySuggestions",
206
+ "showPromptSuggestions",
191
207
  "showRecent",
192
208
  "searchParameters",
193
209
  "detachedMediaQuery",
@@ -195,8 +211,8 @@ function EXPERIMENTAL_Autocomplete(_0) {
195
211
  ]);
196
212
  var _showRecent_classNames, _showRecent_classNames1, _showRecent_classNames2, _showRecent_classNames3;
197
213
  var translations = _object_spread._({}, DEFAULT_TRANSLATIONS, userTranslations);
198
- var _useInstantSearch = reactInstantsearchCore.useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, indexRenderState = _useInstantSearch.indexRenderState, status = _useInstantSearch.status;
199
- var refine = reactInstantsearchCore.useSearchBox({}, {
214
+ var _useInstantSearch = (0, _reactinstantsearchcore.useInstantSearch)(), indexUiState = _useInstantSearch.indexUiState, indexRenderState = _useInstantSearch.indexRenderState, status = _useInstantSearch.status;
215
+ var refine = (0, _reactinstantsearchcore.useSearchBox)({}, {
200
216
  $$type: 'ais.autocomplete',
201
217
  $$widgetType: 'ais.autocomplete'
202
218
  }).refine;
@@ -205,56 +221,89 @@ function EXPERIMENTAL_Autocomplete(_0) {
205
221
  hitsPerPage: 5
206
222
  }, userSearchParameters);
207
223
  var indicesConfig = _to_consumable_array._(indices);
208
- if (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) {
209
- var _showSuggestions_classNames, _showSuggestions_classNames1, _showSuggestions_classNames2, _showSuggestions_classNames3;
224
+ if (showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName) {
225
+ var _showQuerySuggestions_classNames, _showQuerySuggestions_classNames1, _showQuerySuggestions_classNames2, _showQuerySuggestions_classNames3;
210
226
  indicesConfig.unshift({
211
- indexName: showSuggestions.indexName,
212
- headerComponent: showSuggestions.headerComponent,
213
- itemComponent: showSuggestions.itemComponent || function(param) {
227
+ indexName: showQuerySuggestions.indexName,
228
+ headerComponent: showQuerySuggestions.headerComponent,
229
+ itemComponent: showQuerySuggestions.itemComponent || function(param) {
214
230
  var item = param.item, onSelect = param.onSelect, onApply = param.onApply;
215
- return /*#__PURE__*/ React.createElement(AutocompleteSuggestion, {
231
+ return /*#__PURE__*/ _react.default.createElement(AutocompleteSuggestion, {
216
232
  item: item,
217
233
  onSelect: onSelect,
218
234
  onApply: onApply
219
- }, /*#__PURE__*/ React.createElement(ConditionalReverseHighlight, {
235
+ }, /*#__PURE__*/ _react.default.createElement(ConditionalReverseHighlight, {
220
236
  item: item
221
237
  }));
222
238
  },
223
239
  classNames: {
224
- root: instantsearchUiComponents.cx('ais-AutocompleteSuggestions', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions_classNames = showSuggestions.classNames) === null || _showSuggestions_classNames === void 0 ? void 0 : _showSuggestions_classNames.root),
225
- list: instantsearchUiComponents.cx('ais-AutocompleteSuggestionsList', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions_classNames1 = showSuggestions.classNames) === null || _showSuggestions_classNames1 === void 0 ? void 0 : _showSuggestions_classNames1.list),
226
- header: instantsearchUiComponents.cx('ais-AutocompleteSuggestionsHeader', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions_classNames2 = showSuggestions.classNames) === null || _showSuggestions_classNames2 === void 0 ? void 0 : _showSuggestions_classNames2.header),
227
- item: instantsearchUiComponents.cx('ais-AutocompleteSuggestionsItem', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions_classNames3 = showSuggestions.classNames) === null || _showSuggestions_classNames3 === void 0 ? void 0 : _showSuggestions_classNames3.item)
240
+ root: (0, _instantsearchuicomponents.cx)('ais-AutocompleteSuggestions', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames === void 0 ? void 0 : _showQuerySuggestions_classNames.root),
241
+ list: (0, _instantsearchuicomponents.cx)('ais-AutocompleteSuggestionsList', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames1 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames1 === void 0 ? void 0 : _showQuerySuggestions_classNames1.list),
242
+ header: (0, _instantsearchuicomponents.cx)('ais-AutocompleteSuggestionsHeader', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames2 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames2 === void 0 ? void 0 : _showQuerySuggestions_classNames2.header),
243
+ item: (0, _instantsearchuicomponents.cx)('ais-AutocompleteSuggestionsItem', showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : (_showQuerySuggestions_classNames3 = showQuerySuggestions.classNames) === null || _showQuerySuggestions_classNames3 === void 0 ? void 0 : _showQuerySuggestions_classNames3.item)
228
244
  },
245
+ searchParameters: _object_spread._({
246
+ hitsPerPage: 3
247
+ }, showQuerySuggestions.searchParameters),
229
248
  getQuery: function getQuery(item) {
230
249
  return item.query;
231
250
  },
232
- getURL: showSuggestions.getURL
251
+ getURL: showQuerySuggestions.getURL
252
+ });
253
+ }
254
+ if (showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName) {
255
+ var _showPromptSuggestions_classNames, _showPromptSuggestions_classNames1, _showPromptSuggestions_classNames2, _showPromptSuggestions_classNames3;
256
+ indicesConfig.push({
257
+ indexName: showPromptSuggestions.indexName,
258
+ headerComponent: showPromptSuggestions.headerComponent,
259
+ itemComponent: showPromptSuggestions.itemComponent || function(param) {
260
+ var item = param.item, onSelect = param.onSelect;
261
+ return /*#__PURE__*/ _react.default.createElement(AutocompletePromptSuggestion, {
262
+ item: item,
263
+ onSelect: onSelect
264
+ }, /*#__PURE__*/ _react.default.createElement(ConditionalHighlight, {
265
+ item: item,
266
+ attribute: "prompt"
267
+ }));
268
+ },
269
+ classNames: {
270
+ root: (0, _instantsearchuicomponents.cx)('ais-AutocompletePromptSuggestions', (_showPromptSuggestions_classNames = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames === void 0 ? void 0 : _showPromptSuggestions_classNames.root),
271
+ list: (0, _instantsearchuicomponents.cx)('ais-AutocompletePromptSuggestionsList', (_showPromptSuggestions_classNames1 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames1 === void 0 ? void 0 : _showPromptSuggestions_classNames1.list),
272
+ header: (0, _instantsearchuicomponents.cx)('ais-AutocompletePromptSuggestionsHeader', (_showPromptSuggestions_classNames2 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames2 === void 0 ? void 0 : _showPromptSuggestions_classNames2.header),
273
+ item: (0, _instantsearchuicomponents.cx)('ais-AutocompletePromptSuggestionsItem', (_showPromptSuggestions_classNames3 = showPromptSuggestions.classNames) === null || _showPromptSuggestions_classNames3 === void 0 ? void 0 : _showPromptSuggestions_classNames3.item)
274
+ },
275
+ searchParameters: _object_spread._({
276
+ hitsPerPage: 3
277
+ }, showPromptSuggestions.searchParameters),
278
+ getQuery: function getQuery(item) {
279
+ return item.prompt;
280
+ },
281
+ getURL: showPromptSuggestions.getURL
233
282
  });
234
283
  }
235
284
  var recentSearchConfig = showRecent ? {
236
285
  headerComponent: (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? showRecent.headerComponent : undefined,
237
286
  itemComponent: (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' && showRecent.itemComponent ? showRecent.itemComponent : AutocompleteRecentSearch,
238
287
  classNames: {
239
- root: instantsearchUiComponents.cx('ais-AutocompleteRecentSearches', (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? (_showRecent_classNames = showRecent.classNames) === null || _showRecent_classNames === void 0 ? void 0 : _showRecent_classNames.root : undefined),
240
- list: instantsearchUiComponents.cx('ais-AutocompleteRecentSearchesList', (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? (_showRecent_classNames1 = showRecent.classNames) === null || _showRecent_classNames1 === void 0 ? void 0 : _showRecent_classNames1.list : undefined),
241
- header: instantsearchUiComponents.cx('ais-AutocompleteRecentSearchesHeader', (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? (_showRecent_classNames2 = showRecent.classNames) === null || _showRecent_classNames2 === void 0 ? void 0 : _showRecent_classNames2.header : undefined),
242
- item: instantsearchUiComponents.cx('ais-AutocompleteRecentSearchesItem', (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? (_showRecent_classNames3 = showRecent.classNames) === null || _showRecent_classNames3 === void 0 ? void 0 : _showRecent_classNames3.item : undefined)
288
+ root: (0, _instantsearchuicomponents.cx)('ais-AutocompleteRecentSearches', (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? (_showRecent_classNames = showRecent.classNames) === null || _showRecent_classNames === void 0 ? void 0 : _showRecent_classNames.root : undefined),
289
+ list: (0, _instantsearchuicomponents.cx)('ais-AutocompleteRecentSearchesList', (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? (_showRecent_classNames1 = showRecent.classNames) === null || _showRecent_classNames1 === void 0 ? void 0 : _showRecent_classNames1.list : undefined),
290
+ header: (0, _instantsearchuicomponents.cx)('ais-AutocompleteRecentSearchesHeader', (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? (_showRecent_classNames2 = showRecent.classNames) === null || _showRecent_classNames2 === void 0 ? void 0 : _showRecent_classNames2.header : undefined),
291
+ item: (0, _instantsearchuicomponents.cx)('ais-AutocompleteRecentSearchesItem', (typeof showRecent === "undefined" ? "undefined" : _type_of._(showRecent)) === 'object' ? (_showRecent_classNames3 = showRecent.classNames) === null || _showRecent_classNames3 === void 0 ? void 0 : _showRecent_classNames3.item : undefined)
243
292
  }
244
293
  } : undefined;
245
- var isSearchPage = React.useMemo(function() {
294
+ var isSearchPage = (0, _react.useMemo)(function() {
246
295
  return typeof indexRenderState.hits !== 'undefined' || typeof indexRenderState.infiniteHits !== 'undefined';
247
296
  }, [
248
297
  indexRenderState
249
298
  ]);
250
- return /*#__PURE__*/ React.createElement(React.Fragment, null, /*#__PURE__*/ React.createElement(reactInstantsearchCore.Index, {
299
+ return /*#__PURE__*/ _react.default.createElement(_react.Fragment, null, /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Index, {
251
300
  EXPERIMENTAL_isolated: true
252
- }, /*#__PURE__*/ React.createElement(reactInstantsearchCore.Configure, searchParameters), indicesConfig.map(function(index) {
253
- return /*#__PURE__*/ React.createElement(reactInstantsearchCore.Index, {
301
+ }, /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Configure, searchParameters), indicesConfig.map(function(index) {
302
+ return /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Index, {
254
303
  key: index.indexName,
255
304
  indexName: index.indexName
256
- }, /*#__PURE__*/ React.createElement(reactInstantsearchCore.Configure, index.searchParameters));
257
- }), /*#__PURE__*/ React.createElement(InnerAutocomplete, _object_spread_props._(_object_spread._({}, props), {
305
+ }, /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Configure, index.searchParameters));
306
+ }), /*#__PURE__*/ _react.default.createElement(InnerAutocomplete, _object_spread_props._(_object_spread._({}, props), {
258
307
  indicesConfig: indicesConfig,
259
308
  refineSearchBox: refine,
260
309
  isSearchStalled: isSearchStalled,
@@ -262,13 +311,15 @@ function EXPERIMENTAL_Autocomplete(_0) {
262
311
  isSearchPage: isSearchPage,
263
312
  showRecent: showRecent,
264
313
  recentSearchConfig: recentSearchConfig,
265
- showSuggestions: showSuggestions,
314
+ showQuerySuggestions: showQuerySuggestions,
266
315
  detachedMediaQuery: detachedMediaQuery,
267
- translations: translations
316
+ translations: translations,
317
+ showPromptSuggestions: showPromptSuggestions,
318
+ chatRenderState: indexRenderState.chat
268
319
  }))));
269
320
  }
270
321
  function InnerAutocomplete(_0) {
271
- 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, showSuggestions = _0.showSuggestions, transformItems = _0.transformItems, placeholder = _0.placeholder, _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, props = _object_without_properties._(_0, [
272
323
  "indicesConfig",
273
324
  "refineSearchBox",
274
325
  "isSearchStalled",
@@ -279,27 +330,88 @@ function InnerAutocomplete(_0) {
279
330
  "panelComponent",
280
331
  "showRecent",
281
332
  "recentSearchConfig",
282
- "showSuggestions",
333
+ "showQuerySuggestions",
334
+ "showPromptSuggestions",
335
+ "chatRenderState",
283
336
  "transformItems",
284
337
  "placeholder",
338
+ "autoFocus",
285
339
  "detachedMediaQuery",
286
340
  "translations",
287
341
  "classNames"
288
342
  ]);
289
- var _useAutocomplete = reactInstantsearchCore.useAutocomplete({
343
+ var _ref;
344
+ var _showPromptSuggestions_searchParameters;
345
+ var _useAutocomplete = (0, _reactinstantsearchcore.useAutocomplete)({
290
346
  transformItems: transformItems
291
347
  }), indices = _useAutocomplete.indices, refineAutocomplete = _useAutocomplete.refine, currentRefinement = _useAutocomplete.currentRefinement;
292
348
  var _useDetachedMode = useDetachedMode(detachedMediaQuery), isDetached = _useDetachedMode.isDetached, isModalDetached = _useDetachedMode.isModalDetached, isModalOpen = _useDetachedMode.isModalOpen, setIsModalOpen = _useDetachedMode.setIsModalOpen;
293
- var previousIsDetachedRef = React.useRef(isDetached);
349
+ var previousIsDetachedRef = (0, _react.useRef)(isDetached);
294
350
  var _useStorage = useStorage({
295
351
  showRecent: showRecent,
296
352
  query: currentRefinement,
297
353
  indices: indices,
298
354
  indicesConfig: indicesConfig,
299
- suggestionsIndexName: showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName
355
+ suggestionsIndexName: showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName
300
356
  }), storage = _useStorage.storage, storageHits = _useStorage.storageHits, indicesForPropGetters = _useStorage.indicesForPropGetters, indicesConfigForPropGetters = _useStorage.indicesConfigForPropGetters;
357
+ var promptSuggestionsIndexName = showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName;
358
+ var promptSuggestionsLimit = (_ref = showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : (_showPromptSuggestions_searchParameters = showPromptSuggestions.searchParameters) === null || _showPromptSuggestions_searchParameters === void 0 ? void 0 : _showPromptSuggestions_searchParameters.hitsPerPage) !== null && _ref !== void 0 ? _ref : 3;
359
+ var indicesForPanel = (0, _react.useMemo)(function() {
360
+ return indices.map(function(index) {
361
+ var dedupedHits = index.indexName === (showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName) && showRecent ? index.hits.filter(function(suggestionHit) {
362
+ return !storageHits.find(function(storageHit) {
363
+ return storageHit.query === suggestionHit.query;
364
+ });
365
+ }) : index.hits;
366
+ if (index.indexName !== promptSuggestionsIndexName) {
367
+ return _object_spread_props._(_object_spread._({}, index), {
368
+ hits: dedupedHits
369
+ });
370
+ }
371
+ return _object_spread_props._(_object_spread._({}, index), {
372
+ hits: (0, _instantsearchuicomponents.getPromptSuggestionHits)({
373
+ hits: dedupedHits,
374
+ limit: promptSuggestionsLimit
375
+ })
376
+ });
377
+ });
378
+ }, [
379
+ indices,
380
+ promptSuggestionsIndexName,
381
+ promptSuggestionsLimit,
382
+ showRecent,
383
+ showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName,
384
+ storageHits
385
+ ]);
386
+ var indicesForPropGettersWithPromptSuggestions = (0, _react.useMemo)(function() {
387
+ return indicesForPropGetters.map(function(index) {
388
+ if (index.indexName !== promptSuggestionsIndexName) {
389
+ return index;
390
+ }
391
+ return _object_spread_props._(_object_spread._({}, index), {
392
+ hits: (0, _instantsearchuicomponents.getPromptSuggestionHits)({
393
+ hits: index.hits,
394
+ limit: promptSuggestionsLimit
395
+ })
396
+ });
397
+ });
398
+ }, [
399
+ indicesForPropGetters,
400
+ promptSuggestionsIndexName,
401
+ promptSuggestionsLimit
402
+ ]);
403
+ (0, _react.useRef)(false);
404
+ var allIndicesEmpty = indicesForPanel.every(function(param) {
405
+ var hits = param.hits;
406
+ return hits.length === 0;
407
+ });
408
+ var recentEmpty = !storageHits || storageHits.length === 0;
409
+ var hasNoResultsTemplate = indicesConfig.some(function(c) {
410
+ return c.noResultsComponent !== undefined;
411
+ });
412
+ var shouldHideEmptyPanel = allIndicesEmpty && recentEmpty && !hasNoResultsTemplate && !PanelComponent;
301
413
  var _usePropGetters = usePropGetters({
302
- indices: indicesForPropGetters,
414
+ indices: indicesForPropGettersWithPromptSuggestions,
303
415
  indicesConfig: indicesConfigForPropGetters,
304
416
  onRefine: function onRefine(query) {
305
417
  refineAutocomplete(query);
@@ -310,7 +422,19 @@ function InnerAutocomplete(_0) {
310
422
  refineAutocomplete(query);
311
423
  },
312
424
  onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function(param) {
313
- var query = param.query, setQuery = param.setQuery, url = param.url;
425
+ var item = param.item, query = param.query, setQuery = param.setQuery, url = param.url;
426
+ if ((0, _instantsearchuicomponents.isPromptSuggestion)(item)) {
427
+ var chatRenderStateWithFocus = chatRenderState;
428
+ if (chatRenderStateWithFocus) {
429
+ var _chatRenderStateWithFocus_setOpen, _chatRenderStateWithFocus_focusInput, _chatRenderStateWithFocus_sendMessage;
430
+ (_chatRenderStateWithFocus_setOpen = chatRenderStateWithFocus.setOpen) === null || _chatRenderStateWithFocus_setOpen === void 0 ? void 0 : _chatRenderStateWithFocus_setOpen.call(chatRenderStateWithFocus, true);
431
+ (_chatRenderStateWithFocus_focusInput = chatRenderStateWithFocus.focusInput) === null || _chatRenderStateWithFocus_focusInput === void 0 ? void 0 : _chatRenderStateWithFocus_focusInput.call(chatRenderStateWithFocus);
432
+ (_chatRenderStateWithFocus_sendMessage = chatRenderStateWithFocus.sendMessage) === null || _chatRenderStateWithFocus_sendMessage === void 0 ? void 0 : _chatRenderStateWithFocus_sendMessage.call(chatRenderStateWithFocus, {
433
+ text: item.prompt
434
+ });
435
+ return;
436
+ }
437
+ }
314
438
  if (url) {
315
439
  window.location.href = url;
316
440
  return;
@@ -330,10 +454,12 @@ function InnerAutocomplete(_0) {
330
454
  }
331
455
  },
332
456
  placeholder: placeholder,
333
- isDetached: isDetached
457
+ isDetached: isDetached,
458
+ shouldHidePanel: shouldHideEmptyPanel,
459
+ autoFocus: autoFocus
334
460
  }), getInputProps = _usePropGetters.getInputProps, getItemProps = _usePropGetters.getItemProps, getPanelProps = _usePropGetters.getPanelProps, getRootProps = _usePropGetters.getRootProps, isOpen = _usePropGetters.isOpen, setIsOpen = _usePropGetters.setIsOpen, focusInput = _usePropGetters.focusInput;
335
461
  // Open panel and focus input when modal opens
336
- React.useEffect(function() {
462
+ (0, _react.useEffect)(function() {
337
463
  if (isDetached && isModalOpen) {
338
464
  setIsOpen(true);
339
465
  // Focus input to show the keyboard on mobile
@@ -346,7 +472,7 @@ function InnerAutocomplete(_0) {
346
472
  focusInput
347
473
  ]);
348
474
  // Keep the modal open if the panel was open before switching to detached
349
- React.useEffect(function() {
475
+ (0, _react.useEffect)(function() {
350
476
  var wasDetached = previousIsDetachedRef.current;
351
477
  var switchedToDetached = !wasDetached && isDetached;
352
478
  if (switchedToDetached && isOpen) {
@@ -361,19 +487,19 @@ function InnerAutocomplete(_0) {
361
487
  var elements = {};
362
488
  if (showRecent && recentSearchConfig) {
363
489
  var RecentSearchItemComponent = recentSearchConfig.itemComponent;
364
- elements.recent = /*#__PURE__*/ React.createElement(AutocompleteIndex, {
490
+ elements.recent = /*#__PURE__*/ _react.default.createElement(AutocompleteIndex, {
365
491
  HeaderComponent: recentSearchConfig.headerComponent,
366
492
  // @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
367
493
  ItemComponent: function ItemComponent(param) {
368
494
  var item = param.item, onSelect = param.onSelect, onApply = param.onApply;
369
- return /*#__PURE__*/ React.createElement(RecentSearchItemComponent, {
495
+ return /*#__PURE__*/ _react.default.createElement(RecentSearchItemComponent, {
370
496
  item: item,
371
497
  onSelect: onSelect,
372
498
  onRemoveRecentSearch: function onRemoveRecentSearch() {
373
499
  return storage.onRemove(item.query);
374
500
  },
375
501
  onApply: onApply
376
- }, /*#__PURE__*/ React.createElement(ConditionalReverseHighlight, {
502
+ }, /*#__PURE__*/ _react.default.createElement(ConditionalReverseHighlight, {
377
503
  item: item
378
504
  }));
379
505
  },
@@ -383,27 +509,28 @@ function InnerAutocomplete(_0) {
383
509
  key: "recentSearches"
384
510
  });
385
511
  }
386
- indices.forEach(function(param) {
512
+ indicesForPanel.forEach(function(param) {
387
513
  var indexId = param.indexId, indexName = param.indexName, hits = param.hits;
388
- var elementId = indexName === (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) ? 'suggestions' : indexName;
389
- var filteredHits = elementId === 'suggestions' && showRecent ? hits.filter(function(suggestionHit) {
390
- return !storageHits.find(function(storageHit) {
391
- return storageHit.query === suggestionHit.query;
392
- });
393
- }) : hits;
514
+ var elementId = indexName;
515
+ if (indexName === (showQuerySuggestions === null || showQuerySuggestions === void 0 ? void 0 : showQuerySuggestions.indexName)) {
516
+ elementId = 'suggestions';
517
+ } else if (indexName === (showPromptSuggestions === null || showPromptSuggestions === void 0 ? void 0 : showPromptSuggestions.indexName)) {
518
+ elementId = 'promptSuggestions';
519
+ }
394
520
  var currentIndexConfig = indicesConfig.find(function(config) {
395
521
  return config.indexName === indexName;
396
522
  });
397
523
  if (!currentIndexConfig) {
398
524
  return;
399
525
  }
400
- elements[elementId] = /*#__PURE__*/ React.createElement(AutocompleteIndex, {
526
+ elements[elementId] = /*#__PURE__*/ _react.default.createElement(AutocompleteIndex, {
401
527
  key: indexId,
402
528
  // @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
403
529
  HeaderComponent: currentIndexConfig.headerComponent,
404
530
  // @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
405
531
  ItemComponent: currentIndexConfig.itemComponent,
406
- items: filteredHits.map(function(item) {
532
+ NoResultsComponent: currentIndexConfig.noResultsComponent,
533
+ items: hits.map(function(item) {
407
534
  return _object_spread_props._(_object_spread._({}, item), {
408
535
  __indexName: indexId
409
536
  });
@@ -412,7 +539,7 @@ function InnerAutocomplete(_0) {
412
539
  classNames: currentIndexConfig.classNames
413
540
  });
414
541
  });
415
- var searchBoxContent = /*#__PURE__*/ React.createElement(AutocompleteSearch.AutocompleteSearch, {
542
+ var searchBoxContent = /*#__PURE__*/ _react.default.createElement(_AutocompleteSearch.AutocompleteSearch, {
416
543
  inputProps: getInputProps(),
417
544
  clearQuery: function clearQuery() {
418
545
  refineSearchBox('');
@@ -425,19 +552,23 @@ function InnerAutocomplete(_0) {
425
552
  refine: refineSearchBox,
426
553
  isSearchStalled: isSearchStalled
427
554
  });
428
- var panelContent = /*#__PURE__*/ React.createElement(AutocompletePanel, getPanelProps(), PanelComponent ? /*#__PURE__*/ React.createElement(PanelComponent, {
555
+ var panelContent = /*#__PURE__*/ _react.default.createElement(AutocompletePanel, getPanelProps(), PanelComponent ? /*#__PURE__*/ _react.default.createElement(PanelComponent, {
429
556
  elements: elements,
430
- indices: indices
557
+ indices: indicesForPanel
431
558
  }) : Object.keys(elements).map(function(elementId) {
432
559
  return elements[elementId];
433
560
  }));
434
561
  var detachedContainerClassNames = isModalDetached ? _object_spread_props._(_object_spread._({}, classNames), {
435
- detachedContainer: instantsearchUiComponents.cx('ais-AutocompleteDetachedContainer--modal', classNames === null || classNames === void 0 ? void 0 : classNames.detachedContainer)
562
+ detachedContainer: (0, _instantsearchuicomponents.cx)('ais-AutocompleteDetachedContainer--modal', classNames === null || classNames === void 0 ? void 0 : classNames.detachedContainer)
436
563
  }) : classNames;
564
+ var _getRootProps = getRootProps(), rootRef = _getRootProps.ref, rootProps = _object_without_properties._(_getRootProps, [
565
+ "ref"
566
+ ]);
437
567
  if (isDetached) {
438
- return /*#__PURE__*/ React.createElement(Autocomplete, _object_spread_props._(_object_spread._({}, props, getRootProps()), {
568
+ return /*#__PURE__*/ _react.default.createElement(Autocomplete, _object_spread_props._(_object_spread._({}, props, rootProps), {
569
+ rootRef: rootRef,
439
570
  classNames: classNames
440
- }), /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
571
+ }), /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedSearchButton, {
441
572
  query: currentRefinement || indexUiState.query || '',
442
573
  placeholder: placeholder,
443
574
  classNames: classNames,
@@ -450,15 +581,15 @@ function InnerAutocomplete(_0) {
450
581
  refineAutocomplete('');
451
582
  },
452
583
  translations: translations
453
- }), isModalOpen && /*#__PURE__*/ React.createElement(AutocompleteDetachedOverlay, {
584
+ }), isModalOpen && /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedOverlay, {
454
585
  classNames: classNames,
455
586
  onClose: function onClose() {
456
587
  setIsModalOpen(false);
457
588
  setIsOpen(false);
458
589
  }
459
- }, /*#__PURE__*/ React.createElement(AutocompleteDetachedContainer, {
590
+ }, /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedContainer, {
460
591
  classNames: detachedContainerClassNames
461
- }, /*#__PURE__*/ React.createElement(AutocompleteDetachedFormContainer, {
592
+ }, /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedFormContainer, {
462
593
  classNames: classNames,
463
594
  onCancel: function onCancel() {
464
595
  setIsModalOpen(false);
@@ -468,7 +599,8 @@ function InnerAutocomplete(_0) {
468
599
  }, searchBoxContent), panelContent)));
469
600
  }
470
601
  // Normal (non-detached) rendering
471
- return /*#__PURE__*/ React.createElement(Autocomplete, _object_spread_props._(_object_spread._({}, props, getRootProps()), {
602
+ return /*#__PURE__*/ _react.default.createElement(Autocomplete, _object_spread_props._(_object_spread._({}, props, rootProps), {
603
+ rootRef: rootRef,
472
604
  classNames: classNames
473
605
  }), searchBoxContent, panelContent);
474
606
  }
@@ -479,10 +611,20 @@ function ConditionalReverseHighlight(param) {
479
611
  item._highlightResult.query.matchLevel === 'none') {
480
612
  return item.query;
481
613
  }
482
- return /*#__PURE__*/ React.createElement(ReverseHighlight.ReverseHighlight, {
614
+ return /*#__PURE__*/ _react.default.createElement(_ReverseHighlight.ReverseHighlight, {
483
615
  attribute: "query",
484
616
  hit: item
485
617
  });
486
618
  }
487
-
488
- exports.EXPERIMENTAL_Autocomplete = EXPERIMENTAL_Autocomplete;
619
+ function ConditionalHighlight(param) {
620
+ var item = param.item, _param_attribute = param.attribute, attribute = _param_attribute === void 0 ? 'query' : _param_attribute;
621
+ var _item__highlightResult;
622
+ if (!((_item__highlightResult = item._highlightResult) === null || _item__highlightResult === void 0 ? void 0 : _item__highlightResult[attribute]) || // @ts-expect-error - we should not have matchLevel as arrays here
623
+ item._highlightResult[attribute].matchLevel === 'none') {
624
+ return /*#__PURE__*/ _react.default.createElement(_react.default.Fragment, null, item[attribute]);
625
+ }
626
+ return /*#__PURE__*/ _react.default.createElement(_Highlight.Highlight, {
627
+ attribute: attribute,
628
+ hit: item
629
+ });
630
+ }