instantsearch.js 4.82.0 → 4.83.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.
@@ -180,6 +180,16 @@ var connectChat = exports.default = function connectChat(renderFn) {
180
180
  widgetType: this.$$type
181
181
  });
182
182
  }
183
+ var toolsWithAddToolResult = {};
184
+ Object.entries(tools).forEach(function (_ref4) {
185
+ var _ref5 = _slicedToArray(_ref4, 2),
186
+ key = _ref5[0],
187
+ tool = _ref5[1];
188
+ var toolWithAddToolResult = _objectSpread(_objectSpread({}, tool), {}, {
189
+ addToolResult: _chatInstance.addToolResult
190
+ });
191
+ toolsWithAddToolResult[key] = toolWithAddToolResult;
192
+ });
183
193
  return {
184
194
  indexUiState: instantSearchInstance.getUiState()[parent.getIndexId()],
185
195
  input: input,
@@ -192,7 +202,7 @@ var connectChat = exports.default = function connectChat(renderFn) {
192
202
  isClearing: isClearing,
193
203
  clearMessages: clearMessages,
194
204
  onClearTransitionEnd: onClearTransitionEnd,
195
- tools: tools,
205
+ tools: toolsWithAddToolResult,
196
206
  widgetParams: widgetParams,
197
207
  // Chat instance render state
198
208
  addToolResult: _chatInstance.addToolResult,
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '4.82.0';
7
+ var _default = exports.default = '4.83.0';
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -23,6 +22,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
23
22
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
24
23
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
25
24
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
25
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
26
26
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
27
27
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
28
28
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
@@ -56,6 +56,10 @@ var AutocompleteSearchBox = (0, _instantsearchUiComponents.createAutocompleteSea
56
56
  createElement: _preact.h,
57
57
  Fragment: _preact.Fragment
58
58
  });
59
+ var AutocompleteRecentSearch = (0, _instantsearchUiComponents.createAutocompleteRecentSearchComponent)({
60
+ createElement: _preact.h,
61
+ Fragment: _preact.Fragment
62
+ });
59
63
  var usePropGetters = (0, _instantsearchUiComponents.createAutocompletePropGetters)({
60
64
  useEffect: _hooks.useEffect,
61
65
  useId: _hooks.useId,
@@ -63,12 +67,18 @@ var usePropGetters = (0, _instantsearchUiComponents.createAutocompletePropGetter
63
67
  useRef: _hooks.useRef,
64
68
  useState: _hooks.useState
65
69
  });
70
+ var useStorage = (0, _instantsearchUiComponents.createAutocompleteStorage)({
71
+ useEffect: _hooks.useEffect,
72
+ useState: _hooks.useState,
73
+ useMemo: _hooks.useMemo
74
+ });
66
75
  var createRenderer = function createRenderer(params) {
67
76
  var instanceId = params.instanceId,
68
77
  containerNode = params.containerNode,
69
78
  rendererParams = _objectWithoutProperties(params, _excluded);
70
79
  return function (connectorParams, isFirstRendering) {
71
80
  if (isFirstRendering) {
81
+ var _targetIndex$getHelpe, _targetIndex$getHelpe2;
72
82
  var isolatedIndex = connectorParams.instantSearchInstance.mainIndex;
73
83
  var targetIndex = connectorParams.instantSearchInstance.mainIndex;
74
84
  (0, _utils.walkIndex)(targetIndex, function (childIndex) {
@@ -82,13 +92,14 @@ var createRenderer = function createRenderer(params) {
82
92
  isolatedIndex: isolatedIndex,
83
93
  targetIndex: targetIndex
84
94
  };
95
+ connectorParams.refine((_targetIndex$getHelpe = (_targetIndex$getHelpe2 = targetIndex.getHelper()) === null || _targetIndex$getHelpe2 === void 0 ? void 0 : _targetIndex$getHelpe2.state.query) !== null && _targetIndex$getHelpe !== void 0 ? _targetIndex$getHelpe : '');
85
96
  return;
86
97
  }
87
98
  (0, _preact.render)((0, _preact.h)(AutocompleteWrapper, _extends({}, rendererParams, connectorParams)), containerNode);
88
99
  };
89
100
  };
90
101
  function AutocompleteWrapper(_ref) {
91
- var _targetIndex$getWidge, _isolatedIndex$getHel;
102
+ var _isolatedIndex$getHel, _targetIndex$getWidge, _showRecent$templates;
92
103
  var indicesConfig = _ref.indicesConfig,
93
104
  indices = _ref.indices,
94
105
  getSearchPageURL = _ref.getSearchPageURL,
@@ -96,9 +107,21 @@ function AutocompleteWrapper(_ref) {
96
107
  refine = _ref.refine,
97
108
  cssClasses = _ref.cssClasses,
98
109
  renderState = _ref.renderState,
99
- instantSearchInstance = _ref.instantSearchInstance;
110
+ instantSearchInstance = _ref.instantSearchInstance,
111
+ showRecent = _ref.showRecent;
100
112
  var isolatedIndex = renderState.isolatedIndex,
101
113
  targetIndex = renderState.targetIndex;
114
+ var searchboxQuery = isolatedIndex === null || isolatedIndex === void 0 ? void 0 : (_isolatedIndex$getHel = isolatedIndex.getHelper()) === null || _isolatedIndex$getHel === void 0 ? void 0 : _isolatedIndex$getHel.state.query;
115
+ var _useStorage = useStorage({
116
+ query: searchboxQuery,
117
+ showRecent: showRecent,
118
+ indices: indices,
119
+ indicesConfig: indicesConfig
120
+ }),
121
+ storage = _useStorage.storage,
122
+ storageHits = _useStorage.storageHits,
123
+ indicesConfigForPropGetters = _useStorage.indicesConfigForPropGetters,
124
+ indicesForPropGetters = _useStorage.indicesForPropGetters;
102
125
  var isSearchPage = (_targetIndex$getWidge = targetIndex === null || targetIndex === void 0 ? void 0 : targetIndex.getWidgets().some(function (_ref2) {
103
126
  var $$type = _ref2.$$type;
104
127
  return ['ais.hits', 'ais.infiniteHits'].includes($$type);
@@ -112,10 +135,11 @@ function AutocompleteWrapper(_ref) {
112
135
  query: query
113
136
  }), _objectSpread2));
114
137
  });
138
+ query.length > 0 && storage.onAdd(query);
115
139
  };
116
140
  var _usePropGetters = usePropGetters({
117
- indices: indices,
118
- indicesConfig: indicesConfig,
141
+ indices: indicesForPropGetters,
142
+ indicesConfig: indicesConfigForPropGetters,
119
143
  onRefine: onRefine,
120
144
  onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function (_ref3) {
121
145
  var query = _ref3.query,
@@ -139,11 +163,32 @@ function AutocompleteWrapper(_ref) {
139
163
  getItemProps = _usePropGetters.getItemProps,
140
164
  getPanelProps = _usePropGetters.getPanelProps,
141
165
  getRootProps = _usePropGetters.getRootProps;
142
- var query = isolatedIndex === null || isolatedIndex === void 0 ? void 0 : (_isolatedIndex$getHel = isolatedIndex.getHelper()) === null || _isolatedIndex$getHel === void 0 ? void 0 : _isolatedIndex$getHel.state.query;
166
+ var AutocompleteRecentSearchComponent = AutocompleteRecentSearch;
167
+ if (_typeof(showRecent) === 'object' && (_showRecent$templates = showRecent.templates) !== null && _showRecent$templates !== void 0 && _showRecent$templates.item) {
168
+ var props = (0, _templating.prepareTemplateProps)({
169
+ defaultTemplates: {},
170
+ templatesConfig: instantSearchInstance.templatesConfig,
171
+ templates: showRecent.templates
172
+ });
173
+ AutocompleteRecentSearchComponent = function AutocompleteRecentSearchComponent(_ref4) {
174
+ var item = _ref4.item,
175
+ onSelect = _ref4.onSelect,
176
+ onRemoveRecentSearch = _ref4.onRemoveRecentSearch;
177
+ return (0, _preact.h)(_Template.default, _extends({}, props, {
178
+ templateKey: "item",
179
+ rootTagName: "fragment",
180
+ data: {
181
+ item: item,
182
+ onSelect: onSelect,
183
+ onRemoveRecentSearch: onRemoveRecentSearch
184
+ }
185
+ }));
186
+ };
187
+ }
143
188
  return (0, _preact.h)(Autocomplete, _extends({}, getRootProps(), {
144
189
  classNames: cssClasses
145
190
  }), (0, _preact.h)(AutocompleteSearchBox, {
146
- query: query || '',
191
+ query: searchboxQuery || '',
147
192
  inputProps: _objectSpread(_objectSpread({}, getInputProps()), {}, {
148
193
  // @ts-ignore - This clashes with some ambient React JSX declarations.
149
194
  onInput: function onInput(evt) {
@@ -154,10 +199,31 @@ function AutocompleteWrapper(_ref) {
154
199
  return onRefine('');
155
200
  },
156
201
  isSearchStalled: instantSearchInstance.status === 'stalled'
157
- }), (0, _preact.h)(AutocompletePanel, getPanelProps(), indices.map(function (_ref4, i) {
202
+ }), (0, _preact.h)(AutocompletePanel, getPanelProps(), showRecent && (0, _preact.h)(AutocompleteIndex
203
+ // @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
204
+ , {
205
+ ItemComponent: function ItemComponent(_ref5) {
206
+ var item = _ref5.item,
207
+ onSelect = _ref5.onSelect;
208
+ return (0, _preact.h)(AutocompleteRecentSearchComponent, {
209
+ item: item,
210
+ onSelect: onSelect,
211
+ onRemoveRecentSearch: function onRemoveRecentSearch() {
212
+ return storage.onRemove(item.query);
213
+ }
214
+ });
215
+ },
216
+ classNames: {
217
+ root: 'ais-AutocompleteRecentSearches',
218
+ list: 'ais-AutocompleteRecentSearchesList',
219
+ item: 'ais-AutocompleteRecentSearchesItem'
220
+ },
221
+ items: storageHits,
222
+ getItemProps: getItemProps
223
+ }), indices.map(function (_ref6, i) {
158
224
  var _indicesConfig$i$temp;
159
- var indexId = _ref4.indexId,
160
- hits = _ref4.hits;
225
+ var indexId = _ref6.indexId,
226
+ hits = _ref6.hits;
161
227
  if (!renderState.indexTemplateProps[i]) {
162
228
  renderState.indexTemplateProps[i] = (0, _templating.prepareTemplateProps)({
163
229
  defaultTemplates: {},
@@ -165,8 +231,8 @@ function AutocompleteWrapper(_ref) {
165
231
  templates: indicesConfig[i].templates
166
232
  });
167
233
  }
168
- var headerComponent = (_indicesConfig$i$temp = indicesConfig[i].templates) !== null && _indicesConfig$i$temp !== void 0 && _indicesConfig$i$temp.header ? function (_ref5) {
169
- var items = _ref5.items;
234
+ var headerComponent = (_indicesConfig$i$temp = indicesConfig[i].templates) !== null && _indicesConfig$i$temp !== void 0 && _indicesConfig$i$temp.header ? function (_ref7) {
235
+ var items = _ref7.items;
170
236
  return (0, _preact.h)(_Template.default, _extends({}, renderState.indexTemplateProps[i], {
171
237
  templateKey: "header",
172
238
  rootTagName: "fragment",
@@ -175,9 +241,9 @@ function AutocompleteWrapper(_ref) {
175
241
  }
176
242
  }));
177
243
  } : undefined;
178
- var itemComponent = function itemComponent(_ref6) {
179
- var item = _ref6.item,
180
- onSelect = _ref6.onSelect;
244
+ var itemComponent = function itemComponent(_ref8) {
245
+ var item = _ref8.item,
246
+ onSelect = _ref8.onSelect;
181
247
  return (0, _preact.h)(_Template.default, _extends({}, renderState.indexTemplateProps[i], {
182
248
  templateKey: "item",
183
249
  rootTagName: "fragment",
@@ -202,18 +268,19 @@ function AutocompleteWrapper(_ref) {
202
268
  })));
203
269
  }
204
270
  function EXPERIMENTAL_autocomplete(widgetParams) {
205
- var _ref7 = widgetParams || {},
206
- container = _ref7.container,
207
- escapeHTML = _ref7.escapeHTML,
208
- _ref7$indices = _ref7.indices,
209
- indices = _ref7$indices === void 0 ? [] : _ref7$indices,
210
- showSuggestions = _ref7.showSuggestions,
211
- getSearchPageURL = _ref7.getSearchPageURL,
212
- onSelect = _ref7.onSelect,
213
- _ref7$templates = _ref7.templates,
214
- templates = _ref7$templates === void 0 ? {} : _ref7$templates,
215
- _ref7$cssClasses = _ref7.cssClasses,
216
- userCssClasses = _ref7$cssClasses === void 0 ? {} : _ref7$cssClasses;
271
+ var _ref9 = widgetParams || {},
272
+ container = _ref9.container,
273
+ escapeHTML = _ref9.escapeHTML,
274
+ _ref9$indices = _ref9.indices,
275
+ indices = _ref9$indices === void 0 ? [] : _ref9$indices,
276
+ showSuggestions = _ref9.showSuggestions,
277
+ showRecent = _ref9.showRecent,
278
+ getSearchPageURL = _ref9.getSearchPageURL,
279
+ onSelect = _ref9.onSelect,
280
+ _ref9$templates = _ref9.templates,
281
+ templates = _ref9$templates === void 0 ? {} : _ref9$templates,
282
+ _ref9$cssClasses = _ref9.cssClasses,
283
+ userCssClasses = _ref9$cssClasses === void 0 ? {} : _ref9$cssClasses;
217
284
  if (!container) {
218
285
  throw new Error(withUsage('The `container` option is required.'));
219
286
  }
@@ -250,6 +317,7 @@ function EXPERIMENTAL_autocomplete(widgetParams) {
250
317
  getSearchPageURL: getSearchPageURL,
251
318
  onSelect: onSelect,
252
319
  cssClasses: cssClasses,
320
+ showRecent: showRecent,
253
321
  renderState: {
254
322
  indexTemplateProps: [],
255
323
  isolatedIndex: undefined,
@@ -265,14 +333,14 @@ function EXPERIMENTAL_autocomplete(widgetParams) {
265
333
  })({}), (0, _index2.default)({
266
334
  indexId: "ais-autocomplete-".concat(instanceId),
267
335
  EXPERIMENTAL_isolated: true
268
- }).addWidgets([(0, _configure.default)({
269
- hitsPerPage: 5
270
- })].concat(_toConsumableArray(indicesConfig.map(function (_ref8) {
271
- var indexName = _ref8.indexName;
336
+ }).addWidgets([].concat(_toConsumableArray(indicesConfig.map(function (_ref0) {
337
+ var indexName = _ref0.indexName;
272
338
  return (0, _index2.default)({
273
339
  indexName: indexName,
274
340
  indexId: indexName
275
- }).addWidgets([(0, _configure.default)({})]);
341
+ }).addWidgets([(0, _configure.default)({
342
+ hitsPerPage: 5
343
+ })]);
276
344
  })), [_objectSpread(_objectSpread({}, makeWidget({
277
345
  escapeHTML: escapeHTML
278
346
  })), {}, {
@@ -269,7 +269,10 @@ function ChatWrapper(_ref0) {
269
269
  loaderComponent: messagesProps.loaderComponent,
270
270
  errorComponent: messagesProps.errorComponent,
271
271
  actionsComponent: messagesProps.actionsComponent,
272
- translations: messagesProps.translations
272
+ assistantMessageProps: messagesProps.assistantMessageProps,
273
+ userMessageProps: messagesProps.userMessageProps,
274
+ translations: messagesProps.translations,
275
+ messageTranslations: messagesProps.messageTranslations
273
276
  },
274
277
  promptProps: {
275
278
  promptRef: promptProps.promptRef,
@@ -303,8 +306,10 @@ var createRenderer = function createRenderer(_ref1) {
303
306
  var promptRef = {
304
307
  current: null
305
308
  };
309
+
310
+ // eslint-disable-next-line complexity
306
311
  return function (props, isFirstRendering) {
307
- var _templates$header, _templates$header2, _templates$header3, _templates$header4, _templates$header5, _templates$header6, _templates$header7, _templates$header8, _templates$header9, _templates$header0, _templates$messages, _templates$messages2, _templates$messages3, _templates$messages4, _templates$messages5, _templates$messages6, _templates$prompt, _templates$prompt2, _templates$prompt3, _templates$prompt4, _templates$prompt5, _templates$prompt6, _templates$prompt7, _templates$prompt8, _templates$prompt9, _templates$toggleButt, _templates$toggleButt2;
312
+ var _templates$header, _templates$header2, _templates$header3, _templates$header4, _templates$header5, _templates$header6, _templates$header7, _templates$header8, _templates$header9, _templates$header0, _templates$messages, _templates$messages2, _templates$messages3, _templates$messages4, _templates$messages5, _templates$messages6, _templates$assistantM, _templates$assistantM2, _templates$message, _templates$message2, _templates$userMessag, _templates$userMessag2, _templates$prompt, _templates$prompt2, _templates$prompt3, _templates$prompt4, _templates$prompt5, _templates$prompt6, _templates$prompt7, _templates$prompt8, _templates$prompt9, _templates$toggleButt, _templates$toggleButt2;
308
313
  var indexUiState = props.indexUiState,
309
314
  input = props.input,
310
315
  instantSearchInstance = props.instantSearchInstance,
@@ -316,7 +321,6 @@ var createRenderer = function createRenderer(_ref1) {
316
321
  setOpen = props.setOpen,
317
322
  status = props.status,
318
323
  error = props.error,
319
- addToolResult = props.addToolResult,
320
324
  regenerate = props.regenerate,
321
325
  stop = props.stop,
322
326
  isClearing = props.isClearing,
@@ -336,12 +340,12 @@ var createRenderer = function createRenderer(_ref1) {
336
340
  }
337
341
  var toolsForUi = {};
338
342
  Object.entries(toolsFromConnector).forEach(function (_ref10) {
343
+ var _widgetTool$templates;
339
344
  var _ref11 = _slicedToArray(_ref10, 2),
340
345
  key = _ref11[0],
341
346
  connectorTool = _ref11[1];
342
347
  var widgetTool = tools[key];
343
- toolsForUi[key] = _objectSpread(_objectSpread({}, connectorTool), {}, {
344
- addToolResult: addToolResult,
348
+ toolsForUi[key] = _objectSpread(_objectSpread({}, connectorTool), (widgetTool === null || widgetTool === void 0 ? void 0 : (_widgetTool$templates = widgetTool.templates) === null || _widgetTool$templates === void 0 ? void 0 : _widgetTool$templates.layout) && {
345
349
  layoutComponent: function layoutComponent(layoutComponentProps) {
346
350
  return (0, _preact.h)(_Template.default, {
347
351
  templates: widgetTool.templates,
@@ -424,6 +428,44 @@ var createRenderer = function createRenderer(_ref1) {
424
428
  copyToClipboardLabel: (_templates$messages5 = templates.messages) === null || _templates$messages5 === void 0 ? void 0 : _templates$messages5.copyToClipboardLabelText,
425
429
  regenerateLabel: (_templates$messages6 = templates.messages) === null || _templates$messages6 === void 0 ? void 0 : _templates$messages6.regenerateLabelText
426
430
  });
431
+ var assistantMessageTemplateProps = (0, _templating.prepareTemplateProps)({
432
+ defaultTemplates: {},
433
+ templatesConfig: instantSearchInstance.templatesConfig,
434
+ templates: templates.assistantMessage
435
+ });
436
+ var assistantMessageLeadingComponent = (_templates$assistantM = templates.assistantMessage) !== null && _templates$assistantM !== void 0 && _templates$assistantM.leading ? function () {
437
+ return (0, _preact.h)(_Template.default, _extends({}, assistantMessageTemplateProps, {
438
+ templateKey: "leading",
439
+ rootTagName: "fragment"
440
+ }));
441
+ } : undefined;
442
+ var assistantMessageFooterComponent = (_templates$assistantM2 = templates.assistantMessage) !== null && _templates$assistantM2 !== void 0 && _templates$assistantM2.footer ? function () {
443
+ return (0, _preact.h)(_Template.default, _extends({}, assistantMessageTemplateProps, {
444
+ templateKey: "footer",
445
+ rootTagName: "fragment"
446
+ }));
447
+ } : undefined;
448
+ var messageTranslations = getDefinedProperties({
449
+ actionsLabel: (_templates$message = templates.message) === null || _templates$message === void 0 ? void 0 : _templates$message.actionsLabelText,
450
+ messageLabel: (_templates$message2 = templates.message) === null || _templates$message2 === void 0 ? void 0 : _templates$message2.messageLabelText
451
+ });
452
+ var userMessageTemplateProps = (0, _templating.prepareTemplateProps)({
453
+ defaultTemplates: {},
454
+ templatesConfig: instantSearchInstance.templatesConfig,
455
+ templates: templates.userMessage
456
+ });
457
+ var userMessageLeadingComponent = (_templates$userMessag = templates.userMessage) !== null && _templates$userMessag !== void 0 && _templates$userMessag.leading ? function () {
458
+ return (0, _preact.h)(_Template.default, _extends({}, userMessageTemplateProps, {
459
+ templateKey: "leading",
460
+ rootTagName: "fragment"
461
+ }));
462
+ } : undefined;
463
+ var userMessageFooterComponent = (_templates$userMessag2 = templates.userMessage) !== null && _templates$userMessag2 !== void 0 && _templates$userMessag2.footer ? function () {
464
+ return (0, _preact.h)(_Template.default, _extends({}, userMessageTemplateProps, {
465
+ templateKey: "footer",
466
+ rootTagName: "fragment"
467
+ }));
468
+ } : undefined;
427
469
  var promptTemplateProps = (0, _templating.prepareTemplateProps)({
428
470
  defaultTemplates: {},
429
471
  templatesConfig: instantSearchInstance.templatesConfig,
@@ -520,7 +562,16 @@ var createRenderer = function createRenderer(_ref1) {
520
562
  loaderComponent: messagesLoaderComponent,
521
563
  errorComponent: messagesErrorComponent,
522
564
  actionsComponent: actionsComponent,
523
- translations: messagesTranslations
565
+ assistantMessageProps: {
566
+ leadingComponent: assistantMessageLeadingComponent,
567
+ footerComponent: assistantMessageFooterComponent
568
+ },
569
+ userMessageProps: {
570
+ leadingComponent: userMessageLeadingComponent,
571
+ footerComponent: userMessageFooterComponent
572
+ },
573
+ translations: messagesTranslations,
574
+ messageTranslations: messageTranslations
524
575
  },
525
576
  promptProps: {
526
577
  layoutComponent: promptLayoutComponent,
@@ -422,12 +422,6 @@ var index = function index(widgetParams) {
422
422
  helper.searchWithoutTriggeringOnStateChange = function () {
423
423
  return mainHelper.search();
424
424
  };
425
-
426
- // We use the same pattern for the `searchForFacetValues`.
427
- helper.searchForFacetValues = function (facetName, facetValue, maxFacetHits, userState) {
428
- var state = helper.state.setQueryParameters(userState);
429
- return mainHelper.searchForFacetValues(facetName, facetValue, maxFacetHits, state);
430
- };
431
425
  var isolatedHelper = indexName ? helper : (0, _algoliasearchHelper.default)({}, '__empty_index__', {});
432
426
  var derivingHelper = isolated ? isolatedHelper : nearestIsolatedHelper(parent, mainHelper);
433
427
  derivedHelper = derivingHelper.derive(function () {
@@ -5,6 +5,7 @@ import type { AutocompleteIndexClassNames } from 'instantsearch-ui-components';
5
5
  import type { AutocompleteIndexConfig } from 'instantsearch-ui-components';
6
6
  import { Banner } from 'algoliasearch-helper';
7
7
  import type { CarouselProps } from 'instantsearch-ui-components';
8
+ import type { ClientSideTools } from 'instantsearch-ui-components';
8
9
  import { CompositionClient } from 'algoliasearch-helper/types/algoliasearch.js';
9
10
  import EventEmitter from '@algolia/events';
10
11
  import { FindAnswersOptions } from 'algoliasearch-helper/types/algoliasearch.js';
@@ -33,7 +34,6 @@ import { SearchParameters } from 'algoliasearch-helper';
33
34
  import { SearchResults } from 'algoliasearch-helper';
34
35
  import type { TrendingItemsProps } from 'instantsearch-ui-components';
35
36
  import type { UIMessage } from 'ai';
36
- import type { UserClientSideTool } from 'instantsearch-ui-components';
37
37
  import { VNode } from 'preact';
38
38
  import type { VNode as VNode_2 } from 'instantsearch-ui-components';
39
39
 
@@ -337,6 +337,24 @@ declare type AutocompleteWidgetParams<TItem extends BaseHit> = {
337
337
  showSuggestions?: Partial<Pick<IndexConfig<{
338
338
  query: string;
339
339
  }>, 'indexName' | 'getURL' | 'templates' | 'cssClasses'>>;
340
+ showRecent?: boolean | {
341
+ /**
342
+ * Storage key to use in the local storage.
343
+ */
344
+ storageKey?: string;
345
+ templates?: Partial<{
346
+ /**
347
+ * Template to use for each result. This template will receive an object containing a single record.
348
+ */
349
+ item: Template<{
350
+ item: {
351
+ query: string;
352
+ };
353
+ onSelect: () => void;
354
+ onRemoveRecentSearch: () => void;
355
+ }>;
356
+ }>;
357
+ };
340
358
  getSearchPageURL?: (nextUiState: IndexUiState) => string;
341
359
  onSelect?: AutocompleteIndexConfig<TItem>['onSelect'];
342
360
  /**
@@ -643,9 +661,9 @@ declare type ChatRenderState<TUiMessage extends UIMessage = UIMessage> = {
643
661
  */
644
662
  onClearTransitionEnd: () => void;
645
663
  /**
646
- * Tools configuration passed to the connector.
664
+ * Tools configuration with addToolResult bound, ready to be used by the UI.
647
665
  */
648
- tools: Record<string, Omit<UserClientSideTool, 'layoutComponent'>>;
666
+ tools: ClientSideTools;
649
667
  } & Pick<AbstractChat<TUiMessage>, 'addToolResult' | 'clearError' | 'error' | 'id' | 'messages' | 'regenerate' | 'resumeStream' | 'sendMessage' | 'status' | 'stop'>;
650
668
 
651
669
  declare type ChatWidgetDescription<TUiMessage extends UIMessage = UIMessage> = {