react-instantsearch 7.20.2 → 7.22.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.
@@ -7,7 +7,7 @@
7
7
 
8
8
  var React__default = 'default' in React ? React['default'] : React;
9
9
 
10
- var version = '7.20.2';
10
+ var version = '7.22.0';
11
11
 
12
12
  // Copyright Joyent, Inc. and other Node contributors.
13
13
  //
@@ -4651,7 +4651,7 @@
4651
4651
 
4652
4652
  var sortAndMergeRecommendations_1 = sortAndMergeRecommendations;
4653
4653
 
4654
- var version$1 = '3.26.1';
4654
+ var version$1 = '3.27.0';
4655
4655
 
4656
4656
  var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
4657
4657
 
@@ -13355,7 +13355,7 @@
13355
13355
  };
13356
13356
  }
13357
13357
 
13358
- var version$3 = '4.85.1';
13358
+ var version$3 = '4.86.0';
13359
13359
 
13360
13360
  function _typeof$q(o) {
13361
13361
  "@babel/helpers - typeof";
@@ -19259,10 +19259,33 @@
19259
19259
 
19260
19260
  /**
19261
19261
  * The **SortBy** connector provides the logic to build a custom widget that will display a
19262
- * list of indices. With Algolia, this is most commonly used for changing ranking strategy. This allows
19263
- * a user to change how the hits are being sorted.
19262
+ * list of indices or sorting strategies. With Algolia, this is most commonly used for changing
19263
+ * ranking strategy. This allows a user to change how the hits are being sorted.
19264
+ *
19265
+ * This connector supports two sorting modes:
19266
+ * 1. **Index-based (traditional)**: Uses the `value` property to switch between different indices.
19267
+ * This is the standard behavior for non-composition setups.
19268
+ *
19269
+ * 2. **Strategy-based (composition mode)**: Uses the `strategy` property to apply sorting strategies
19270
+ * via the `sortBy` search parameter. This is only available when using Algolia Compositions.
19271
+ *
19272
+ * Items can mix both types in the same widget, allowing for flexible sorting options.
19264
19273
  */
19265
19274
 
19275
+ function isStrategyItem(item) {
19276
+ return 'strategy' in item && item.strategy !== undefined;
19277
+ }
19278
+ function getItemValue(item) {
19279
+ if (isStrategyItem(item)) {
19280
+ return item.strategy;
19281
+ }
19282
+ return item.value;
19283
+ }
19284
+ function isValidStrategy(itemsLookup, value) {
19285
+ if (!value) return false;
19286
+ var item = itemsLookup[value];
19287
+ return item !== undefined && isStrategyItem(item);
19288
+ }
19266
19289
  var connectSortBy = function connectSortBy(renderFn) {
19267
19290
  var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop$1;
19268
19291
  checkRendering(renderFn, withUsage$m());
@@ -19277,14 +19300,38 @@
19277
19300
  if (!Array.isArray(items)) {
19278
19301
  throw new Error(withUsage$m('The `items` option expects an array of objects.'));
19279
19302
  }
19303
+ var itemsLookup = {};
19304
+ items.forEach(function (item, index) {
19305
+ var hasValue = 'value' in item && item.value !== undefined;
19306
+ var hasStrategy = 'strategy' in item && item.strategy !== undefined;
19307
+
19308
+ // Validate mutual exclusivity
19309
+ if (hasValue && hasStrategy) {
19310
+ throw new Error(withUsage$m("Item at index ".concat(index, " cannot have both \"value\" and \"strategy\" properties.")));
19311
+ }
19312
+ if (!hasValue && !hasStrategy) {
19313
+ throw new Error(withUsage$m("Item at index ".concat(index, " must have either a \"value\" or \"strategy\" property.")));
19314
+ }
19315
+ var itemValue = getItemValue(item);
19316
+ itemsLookup[itemValue] = item;
19317
+ });
19318
+ connectorState.itemsLookup = itemsLookup;
19280
19319
  return {
19281
19320
  $$type: 'ais.sortBy',
19282
19321
  init: function init(initOptions) {
19283
19322
  var instantSearchInstance = initOptions.instantSearchInstance;
19323
+
19324
+ // Check if strategies are used outside composition mode
19325
+ var hasStrategyItems = items.some(function (item) {
19326
+ return 'strategy' in item && item.strategy;
19327
+ });
19328
+ if (hasStrategyItems && !instantSearchInstance.compositionID) {
19329
+ throw new Error(withUsage$m('Sorting strategies can only be used in composition mode. Please provide a "compositionID" to your InstantSearch instance.'));
19330
+ }
19284
19331
  var widgetRenderState = this.getWidgetRenderState(initOptions);
19285
19332
  var currentIndex = widgetRenderState.currentRefinement;
19286
19333
  var isCurrentIndexInItems = find$1(items, function (item) {
19287
- return item.value === currentIndex;
19334
+ return getItemValue(item) === currentIndex;
19288
19335
  });
19289
19336
  renderFn(_objectSpread$F(_objectSpread$F({}, widgetRenderState), {}, {
19290
19337
  instantSearchInstance: instantSearchInstance
@@ -19299,7 +19346,17 @@
19299
19346
  dispose: function dispose(_ref2) {
19300
19347
  var state = _ref2.state;
19301
19348
  unmountFn();
19302
- return connectorState.initialIndex ? state.setIndex(connectorState.initialIndex) : state;
19349
+
19350
+ // Clear sortBy parameter if it was set
19351
+ if (connectorState.isUsingComposition && state.sortBy) {
19352
+ state = state.setQueryParameter('sortBy', undefined);
19353
+ }
19354
+
19355
+ // Restore initial index if changed
19356
+ if (connectorState.initialValue && state.index !== connectorState.initialValue) {
19357
+ return state.setIndex(connectorState.initialValue);
19358
+ }
19359
+ return state;
19303
19360
  },
19304
19361
  getRenderState: function getRenderState(renderState, renderOptions) {
19305
19362
  return _objectSpread$F(_objectSpread$F({}, renderState), {}, {
@@ -19310,22 +19367,54 @@
19310
19367
  var results = _ref3.results,
19311
19368
  helper = _ref3.helper,
19312
19369
  state = _ref3.state,
19313
- parent = _ref3.parent;
19314
- if (!connectorState.initialIndex && parent) {
19315
- connectorState.initialIndex = parent.getIndexName();
19370
+ parent = _ref3.parent,
19371
+ instantSearchInstance = _ref3.instantSearchInstance;
19372
+ // Capture initial value (composition ID or main index)
19373
+ if (!connectorState.initialValue && parent) {
19374
+ connectorState.initialValue = parent.getIndexName();
19316
19375
  }
19317
- if (!connectorState.setIndex) {
19318
- connectorState.setIndex = function (indexName) {
19319
- helper.setIndex(indexName).search();
19376
+
19377
+ // Create refine function if not exists
19378
+ if (!connectorState.refine) {
19379
+ // Cache composition mode status for lifecycle methods that don't have access to instantSearchInstance
19380
+ connectorState.isUsingComposition = Boolean(instantSearchInstance === null || instantSearchInstance === void 0 ? void 0 : instantSearchInstance.compositionID);
19381
+ connectorState.refine = function (value) {
19382
+ // O(1) lookup using the items lookup table
19383
+ var item = connectorState.itemsLookup[value];
19384
+ if (item && isStrategyItem(item)) {
19385
+ // Strategy-based: set sortBy parameter for composition API
19386
+ // The composition backend will interpret this and apply the sorting strategy
19387
+ helper.setQueryParameter('sortBy', item.strategy).search();
19388
+ } else {
19389
+ // Index-based: clear any existing sortBy parameter and switch to the new index
19390
+ // Clearing sortBy is critical when transitioning from strategy to index-based sorting
19391
+ helper.setQueryParameter('sortBy', undefined).setIndex(value).search();
19392
+ }
19320
19393
  };
19321
19394
  }
19395
+
19396
+ // Transform items first (on original structure)
19397
+ var transformedItems = transformItems(items, {
19398
+ results: results
19399
+ });
19400
+
19401
+ // Normalize items: all get a 'value' property for the render state
19402
+ var normalizedItems = transformedItems.map(function (item) {
19403
+ return {
19404
+ label: item.label,
19405
+ value: getItemValue(item)
19406
+ };
19407
+ });
19408
+
19409
+ // Determine current refinement
19410
+ // In composition mode, prefer sortBy parameter if it corresponds to a valid strategy item
19411
+ // Otherwise use the index (for index-based items or when no valid strategy is active)
19412
+ var currentRefinement = connectorState.isUsingComposition && isValidStrategy(connectorState.itemsLookup, state.sortBy) ? state.sortBy : state.index;
19322
19413
  var hasNoResults = results ? results.nbHits === 0 : true;
19323
19414
  return {
19324
- currentRefinement: state.index,
19325
- options: transformItems(items, {
19326
- results: results
19327
- }),
19328
- refine: connectorState.setIndex,
19415
+ currentRefinement: currentRefinement,
19416
+ options: normalizedItems,
19417
+ refine: connectorState.refine,
19329
19418
  hasNoResults: hasNoResults,
19330
19419
  canRefine: !hasNoResults && items.length > 0,
19331
19420
  widgetParams: widgetParams
@@ -19333,14 +19422,25 @@
19333
19422
  },
19334
19423
  getWidgetUiState: function getWidgetUiState(uiState, _ref4) {
19335
19424
  var searchParameters = _ref4.searchParameters;
19336
- var currentIndex = searchParameters.index;
19425
+ // In composition mode with an active strategy, use sortBy parameter
19426
+ // Otherwise use index-based behavior (traditional mode)
19427
+ var currentValue = connectorState.isUsingComposition && isValidStrategy(connectorState.itemsLookup, searchParameters.sortBy) ? searchParameters.sortBy : searchParameters.index;
19337
19428
  return _objectSpread$F(_objectSpread$F({}, uiState), {}, {
19338
- sortBy: currentIndex !== connectorState.initialIndex ? currentIndex : undefined
19429
+ sortBy: currentValue !== connectorState.initialValue ? currentValue : undefined
19339
19430
  });
19340
19431
  },
19341
19432
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) {
19342
19433
  var uiState = _ref5.uiState;
19343
- return searchParameters.setQueryParameter('index', uiState.sortBy || connectorState.initialIndex || searchParameters.index);
19434
+ var sortByValue = uiState.sortBy || connectorState.initialValue || searchParameters.index;
19435
+ if (isValidStrategy(connectorState.itemsLookup, sortByValue)) {
19436
+ var item = connectorState.itemsLookup[sortByValue];
19437
+ // Strategy-based: set the sortBy parameter for composition API
19438
+ // The index remains as the compositionID
19439
+ return searchParameters.setQueryParameter('sortBy', item.strategy);
19440
+ }
19441
+
19442
+ // Index-based: set the index parameter (traditional behavior)
19443
+ return searchParameters.setQueryParameter('index', sortByValue);
19344
19444
  }
19345
19445
  };
19346
19446
  };
@@ -20921,7 +21021,7 @@
20921
21021
  };
20922
21022
  }
20923
21023
 
20924
- var _excluded$d = ["className", "onSelect"];
21024
+ var _excluded$d = ["className", "onSelect", "onApply"];
20925
21025
  function createAutocompleteIndexComponent(_ref) {
20926
21026
  var createElement = _ref.createElement;
20927
21027
  return function AutocompleteIndex(userProps) {
@@ -20943,6 +21043,7 @@
20943
21043
  var _getItemProps = getItemProps(item, index),
20944
21044
  className = _getItemProps.className,
20945
21045
  onSelect = _getItemProps.onSelect,
21046
+ onApply = _getItemProps.onApply,
20946
21047
  itemProps = _objectWithoutProperties$d(_getItemProps, _excluded$d);
20947
21048
  return createElement("li", _extends$2({
20948
21049
  key: "".concat(itemProps.id, ":").concat(item.objectID)
@@ -20950,7 +21051,8 @@
20950
21051
  className: cx('ais-AutocompleteIndexItem', classNames.item, className)
20951
21052
  }), createElement(ItemComponent, {
20952
21053
  item: item,
20953
- onSelect: onSelect
21054
+ onSelect: onSelect,
21055
+ onApply: onApply
20954
21056
  }));
20955
21057
  })));
20956
21058
  };
@@ -21181,6 +21283,15 @@
21181
21283
  d: "M18 7v13c0 0.276-0.111 0.525-0.293 0.707s-0.431 0.293-0.707 0.293h-10c-0.276 0-0.525-0.111-0.707-0.293s-0.293-0.431-0.293-0.707v-13zM17 5v-1c0-0.828-0.337-1.58-0.879-2.121s-1.293-0.879-2.121-0.879h-4c-0.828 0-1.58 0.337-2.121 0.879s-0.879 1.293-0.879 2.121v1h-4c-0.552 0-1 0.448-1 1s0.448 1 1 1h1v13c0 0.828 0.337 1.58 0.879 2.121s1.293 0.879 2.121 0.879h10c0.828 0 1.58-0.337 2.121-0.879s0.879-1.293 0.879-2.121v-13h1c0.552 0 1-0.448 1-1s-0.448-1-1-1zM9 5v-1c0-0.276 0.111-0.525 0.293-0.707s0.431-0.293 0.707-0.293h4c0.276 0 0.525 0.111 0.707 0.293s0.293 0.431 0.293 0.707v1zM9 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1zM13 11v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1z"
21182
21284
  }));
21183
21285
  }
21286
+ function ApplyIcon(_ref6) {
21287
+ var createElement = _ref6.createElement;
21288
+ return createElement("svg", {
21289
+ viewBox: "0 0 24 24",
21290
+ fill: "currentColor"
21291
+ }, createElement("path", {
21292
+ d: "M8 17v-7.586l8.293 8.293c0.391 0.391 1.024 0.391 1.414 0s0.391-1.024 0-1.414l-8.293-8.293h7.586c0.552 0 1-0.448 1-1s-0.448-1-1-1h-10c-0.552 0-1 0.448-1 1v10c0 0.552 0.448 1 1 1s1-0.448 1-1z"
21293
+ }));
21294
+ }
21184
21295
 
21185
21296
  function createAutocompleteRecentSearchComponent(_ref) {
21186
21297
  var createElement = _ref.createElement;
@@ -21189,6 +21300,7 @@
21189
21300
  children = userProps.children,
21190
21301
  onSelect = userProps.onSelect,
21191
21302
  onRemoveRecentSearch = userProps.onRemoveRecentSearch,
21303
+ onApply = userProps.onApply,
21192
21304
  _userProps$classNames = userProps.classNames,
21193
21305
  classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames;
21194
21306
  return createElement("div", {
@@ -21213,6 +21325,15 @@
21213
21325
  }
21214
21326
  }, createElement(TrashIcon, {
21215
21327
  createElement: createElement
21328
+ })), createElement("button", {
21329
+ className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteRecentSearchItemApplyButton', classNames.applyButton),
21330
+ title: "Apply ".concat(item.query, " as search"),
21331
+ onClick: function onClick(evt) {
21332
+ evt.stopPropagation();
21333
+ onApply();
21334
+ }
21335
+ }, createElement(ApplyIcon, {
21336
+ createElement: createElement
21216
21337
  }))));
