instantsearch.js 4.83.0 → 4.85.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.
@@ -80,7 +80,8 @@ var connectChat = exports.default = function connectChat(renderFn) {
80
80
  api: "https://".concat(appId, ".algolia.net/agent-studio/1/agents/").concat(agentId, "/completions?compatibilityMode=ai-sdk-5"),
81
81
  headers: {
82
82
  'x-algolia-application-id': appId,
83
- 'x-algolia-api-Key': apiKey
83
+ 'x-algolia-api-Key': apiKey,
84
+ 'x-algolia-agent': (0, _utils.getAlgoliaAgent)(instantSearchInstance.client)
84
85
  }
85
86
  });
86
87
  }
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getAlgoliaAgent = getAlgoliaAgent;
7
+ function getAlgoliaAgent(client) {
8
+ var clientTyped = client;
9
+ return clientTyped.transporter && clientTyped.transporter.userAgent ? clientTyped.transporter.userAgent.value : clientTyped._ua;
10
+ }
@@ -223,6 +223,17 @@ Object.keys(_geoSearch).forEach(function (key) {
223
223
  }
224
224
  });
225
225
  });
226
+ var _getAlgoliaAgent = require("./getAlgoliaAgent");
227
+ Object.keys(_getAlgoliaAgent).forEach(function (key) {
228
+ if (key === "default" || key === "__esModule") return;
229
+ if (key in exports && exports[key] === _getAlgoliaAgent[key]) return;
230
+ Object.defineProperty(exports, key, {
231
+ enumerable: true,
232
+ get: function get() {
233
+ return _getAlgoliaAgent[key];
234
+ }
235
+ });
236
+ });
226
237
  var _getAppIdAndApiKey = require("./getAppIdAndApiKey");