21217
21338
  };
21218
21339
  }
@@ -21286,8 +21407,10 @@
21286
21407
  function createAutocompleteSuggestionComponent(_ref) {
21287
21408
  var createElement = _ref.createElement;
21288
21409
  return function AutocompleteSuggestion(userProps) {
21289
- var children = userProps.children,
21410
+ var item = userProps.item,
21411
+ children = userProps.children,
21290
21412
  onSelect = userProps.onSelect,
21413
+ onApply = userProps.onApply,
21291
21414
  _userProps$classNames = userProps.classNames,
21292
21415
  classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames;
21293
21416
  return createElement("div", {
@@ -21301,7 +21424,19 @@
21301
21424
  createElement: createElement
21302
21425
  })), createElement("div", {
21303
21426
  className: cx('ais-AutocompleteItemContentBody', 'ais-AutocompleteSuggestionItemContentBody', classNames.content)
21304
- }, children)));
21427
+ }, children)), createElement("div", {
21428
+ className: cx('ais-AutocompleteItemActions', 'ais-AutocompleteSuggestionItemActions', classNames.actions)
21429
+ }, createElement("button", {
21430
+ className: cx('ais-AutocompleteItemActionButton', 'ais-AutocompleteSuggestionItemApplyButton', classNames.applyButton),
21431
+ type: "button",
21432
+ title: "Apply ".concat(item.query, " as search"),
21433
+ onClick: function onClick(evt) {
21434
+ evt.stopPropagation();
21435
+ onApply();
21436
+ }
21437
+ }, createElement(ApplyIcon, {
21438
+ createElement: createElement
21439
+ }))));
21305
21440
  };
21306
21441
  }
21307
21442
 
@@ -21316,6 +21451,7 @@
21316
21451
  indicesConfig = _ref2.indicesConfig,
21317
21452
  onRefine = _ref2.onRefine,
21318
21453
  globalOnSelect = _ref2.onSelect,
21454
+ _onApply = _ref2.onApply,
21319
21455
  placeholder = _ref2.placeholder;
21320
21456
  var getElementId = createGetElementId(useId());
21321
21457
  var inputRef = useRef(null);
@@ -21483,6 +21619,13 @@
21483
21619
  return submit({
21484
21620
  activeDescendant: id
21485
21621
  });
21622
+ },
21623
+ onApply: function onApply() {
21624
+ var _getQuery2;
21625
+ var _ref4 = items.get(id),
21626
+ currentItem = _ref4.item,
21627
+ getQuery = _ref4.config.getQuery;
21628
+ _onApply((_getQuery2 = getQuery === null || getQuery === void 0 ? void 0 : getQuery(currentItem)) !== null && _getQuery2 !== void 0 ? _getQuery2 : '');
21486
21629
  }
21487
21630
  };
21488
21631
  },
@@ -21502,10 +21645,10 @@
21502
21645
  };
21503
21646
  };
21504
21647
  }
21505
- function buildItems(_ref4) {
21506
- var indices = _ref4.indices,
21507
- indicesConfig = _ref4.indicesConfig,
21508
- getElementId = _ref4.getElementId;
21648
+ function buildItems(_ref5) {
21649
+ var indices = _ref5.indices,
21650
+ indicesConfig = _ref5.indicesConfig,
21651
+ getElementId = _ref5.getElementId;
21509
21652
  var itemsIds = [];
21510
21653
  var items = new Map();
21511
21654
  for (var i = 0; i < indicesConfig.length; i++) {
@@ -22546,7 +22689,7 @@
22546
22689
  }
22547
22690
 
22548
22691
  var _excluded$o = ["indices", "showSuggestions", "showRecent", "searchParameters"],
22549
- _excluded2$5 = ["indicesConfig", "refineSearchBox", "getSearchPageURL", "onSelect", "indexUiState", "isSearchPage", "panelComponent", "showRecent", "showSuggestions", "placeholder"];
22692
+ _excluded2$5 = ["indicesConfig", "refineSearchBox", "getSearchPageURL", "onSelect", "indexUiState", "isSearchPage", "panelComponent", "showRecent", "recentSearchConfig", "showSuggestions", "placeholder"];
22550
22693
  var Autocomplete = createAutocompleteComponent({
22551
22694
  createElement: React.createElement,
22552
22695
  Fragment: React.Fragment
@@ -22580,6 +22723,7 @@
22580
22723
  useState: React.useState
22581
22724
  });
22582
22725
  function EXPERIMENTAL_Autocomplete(_ref) {
22726
+ var _showRecent$className, _showRecent$className2, _showRecent$className3, _showRecent$className4;
22583
22727
  var _ref$indices = _ref.indices,
22584
22728
  indices = _ref$indices === void 0 ? [] : _ref$indices,
22585
22729
  showSuggestions = _ref.showSuggestions,
@@ -22605,10 +22749,12 @@
22605
22749
  headerComponent: showSuggestions.headerComponent,
22606
22750
  itemComponent: showSuggestions.itemComponent || function (_ref2) {
22607
22751
  var item = _ref2.item,
22608
- onSelect = _ref2.onSelect;
22752
+ onSelect = _ref2.onSelect,
22753
+ onApply = _ref2.onApply;
22609
22754
  return /*#__PURE__*/React__default.createElement(AutocompleteSuggestion, {
22610
22755
  item: item,
22611
- onSelect: onSelect
22756
+ onSelect: onSelect,
22757
+ onApply: onApply
22612
22758
  }, /*#__PURE__*/React__default.createElement(ConditionalReverseHighlight, {
22613
22759
  item: item
22614
22760
  }));
@@ -22625,6 +22771,16 @@
22625
22771
  getURL: showSuggestions.getURL
22626
22772
  });
22627
22773
  }
22774
+ var recentSearchConfig = showRecent ? {
22775
+ headerComponent: _typeof$S(showRecent) === 'object' ? showRecent.headerComponent : undefined,
22776
+ itemComponent: _typeof$S(showRecent) === 'object' && showRecent.itemComponent ? showRecent.itemComponent : AutocompleteRecentSearch,
22777
+ classNames: {
22778
+ root: cx('ais-AutocompleteRecentSearches', _typeof$S(showRecent) === 'object' ? (_showRecent$className = showRecent.classNames) === null || _showRecent$className === void 0 ? void 0 : _showRecent$className.root : undefined),
22779
+ list: cx('ais-AutocompleteRecentSearchesList', _typeof$S(showRecent) === 'object' ? (_showRecent$className2 = showRecent.classNames) === null || _showRecent$className2 === void 0 ? void 0 : _showRecent$className2.list : undefined),
22780
+ header: cx('ais-AutocompleteRecentSearchesHeader', _typeof$S(showRecent) === 'object' ? (_showRecent$className3 = showRecent.classNames) === null || _showRecent$className3 === void 0 ? void 0 : _showRecent$className3.header : undefined),
22781
+ item: cx('ais-AutocompleteRecentSearchesItem', _typeof$S(showRecent) === 'object' ? (_showRecent$className4 = showRecent.classNames) === null || _showRecent$className4 === void 0 ? void 0 : _showRecent$className4.item : undefined)
22782
+ }
22783
+ } : undefined;
22628
22784
  var isSearchPage = React.useMemo(function () {
22629
22785
  return typeof indexRenderState.hits !== 'undefined' || typeof indexRenderState.infiniteHits !== 'undefined';
22630
22786
  }, [indexRenderState]);
@@ -22641,6 +22797,7 @@
22641
22797
  indexUiState: indexUiState,
22642
22798
  isSearchPage: isSearchPage,
22643
22799
  showRecent: showRecent,
22800
+ recentSearchConfig: recentSearchConfig,
22644
22801
  showSuggestions: showSuggestions
22645
22802
  }))));