227
238
  Object.keys(_getAppIdAndApiKey).forEach(function (key) {
228
239
  if (key === "default" || key === "__esModule") return;
@@ -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.83.0';
7
+ var _default = exports.default = '4.85.0';
@@ -70,8 +70,7 @@ function createMetadataMiddleware() {
70
70
  subscribe: function subscribe() {
71
71
  // using setTimeout here to delay extraction until widgets have been added in a tick (e.g. Vue)
72
72
  setTimeout(function () {
73
- var client = instantSearchInstance.client;
74
- payload.ua = client.transporter && client.transporter.userAgent ? client.transporter.userAgent.value : client._ua;
73
+ payload.ua = (0, _utils.getAlgoliaAgent)(instantSearchInstance.client);
75
74
  extractWidgetPayload(instantSearchInstance.mainIndex.getWidgets(), instantSearchInstance, payload);
76
75
  instantSearchInstance.middleware.forEach(function (middleware) {
77
76
  return payload.widgets.push({
@@ -9,6 +9,7 @@ var _preact = require("preact");
9
9
  var _hooks = require("preact/hooks");
10
10
  var _Template = _interopRequireDefault(require("../../components/Template/Template"));
11
11
  var _index = require("../../connectors/index.umd");
12
+ var _components = require("../../helpers/components");
12
13
  var _suit = require("../../lib/suit");
13
14
  var _templating = require("../../lib/templating");
14
15
  var _utils = require("../../lib/utils");
@@ -90,7 +91,12 @@ var createRenderer = function createRenderer(params) {
90
91
  rendererParams.renderState = {
91
92
  indexTemplateProps: [],
92
93
  isolatedIndex: isolatedIndex,
93
- targetIndex: targetIndex
94
+ targetIndex: targetIndex,
95
+ templateProps: (0, _templating.prepareTemplateProps)({
96
+ defaultTemplates: {},
97
+ templatesConfig: connectorParams.instantSearchInstance.templatesConfig,
98
+ templates: rendererParams.templates
99
+ })
94
100
  };
95
101
  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 : '');
96
102
  return;
@@ -104,11 +110,14 @@ function AutocompleteWrapper(_ref) {
104
110
  indices = _ref.indices,
105
111
  getSearchPageURL = _ref.getSearchPageURL,
106
112
  userOnSelect = _ref.onSelect,
107
- refine = _ref.refine,
113
+ refineAutocomplete = _ref.refine,
108
114
  cssClasses = _ref.cssClasses,
109
115
  renderState = _ref.renderState,
110
116
  instantSearchInstance = _ref.instantSearchInstance,
111
- showRecent = _ref.showRecent;
117
+ showRecent = _ref.showRecent,
118
+ showSuggestions = _ref.showSuggestions,
119
+ templates = _ref.templates,
120
+ placeholder = _ref.placeholder;
112
121
  var isolatedIndex = renderState.isolatedIndex,
113
122
  targetIndex = renderState.targetIndex;
114
123
  var searchboxQuery = isolatedIndex === null || isolatedIndex === void 0 ? void 0 : (_isolatedIndex$getHel = isolatedIndex.getHelper()) === null || _isolatedIndex$getHel === void 0 ? void 0 : _isolatedIndex$getHel.state.query;
@@ -127,6 +136,7 @@ function AutocompleteWrapper(_ref) {
127
136
  return ['ais.hits', 'ais.infiniteHits'].includes($$type);
128
137
  })) !== null && _targetIndex$getWidge !== void 0 ? _targetIndex$getWidge : false;
129
138
  var onRefine = function onRefine(query) {
139
+ refineAutocomplete(query);
130
140
  instantSearchInstance.setUiState(function (uiState) {
131
141
  var _objectSpread2;
132
142
  return _objectSpread(_objectSpread({}, uiState), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, targetIndex.getIndexId(), _objectSpread(_objectSpread({}, uiState[targetIndex.getIndexId()]), {}, {
@@ -157,23 +167,35 @@ function AutocompleteWrapper(_ref) {
157
167
  return;
158
168
  }
159
169
  setQuery(query);
160
- }
170
+ },
171
+ placeholder: placeholder
161
172
  }),
162
173
  getInputProps = _usePropGetters.getInputProps,
163
174
  getItemProps = _usePropGetters.getItemProps,
164
175
  getPanelProps = _usePropGetters.getPanelProps,
165
176
  getRootProps = _usePropGetters.getRootProps;
166
- var AutocompleteRecentSearchComponent = AutocompleteRecentSearch;
177
+ var AutocompleteRecentSearchComponent = function AutocompleteRecentSearchComponent(_ref4) {
178
+ var item = _ref4.item,
179
+ onSelect = _ref4.onSelect,
180
+ onRemoveRecentSearch = _ref4.onRemoveRecentSearch;
181
+ return (0, _preact.h)(AutocompleteRecentSearch, {
182
+ item: item,
183
+ onSelect: onSelect,
184
+ onRemoveRecentSearch: onRemoveRecentSearch
185
+ }, (0, _preact.h)(ConditionalReverseHighlight, {
186
+ item: item
187
+ }));
188
+ };
167
189
  if (_typeof(showRecent) === 'object' && (_showRecent$templates = showRecent.templates) !== null && _showRecent$templates !== void 0 && _showRecent$templates.item) {
168
190
  var props = (0, _templating.prepareTemplateProps)({
169
191
  defaultTemplates: {},
170
192
  templatesConfig: instantSearchInstance.templatesConfig,
171
193
  templates: showRecent.templates
172
194
  });
173
- AutocompleteRecentSearchComponent = function AutocompleteRecentSearchComponent(_ref4) {
174
- var item = _ref4.item,
175
- onSelect = _ref4.onSelect,
176
- onRemoveRecentSearch = _ref4.onRemoveRecentSearch;
195
+ AutocompleteRecentSearchComponent = function AutocompleteRecentSearchComponent(_ref5) {
196
+ var item = _ref5.item,
197
+ onSelect = _ref5.onSelect,
198
+ onRemoveRecentSearch = _ref5.onRemoveRecentSearch;
177
199
  return (0, _preact.h)(_Template.default, _extends({}, props, {
178
200
  templateKey: "item",
179
201
  rootTagName: "fragment",
@@ -185,45 +207,36 @@ function AutocompleteWrapper(_ref) {
185
207
  }));
186
208
  };
187
209
  }
188
- return (0, _preact.h)(Autocomplete, _extends({}, getRootProps(), {
189
- classNames: cssClasses
190
- }), (0, _preact.h)(AutocompleteSearchBox, {
191
- query: searchboxQuery || '',
192
- inputProps: _objectSpread(_objectSpread({}, getInputProps()), {}, {
193
- // @ts-ignore - This clashes with some ambient React JSX declarations.
194
- onInput: function onInput(evt) {
195
- return refine(evt.currentTarget.value);
196
- }
197
- }),
198
- onClear: function onClear() {
199
- return onRefine('');
200
- },
201
- isSearchStalled: instantSearchInstance.status === 'stalled'
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) {
210
+ var elements = {};
211
+ if (showRecent) {
212
+ elements.recent = (0, _preact.h)(AutocompleteIndex
213
+ // @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
214
+ , {
215
+ ItemComponent: function ItemComponent(_ref6) {
216
+ var item = _ref6.item,
217
+ onSelect = _ref6.onSelect;
218
+ return (0, _preact.h)(AutocompleteRecentSearchComponent, {
219
+ item: item,
220
+ onSelect: onSelect,
221
+ onRemoveRecentSearch: function onRemoveRecentSearch() {
222
+ return storage.onRemove(item.query);
223
+ }
224
+ });
225
+ },
226
+ classNames: {
227
+ root: 'ais-AutocompleteRecentSearches',
228
+ list: 'ais-AutocompleteRecentSearchesList',
229
+ item: 'ais-AutocompleteRecentSearchesItem'
230
+ },
231
+ items: storageHits,
232
+ getItemProps: getItemProps
233
+ });
234
+ }
235
+ indices.forEach(function (_ref7, i) {
224
236
  var _indicesConfig$i$temp;
225
- var indexId = _ref6.indexId,
226
- hits = _ref6.hits;
237
+ var indexId = _ref7.indexId,
238
+ indexName = _ref7.indexName,
239
+ hits = _ref7.hits;
227
240
  if (!renderState.indexTemplateProps[i]) {
228
241
  renderState.indexTemplateProps[i] = (0, _templating.prepareTemplateProps)({
229
242
  defaultTemplates: {},
@@ -231,8 +244,8 @@ function AutocompleteWrapper(_ref) {
231
244
  templates: indicesConfig[i].templates
232
245
  });
233
246
  }
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;
247
+ var headerComponent = (_indicesConfig$i$temp = indicesConfig[i].templates) !== null && _indicesConfig$i$temp !== void 0 && _indicesConfig$i$temp.header ? function (_ref8) {
248
+ var items = _ref8.items;
236
249
  return (0, _preact.h)(_Template.default, _extends({}, renderState.indexTemplateProps[i], {
237
250
  templateKey: "header",
238
251
  rootTagName: "fragment",
@@ -241,9 +254,9 @@ function AutocompleteWrapper(_ref) {
241
254
  }
242
255
  }));
243
256
  } : undefined;
244
- var itemComponent = function itemComponent(_ref8) {
245
- var item = _ref8.item,
246
- onSelect = _ref8.onSelect;
257
+ var itemComponent = function itemComponent(_ref9) {
258
+ var item = _ref9.item,
259
+ onSelect = _ref9.onSelect;
247
260
  return (0, _preact.h)(_Template.default, _extends({}, renderState.indexTemplateProps[i], {
248
261
  templateKey: "item",
249
262
  rootTagName: "fragment",
@@ -253,11 +266,17 @@ function AutocompleteWrapper(_ref) {
253
266
  }
254
267
  }));
255
268
  };
256
- return (0, _preact.h)(AutocompleteIndex, {
269
+ var elementId = indexName === (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) ? 'suggestions' : indexName;
270
+ var filteredHits = elementId === 'suggestions' && showRecent ? hits.filter(function (suggestionHit) {
271
+ return !(0, _utils.find)(storageHits, function (storageHit) {
272
+ return storageHit.query === suggestionHit.query;
273
+ });
274
+ }) : hits;
275
+ elements[elementId] = (0, _preact.h)(AutocompleteIndex, {
257
276
  key: indexId,
258
277
  HeaderComponent: headerComponent,
259
278
  ItemComponent: itemComponent,
260
- items: hits.map(function (item) {
279
+ items: filteredHits.map(function (item) {
261
280
  return _objectSpread(_objectSpread({}, item), {}, {
262
281
  __indexName: indexId
263
282
  });
@@ -265,26 +284,55 @@ function AutocompleteWrapper(_ref) {
265
284
  getItemProps: getItemProps,
266
285
  classNames: indicesConfig[i].cssClasses
267
286
  });
287
+ });
288
+ return (0, _preact.h)(Autocomplete, _extends({}, getRootProps(), {
289
+ classNames: cssClasses
290
+ }), (0, _preact.h)(AutocompleteSearchBox, {
291
+ query: searchboxQuery || '',
292
+ inputProps: _objectSpread(_objectSpread({}, getInputProps()), {}, {
293
+ // @ts-ignore - This clashes with some ambient React JSX declarations.
294
+ onInput: function onInput(evt) {
295
+ return refineAutocomplete(evt.currentTarget.value);
296
+ }
297
+ }),
298
+ onClear: function onClear() {
299
+ onRefine('');
300
+ },
301
+ isSearchStalled: instantSearchInstance.status === 'stalled'
302
+ }), (0, _preact.h)(AutocompletePanel, getPanelProps(), templates.panel ? (0, _preact.h)(_Template.default, _extends({}, renderState.templateProps, {
303
+ templateKey: "panel",
304
+ rootTagName: "fragment",
305
+ data: {
306
+ elements: elements,
307
+ indices: indices
308
+ }
309
+ })) : Object.keys(elements).map(function (elementId) {
310
+ return elements[elementId];
268
311
  })));
269
312
  }
270
313
  function EXPERIMENTAL_autocomplete(widgetParams) {
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;
314
+ var _ref0 = widgetParams || {},
315
+ container = _ref0.container,
316
+ escapeHTML = _ref0.escapeHTML,
317
+ _ref0$indices = _ref0.indices,
318
+ indices = _ref0$indices === void 0 ? [] : _ref0$indices,
319
+ showSuggestions = _ref0.showSuggestions,
320
+ showRecent = _ref0.showRecent,
321
+ userSearchParameters = _ref0.searchParameters,
322
+ getSearchPageURL = _ref0.getSearchPageURL,
323
+ onSelect = _ref0.onSelect,
324
+ _ref0$templates = _ref0.templates,
325
+ templates = _ref0$templates === void 0 ? {} : _ref0$templates,
326
+ _ref0$cssClasses = _ref0.cssClasses,
327
+ userCssClasses = _ref0$cssClasses === void 0 ? {} : _ref0$cssClasses,
328
+ placeholder = _ref0.placeholder;
284
329
  if (!container) {
285
330
  throw new Error(withUsage('The `container` option is required.'));
286
331
  }
287
332
  var containerNode = (0, _utils.getContainerNode)(container);
333
+ var searchParameters = _objectSpread({
334
+ hitsPerPage: 5
335
+ }, userSearchParameters);
288
336
  var cssClasses = {
289
337
  root: (0, _instantsearchUiComponents.cx)(suit(), userCssClasses.root)
290
338
  };
@@ -295,7 +343,16 @@ function EXPERIMENTAL_autocomplete(widgetParams) {
295
343
  indexName: showSuggestions.indexName,
296
344
  templates: _objectSpread({
297
345
  // @ts-expect-error
298
- item: AutocompleteSuggestion
346
+ item: function item(_ref1) {
347
+ var _item = _ref1.item,
348
+ onSelectItem = _ref1.onSelect;
349
+ return (0, _preact.h)(AutocompleteSuggestion, {
350
+ item: _item,
351
+ onSelect: onSelectItem
352
+ }, (0, _preact.h)(ConditionalReverseHighlight, {
353
+ item: _item
354
+ }));
355
+ }
299
356
  }, showSuggestions.templates),
300
357
  cssClasses: {
301
358
  root: (0, _instantsearchUiComponents.cx)('ais-AutocompleteSuggestions', (_showSuggestions$cssC = showSuggestions.cssClasses) === null || _showSuggestions$cssC === void 0 ? void 0 : _showSuggestions$cssC.root),
@@ -318,10 +375,13 @@ function EXPERIMENTAL_autocomplete(widgetParams) {
318
375
  onSelect: onSelect,
319
376
  cssClasses: cssClasses,
320
377
  showRecent: showRecent,
378
+ showSuggestions: showSuggestions,
379
+ placeholder: placeholder,
321
380
  renderState: {
322
381
  indexTemplateProps: [],
323
382
  isolatedIndex: undefined,
324
- targetIndex: undefined
383
+ targetIndex: undefined,
384
+ templateProps: undefined
325
385
  },
326
386
  templates: templates
327
387
  });
@@ -333,17 +393,29 @@ function EXPERIMENTAL_autocomplete(widgetParams) {
333
393
  })({}), (0, _index2.default)({
334
394
  indexId: "ais-autocomplete-".concat(instanceId),
335
395
  EXPERIMENTAL_isolated: true
336
- }).addWidgets([].concat(_toConsumableArray(indicesConfig.map(function (_ref0) {
337
- var indexName = _ref0.indexName;
396
+ }).addWidgets([(0, _configure.default)(searchParameters)].concat(_toConsumableArray(indicesConfig.map(function (_ref10) {
397
+ var indexName = _ref10.indexName,
398
+ indexSearchParameters = _ref10.searchParameters;
338
399
  return (0, _index2.default)({
339
400
  indexName: indexName,
340
401
  indexId: indexName
341
- }).addWidgets([(0, _configure.default)({
342
- hitsPerPage: 5
343
- })]);
402
+ }).addWidgets([(0, _configure.default)(indexSearchParameters || {})]);
344
403
  })), [_objectSpread(_objectSpread({}, makeWidget({
345
404
  escapeHTML: escapeHTML
346
405
  })), {}, {
347
406
  $$widgetType: 'ais.autocomplete'
348
407
  })]))];
408
+ }
409
+ function ConditionalReverseHighlight(_ref11) {
410
+ var _item$_highlightResul;
411
+ var item = _ref11.item;
412
+ if (!((_item$_highlightResul = item._highlightResult) !== null && _item$_highlightResul !== void 0 && _item$_highlightResul.query) ||
413
+ // @ts-expect-error - we should not have matchLevel as arrays here
414
+ item._highlightResult.query.matchLevel === 'none') {
415
+ return item.query;
416
+ }
417
+ return (0, _preact.h)(_components.ReverseHighlight, {
418
+ attribute: "query",
419
+ hit: item
420
+ });
349
421
  }
@@ -57,13 +57,13 @@ function getDefinedProperties(obj) {
57
57
  return value !== undefined;
58
58
  }));
59
59
  }
60
- var _ref6 = (0, _preact.h)(_instantsearchUiComponents.ArrowRightIconComponent, {
60
+ var _ref6 = (0, _preact.h)(_instantsearchUiComponents.ArrowRightIcon, {
61
61
  createElement: _preact.h
62
62
  });
63
- var _ref7 = (0, _preact.h)(_instantsearchUiComponents.ChevronLeftIconComponent, {
63
+ var _ref7 = (0, _preact.h)(_instantsearchUiComponents.ChevronLeftIcon, {
64
64
  createElement: _preact.h
65
65
  });
66
- var _ref8 = (0, _preact.h)(_instantsearchUiComponents.ChevronRightIconComponent, {
66
+ var _ref8 = (0, _preact.h)(_instantsearchUiComponents.ChevronRightIcon, {
67
67
  createElement: _preact.h
68
68
  });
69
69
  function createCarouselTool(showViewAll, templates, getSearchPageURL) {
@@ -204,6 +204,12 @@ var index = function index(widgetParams) {
204
204
  helper: helper
205
205
  })));
206
206
  },
207
+ scheduleLocalSearch: (0, _utils.defer)(function () {
208
+ if (isolated) {
209
+ var _helper2;
210
+ (_helper2 = helper) === null || _helper2 === void 0 ? void 0 : _helper2.search();
211
+ }
212
+ }),
207
213
  getWidgets: function getWidgets() {
208
214
  return localWidgets;
209
215
  },
@@ -269,8 +275,7 @@ var index = function index(widgetParams) {
269
275
  }
270
276
  });
271
277
  if (isolated) {
272
- var _helper2;
273
- (_helper2 = helper) === null || _helper2 === void 0 ? void 0 : _helper2.search();
278
+ this.scheduleLocalSearch();
274
279
  } else {
275
280
  localInstantSearchInstance.scheduleSearch();
276
281
  }
@@ -349,8 +354,7 @@ var index = function index(widgetParams) {
349
354
  helper.recommendState = cleanedRecommendState;
350
355
  if (localWidgets.length) {
351
356
  if (isolated) {
352
- var _helper3;
353
- (_helper3 = helper) === null || _helper3 === void 0 ? void 0 : _helper3.search();
357
+ this.scheduleLocalSearch();
354
358
  } else {
355
359
  localInstantSearchInstance.scheduleSearch();
356
360
  }
@@ -604,7 +608,7 @@ var index = function index(widgetParams) {
604
608
  },
605
609
  dispose: function dispose() {
606
610
  var _this5 = this,
607
- _helper4,
611
+ _helper3,
608
612
  _derivedHelper3;
609
613
  localWidgets.forEach(function (widget) {
610
614
  if (widget.dispose && helper) {
@@ -624,7 +628,7 @@ var index = function index(widgetParams) {
624
628
  });
625
629
  localInstantSearchInstance = null;
626
630
  localParent = null;
627
- (_helper4 = helper) === null || _helper4 === void 0 ? void 0 : _helper4.removeAllListeners();
631
+ (_helper3 = helper) === null || _helper3 === void 0 ? void 0 : _helper3.removeAllListeners();
628
632
  helper = null;
629
633
  (_derivedHelper3 = derivedHelper) === null || _derivedHelper3 === void 0 ? void 0 : _derivedHelper3.detach();
630
634
  derivedHelper = null;
@@ -309,7 +309,17 @@ declare type AutocompleteRenderState = {
309
309
  refine: (query: string) => void;
310
310
  };
311
311
 
312
- declare type AutocompleteTemplates<TItem extends BaseHit> = Partial<Record<string, TItem>>;
312
+ declare type AutocompleteSearchParameters = Omit<PlainSearchParameters, 'index'>;
313
+
314
+ declare type AutocompleteTemplates = {
315
+ /**
316
+ * Template to use for the panel.
317
+ */
318
+ panel?: Template<{
319
+ elements: PanelElements;
320
+ indices: AutocompleteRenderState['indices'];
321
+ }>;
322
+ };
313
323
 
314
324
  declare type AutocompleteWidgetDescription = {
315
325
  $$type: 'ais.autocomplete';
@@ -355,16 +365,24 @@ declare type AutocompleteWidgetParams<TItem extends BaseHit> = {
355
365
  }>;
356
366
  }>;
357
367
  };
368
+ /**
369
+ * Search parameters to apply to the autocomplete indices.
370
+ */
371
+ searchParameters?: AutocompleteSearchParameters;
358
372
  getSearchPageURL?: (nextUiState: IndexUiState) => string;
359
373
  onSelect?: AutocompleteIndexConfig<TItem>['onSelect'];
360
374
  /**
361
375
  * Templates to use for the widget.
362
376
  */
363
- templates?: AutocompleteTemplates<TItem>;
377
+ templates?: AutocompleteTemplates;
364
378
  /**
365
379
  * CSS classes to add.
366
380
  */
367
381
  cssClasses?: AutocompleteCSSClasses;
382
+ /**
383
+ * Placeholder text for the search input.
384
+ */
385
+ placeholder?: string;
368
386
  };
369
387
 
370
388
  declare type BaseHit = Record<string, any>;
@@ -4887,6 +4905,10 @@ declare type IndexConfig<TItem extends BaseHit> = AutocompleteIndexConfig<TItem>
4887
4905
  onSelect: () => void;
4888
4906
  }>;
4889
4907
  }>;
4908
+ /**
4909
+ * Search parameters to apply to this index.
4910
+ */
4911
+ searchParameters?: AutocompleteSearchParameters;
4890
4912
  cssClasses?: Partial<AutocompleteIndexClassNames>;
4891
4913
  };
4892
4914
 
@@ -4947,6 +4969,11 @@ declare type IndexWidget<TUiState extends UiState = UiState> = Omit<Widget<Index
4947
4969
  * @private
4948
4970
  */
4949
4971
  _isolated: boolean;
4972
+ /**
4973
+ * Schedules a search for this index only.
4974
+ * @private
4975
+ */
4976
+ scheduleLocalSearch: () => void;
4950
4977
  };
4951
4978
 
4952
4979
  declare type IndexWidgetDescription = {
@@ -6350,6 +6377,8 @@ declare type PanelCSSClasses = Partial<{
6350
6377
  footer: string | string[];
6351
6378
  }>;
6352
6379
 
6380
+ declare type PanelElements = Partial<Record<'recent' | 'suggestions' | (string & {}), preact.JSX.Element>>;
6381
+
6353
6382
  declare type PanelRenderOptions<TWidgetFactory extends AnyWidgetFactory> = RenderOptions & GetWidgetRenderState<TWidgetFactory>;
6354
6383
 
6355
6384
  declare type PanelTemplates<TWidget extends AnyWidgetFactory> = Partial<{