22646
22803
  }
@@ -22653,6 +22810,7 @@
22653
22810
  isSearchPage = _ref3.isSearchPage,
22654
22811
  PanelComponent = _ref3.panelComponent,
22655
22812
  showRecent = _ref3.showRecent,
22813
+ recentSearchConfig = _ref3.recentSearchConfig,
22656
22814
  showSuggestions = _ref3.showSuggestions,
22657
22815
  placeholder = _ref3.placeholder,
22658
22816
  props = _objectWithoutProperties$c(_ref3, _excluded2$5);
@@ -22678,6 +22836,9 @@
22678
22836
  refineSearchBox(query);
22679
22837
  storage.onAdd(query);
22680
22838
  },
22839
+ onApply: function onApply(query) {
22840
+ refineAutocomplete(query);
22841
+ },
22681
22842
  onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function (_ref4) {
22682
22843
  var query = _ref4.query,
22683
22844
  setQuery = _ref4.setQuery,
@@ -22700,30 +22861,29 @@
22700
22861
  getItemProps = _usePropGetters.getItemProps,
22701
22862
  getPanelProps = _usePropGetters.getPanelProps,
22702
22863
  getRootProps = _usePropGetters.getRootProps;
22703
- var AutocompleteRecentSearchComponent = _typeof$S(showRecent) === 'object' && showRecent.itemComponent || AutocompleteRecentSearch;
22704
22864
  var elements = {};
22705
- if (showRecent) {
22706
- elements.recent = /*#__PURE__*/React__default.createElement(AutocompleteIndex
22707
- // @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
22708
- , {
22865
+ if (showRecent && recentSearchConfig) {
22866
+ var RecentSearchItemComponent = recentSearchConfig.itemComponent;
22867
+ elements.recent = /*#__PURE__*/React__default.createElement(AutocompleteIndex, {
22868
+ HeaderComponent: recentSearchConfig.headerComponent
22869
+ // @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
22870
+ ,
22709
22871
  ItemComponent: function ItemComponent(_ref5) {
22710
22872
  var item = _ref5.item,
22711
- onSelect = _ref5.onSelect;
22712
- return /*#__PURE__*/React__default.createElement(AutocompleteRecentSearchComponent, {
22873
+ onSelect = _ref5.onSelect,
22874
+ onApply = _ref5.onApply;
22875
+ return /*#__PURE__*/React__default.createElement(RecentSearchItemComponent, {
22713
22876
  item: item,
22714
22877
  onSelect: onSelect,
22715
22878
  onRemoveRecentSearch: function onRemoveRecentSearch() {
22716
22879
  return storage.onRemove(item.query);
22717
- }
22880
+ },
22881
+ onApply: onApply
22718
22882
  }, /*#__PURE__*/React__default.createElement(ConditionalReverseHighlight, {
22719
22883
  item: item
22720
22884
  }));
22721
22885
  },
22722
- classNames: {
22723
- root: 'ais-AutocompleteRecentSearches',
22724
- list: 'ais-AutocompleteRecentSearchesList',
22725
- item: 'ais-AutocompleteRecentSearchesItem'
22726
- },
22886
+ classNames: recentSearchConfig.classNames,
22727
22887
  items: storageHits,
22728
22888
  getItemProps: getItemProps,
22729
22889
  key: "recentSearches"