react-instantsearch 7.19.0 → 7.20.1

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.
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ReverseHighlight = ReverseHighlight;
7
+ var _instantsearchUiComponents = require("instantsearch-ui-components");
8
+ var _react = _interopRequireDefault(require("react"));
9
+ var _InternalHighlight = require("./InternalHighlight");
10
+ var _excluded = ["classNames"];
11
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
13
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
14
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
15
+ function ReverseHighlight(_ref) {
16
+ var _ref$classNames = _ref.classNames,
17
+ classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
18
+ props = _objectWithoutProperties(_ref, _excluded);
19
+ return /*#__PURE__*/_react.default.createElement(_InternalHighlight.InternalHighlight, _extends({
20
+ classNames: {
21
+ root: (0, _instantsearchUiComponents.cx)('ais-ReverseHighlight', classNames.root),
22
+ highlighted: (0, _instantsearchUiComponents.cx)('ais-ReverseHighlight-highlighted', classNames.highlighted),
23
+ nonHighlighted: (0, _instantsearchUiComponents.cx)('ais-ReverseHighlight-nonHighlighted', classNames.nonHighlighted),
24
+ separator: (0, _instantsearchUiComponents.cx)('ais-ReverseHighlight-separator', classNames.separator)
25
+ }
26
+ }, props));
27
+ }
@@ -8,15 +8,11 @@ var _instantsearchUiComponents = require("instantsearch-ui-components");
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _reactInstantsearchCore = require("react-instantsearch-core");
10
10
  var _AutocompleteSearch = require("../components/AutocompleteSearch");
11
- var _excluded = ["indices", "showSuggestions", "showRecent"],
12
- _excluded2 = ["indicesConfig", "refineSearchBox", "getSearchPageURL", "onSelect", "indexUiState", "isSearchPage", "showRecent"];
11
+ var _ReverseHighlight = require("./ReverseHighlight");
12
+ var _excluded = ["indices", "showSuggestions", "showRecent", "searchParameters"],
13
+ _excluded2 = ["indicesConfig", "refineSearchBox", "getSearchPageURL", "onSelect", "indexUiState", "isSearchPage", "panelComponent", "showRecent", "showSuggestions", "placeholder"];
13
14
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
14
15
  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); }
15
- 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; }
16
- 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; }
17
- 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; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
- function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
16
  function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
21
17
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
22
18
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
@@ -24,6 +20,11 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
24
20
  function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
25
21
  function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
26
22
  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; }
23
+ 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; }
24
+ 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; }
25
+ 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; }
26
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
27
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
27
28
  function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
28
29
  function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
29
30
  var Autocomplete = (0, _instantsearchUiComponents.createAutocompleteComponent)({
@@ -58,14 +59,12 @@ var useStorage = (0, _instantsearchUiComponents.createAutocompleteStorage)({
58
59
  useMemo: _react.useMemo,
59
60
  useState: _react.useState
60
61
  });
61
- var _ref2 = /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.Configure, {
62
- hitsPerPage: 5
63
- });
64
62
  function EXPERIMENTAL_Autocomplete(_ref) {
65
63
  var _ref$indices = _ref.indices,
66
64
  indices = _ref$indices === void 0 ? [] : _ref$indices,
67
65
  showSuggestions = _ref.showSuggestions,
68
66
  showRecent = _ref.showRecent,
67
+ userSearchParameters = _ref.searchParameters,
69
68
  props = _objectWithoutProperties(_ref, _excluded);
70
69
  var _useInstantSearch = (0, _reactInstantsearchCore.useInstantSearch)(),
71
70
  indexUiState = _useInstantSearch.indexUiState,
@@ -75,13 +74,25 @@ function EXPERIMENTAL_Autocomplete(_ref) {
75
74
  $$widgetType: 'ais.autocomplete'
76
75
  }),
77
76
  refine = _useSearchBox.refine;
77
+ var searchParameters = _objectSpread({
78
+ hitsPerPage: 5
79
+ }, userSearchParameters);
78
80
  var indicesConfig = _toConsumableArray(indices);
79
81
  if (showSuggestions !== null && showSuggestions !== void 0 && showSuggestions.indexName) {
80
82
  var _showSuggestions$clas, _showSuggestions$clas2, _showSuggestions$clas3, _showSuggestions$clas4;
81
83
  indicesConfig.unshift({
82
84
  indexName: showSuggestions.indexName,
83
85
  headerComponent: showSuggestions.headerComponent,
84
- itemComponent: showSuggestions.itemComponent || AutocompleteSuggestion,
86
+ itemComponent: showSuggestions.itemComponent || function (_ref2) {
87
+ var item = _ref2.item,
88
+ onSelect = _ref2.onSelect;
89
+ return /*#__PURE__*/_react.default.createElement(AutocompleteSuggestion, {
90
+ item: item,
91
+ onSelect: onSelect
92
+ }, /*#__PURE__*/_react.default.createElement(ConditionalReverseHighlight, {
93
+ item: item
94
+ }));
95
+ },
85
96
  classNames: {
86
97
  root: (0, _instantsearchUiComponents.cx)('ais-AutocompleteSuggestions', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions$clas = showSuggestions.classNames) === null || _showSuggestions$clas === void 0 ? void 0 : _showSuggestions$clas.root),
87
98
  list: (0, _instantsearchUiComponents.cx)('ais-AutocompleteSuggestionsList', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions$clas2 = showSuggestions.classNames) === null || _showSuggestions$clas2 === void 0 ? void 0 : _showSuggestions$clas2.list),
@@ -99,17 +110,18 @@ function EXPERIMENTAL_Autocomplete(_ref) {
99
110
  }, [indexRenderState]);
100
111
  return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.Index, {
101
112
  EXPERIMENTAL_isolated: true
102
- }, _ref2, indicesConfig.map(function (index) {
113
+ }, /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.Configure, searchParameters), indicesConfig.map(function (index) {
103
114
  return /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.Index, {
104
115
  key: index.indexName,
105
116
  indexName: index.indexName
106
- });
117
+ }, /*#__PURE__*/_react.default.createElement(_reactInstantsearchCore.Configure, index.searchParameters));
107
118
  }), /*#__PURE__*/_react.default.createElement(InnerAutocomplete, _extends({}, props, {
108
119
  indicesConfig: indicesConfig,
109
120
  refineSearchBox: refine,
110
121
  indexUiState: indexUiState,
111
122
  isSearchPage: isSearchPage,
112
- showRecent: showRecent
123
+ showRecent: showRecent,
124
+ showSuggestions: showSuggestions
113
125
  }))));
114
126
  }
115
127
  function InnerAutocomplete(_ref3) {
@@ -119,7 +131,10 @@ function InnerAutocomplete(_ref3) {
119
131
  userOnSelect = _ref3.onSelect,
120
132
  indexUiState = _ref3.indexUiState,
121
133
  isSearchPage = _ref3.isSearchPage,
134
+ PanelComponent = _ref3.panelComponent,
122
135
  showRecent = _ref3.showRecent,
136
+ showSuggestions = _ref3.showSuggestions,
137
+ placeholder = _ref3.placeholder,
123
138
  props = _objectWithoutProperties(_ref3, _excluded2);
124
139
  var _useAutocomplete = (0, _reactInstantsearchCore.useAutocomplete)(),
125
140
  indices = _useAutocomplete.indices,
@@ -158,58 +173,92 @@ function InnerAutocomplete(_ref3) {
158
173
  return;
159
174
  }
160
175
  setQuery(query);
161
- }
176
+ },
177
+ placeholder: placeholder
162
178
  }),
163
179
  getInputProps = _usePropGetters.getInputProps,
164
180
  getItemProps = _usePropGetters.getItemProps,
165
181
  getPanelProps = _usePropGetters.getPanelProps,
166
182
  getRootProps = _usePropGetters.getRootProps;
167
183
  var AutocompleteRecentSearchComponent = _typeof(showRecent) === 'object' && showRecent.itemComponent || AutocompleteRecentSearch;
168
- return /*#__PURE__*/_react.default.createElement(Autocomplete, _extends({}, props, getRootProps()), /*#__PURE__*/_react.default.createElement(_AutocompleteSearch.AutocompleteSearch, {
169
- inputProps: getInputProps(),
170
- clearQuery: function clearQuery() {
171
- refineSearchBox('');
172
- refineAutocomplete('');
173
- }
174
- }), /*#__PURE__*/_react.default.createElement(AutocompletePanel, getPanelProps(), showRecent && /*#__PURE__*/_react.default.createElement(AutocompleteIndex
175
- // @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
176
- , {
177
- ItemComponent: function ItemComponent(_ref5) {
178
- var item = _ref5.item,
179
- onSelect = _ref5.onSelect;
180
- return /*#__PURE__*/_react.default.createElement(AutocompleteRecentSearchComponent, {
181
- item: item,
182
- onSelect: onSelect,
183
- onRemoveRecentSearch: function onRemoveRecentSearch() {
184
- return storage.onRemove(item.query);
185
- }
186
- });
187
- },
188
- classNames: {
189
- root: 'ais-AutocompleteRecentSearches',
190
- list: 'ais-AutocompleteRecentSearchesList',
191
- item: 'ais-AutocompleteRecentSearchesItem'
192
- },
193
- items: storageHits,
194
- getItemProps: getItemProps
195
- }), indices.map(function (_ref6, index) {
184
+ var elements = {};
185
+ if (showRecent) {
186
+ elements.recent = /*#__PURE__*/_react.default.createElement(AutocompleteIndex
187
+ // @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
188
+ , {
189
+ ItemComponent: function ItemComponent(_ref5) {
190
+ var item = _ref5.item,
191
+ onSelect = _ref5.onSelect;
192
+ return /*#__PURE__*/_react.default.createElement(AutocompleteRecentSearchComponent, {
193
+ item: item,
194
+ onSelect: onSelect,
195
+ onRemoveRecentSearch: function onRemoveRecentSearch() {
196
+ return storage.onRemove(item.query);
197
+ }
198
+ }, /*#__PURE__*/_react.default.createElement(ConditionalReverseHighlight, {
199
+ item: item
200
+ }));
201
+ },
202
+ classNames: {
203
+ root: 'ais-AutocompleteRecentSearches',
204
+ list: 'ais-AutocompleteRecentSearchesList',
205
+ item: 'ais-AutocompleteRecentSearchesItem'
206
+ },
207
+ items: storageHits,
208
+ getItemProps: getItemProps,
209
+ key: "recentSearches"
210
+ });
211
+ }
212
+ indices.forEach(function (_ref6, i) {
196
213
  var indexId = _ref6.indexId,
214
+ indexName = _ref6.indexName,
197
215
  hits = _ref6.hits;
198
- return /*#__PURE__*/_react.default.createElement(AutocompleteIndex, {
216
+ var elementId = indexName === (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) ? 'suggestions' : indexName;
217
+ var filteredHits = elementId === 'suggestions' && showRecent ? hits.filter(function (suggestionHit) {
218
+ return !storageHits.find(function (storageHit) {
219
+ return storageHit.query === suggestionHit.query;
220
+ });
221
+ }) : hits;
222
+ elements[elementId] = /*#__PURE__*/_react.default.createElement(AutocompleteIndex, {
199
223
  key: indexId
200
224
  // @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
201
225
  ,
202
- HeaderComponent: indicesConfig[index].headerComponent
226
+ HeaderComponent: indicesConfig[i].headerComponent
203
227
  // @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
204
228
  ,
205
- ItemComponent: indicesConfig[index].itemComponent,
206
- items: hits.map(function (item) {
229
+ ItemComponent: indicesConfig[i].itemComponent,
230
+ items: filteredHits.map(function (item) {
207
231
  return _objectSpread(_objectSpread({}, item), {}, {
208
232
  __indexName: indexId
209
233
  });
210
234
  }),
211
235
  getItemProps: getItemProps,
212
- classNames: indicesConfig[index].classNames
236
+ classNames: indicesConfig[i].classNames
213
237
  });
238
+ });
239
+ return /*#__PURE__*/_react.default.createElement(Autocomplete, _extends({}, props, getRootProps()), /*#__PURE__*/_react.default.createElement(_AutocompleteSearch.AutocompleteSearch, {
240
+ inputProps: getInputProps(),
241
+ clearQuery: function clearQuery() {
242
+ refineSearchBox('');
243
+ refineAutocomplete('');
244
+ }
245
+ }), /*#__PURE__*/_react.default.createElement(AutocompletePanel, getPanelProps(), PanelComponent ? /*#__PURE__*/_react.default.createElement(PanelComponent, {
246
+ elements: elements,
247
+ indices: indices
248
+ }) : Object.keys(elements).map(function (elementId) {
249
+ return elements[elementId];
214
250
  })));
251
+ }
252
+ function ConditionalReverseHighlight(_ref7) {
253
+ var _item$_highlightResul;
254
+ var item = _ref7.item;
255
+ if (!((_item$_highlightResul = item._highlightResult) !== null && _item$_highlightResul !== void 0 && _item$_highlightResul.query) ||
256
+ // @ts-expect-error - we should not have matchLevel as arrays here
257
+ item._highlightResult.query.matchLevel === 'none') {
258
+ return item.query;
259
+ }
260
+ return /*#__PURE__*/_react.default.createElement(_ReverseHighlight.ReverseHighlight, {
261
+ attribute: "query",
262
+ hit: item
263
+ });
215
264
  }
@@ -0,0 +1,46 @@
1
+ "use strict";
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
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.ReverseHighlight = ReverseHighlight;
8
+ var _utils = require("instantsearch.js/cjs/lib/utils");
9
+ var _react = _interopRequireDefault(require("react"));
10
+ var _ReverseHighlight = require("../ui/ReverseHighlight");
11
+ var _excluded = ["hit", "attribute", "highlightedTagName", "nonHighlightedTagName", "separator"],
12
+ _excluded2 = ["isHighlighted"];
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
15
+ 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; }
16
+ 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; }
17
+ 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; }
18
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
19
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
21
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
22
+ function ReverseHighlight(_ref) {
23
+ var hit = _ref.hit,
24
+ attribute = _ref.attribute,
25
+ highlightedTagName = _ref.highlightedTagName,
26
+ nonHighlightedTagName = _ref.nonHighlightedTagName,
27
+ separator = _ref.separator,
28
+ props = _objectWithoutProperties(_ref, _excluded);
29
+ var property = (0, _utils.getPropertyByPath)(hit._highlightResult, attribute) || [];
30
+ var properties = Array.isArray(property) ? property : [property];
31
+ var parts = properties.map(function (singleValue) {
32
+ return (0, _utils.getHighlightedParts)((0, _utils.unescape)(singleValue.value || '')).map(function (_ref2) {
33
+ var isHighlighted = _ref2.isHighlighted,
34
+ rest = _objectWithoutProperties(_ref2, _excluded2);
35
+ return _objectSpread(_objectSpread({}, rest), {}, {
36
+ isHighlighted: !isHighlighted
37
+ });
38
+ });
39
+ });
40
+ return /*#__PURE__*/_react.default.createElement(_ReverseHighlight.ReverseHighlight, _extends({}, props, {
41
+ parts: parts,
42
+ highlightedTagName: highlightedTagName,
43
+ nonHighlightedTagName: nonHighlightedTagName,
44
+ separator: separator
45
+ }));
46
+ }
@@ -89,7 +89,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
89
89
  window.location.href = getSearchPageURL(nextUiState);
90
90
  },
91
91
  className: "ais-ChatToolSearchIndexCarouselHeaderViewAll"
92
- }, "View all", /*#__PURE__*/_react.default.createElement(_instantsearchUiComponents.ArrowRightIconComponent, {
92
+ }, "View all", /*#__PURE__*/_react.default.createElement(_instantsearchUiComponents.ArrowRightIcon, {
93
93
  createElement: _react.createElement
94
94
  }))), (hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) > 2 && /*#__PURE__*/_react.default.createElement("div", {
95
95
  className: "ais-ChatToolSearchIndexCarouselHeaderScrollButtons"
@@ -100,7 +100,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
100
100
  onClick: scrollLeft,
101
101
  disabled: !canScrollLeft,
102
102
  className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
103
- }, /*#__PURE__*/_react.default.createElement(_instantsearchUiComponents.ChevronLeftIconComponent, {
103
+ }, /*#__PURE__*/_react.default.createElement(_instantsearchUiComponents.ChevronLeftIcon, {
104
104
  createElement: _react.createElement
105
105
  })), /*#__PURE__*/_react.default.createElement(Button, {
106
106
  variant: "outline",
@@ -109,7 +109,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
109
109
  onClick: scrollRight,
110
110
  disabled: !canScrollRight,
111
111
  className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
112
- }, /*#__PURE__*/_react.default.createElement(_instantsearchUiComponents.ChevronRightIconComponent, {
112
+ }, /*#__PURE__*/_react.default.createElement(_instantsearchUiComponents.ChevronRightIcon, {
113
113
  createElement: _react.createElement
114
114
  }))));
115
115
  }
@@ -201,6 +201,17 @@ Object.keys(_RelatedProducts).forEach(function (key) {
201
201
  }
202
202
  });
203
203
  });
204
+ var _ReverseHighlight = require("./ReverseHighlight");
205
+ Object.keys(_ReverseHighlight).forEach(function (key) {
206
+ if (key === "default" || key === "__esModule") return;
207
+ if (key in exports && exports[key] === _ReverseHighlight[key]) return;
208
+ Object.defineProperty(exports, key, {
209
+ enumerable: true,
210
+ get: function get() {
211
+ return _ReverseHighlight[key];
212
+ }
213
+ });
214
+ });
204
215
  var _SearchBox = require("./SearchBox");
205
216
  Object.keys(_SearchBox).forEach(function (key) {
206
217
  if (key === "default" || key === "__esModule") return;
@@ -214,6 +214,18 @@ Object.keys(_RelatedProducts).forEach(function (key) {
214
214
  }
215
215
  });
216
216
  });
217
+ var _ReverseHighlight = require("./ReverseHighlight");
218
+ Object.keys(_ReverseHighlight).forEach(function (key) {
219
+ if (key === "default" || key === "__esModule") return;
220
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
221
+ if (key in exports && exports[key] === _ReverseHighlight[key]) return;
222
+ Object.defineProperty(exports, key, {
223
+ enumerable: true,
224
+ get: function get() {
225
+ return _ReverseHighlight[key];
226
+ }
227
+ });
228
+ });
217
229
  var _SearchBox = require("./SearchBox");
218
230
  Object.keys(_SearchBox).forEach(function (key) {
219
231
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import type { HighlightProps as InternalHighlightProps, HighlightClassNames as InternalHighlightClassNames } from 'instantsearch-ui-components';
3
+ export type ReverseHighlightClassNames = InternalHighlightClassNames;
4
+ export type ReverseHighlightProps = Omit<InternalHighlightProps, 'classNames'> & {
5
+ classNames?: Partial<ReverseHighlightClassNames>;
6
+ };
7
+ export declare function ReverseHighlight({ classNames, ...props }: ReverseHighlightProps): React.JSX.Element;
@@ -0,0 +1,20 @@
1
+ var _excluded = ["classNames"];
2
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
3
+ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
4
+ function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
5
+ import { cx } from 'instantsearch-ui-components';
6
+ import React from 'react';
7
+ import { InternalHighlight } from "./InternalHighlight.js";
8
+ export function ReverseHighlight(_ref) {
9
+ var _ref$classNames = _ref.classNames,
10
+ classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
11
+ props = _objectWithoutProperties(_ref, _excluded);
12
+ return /*#__PURE__*/React.createElement(InternalHighlight, _extends({
13
+ classNames: {
14
+ root: cx('ais-ReverseHighlight', classNames.root),
15
+ highlighted: cx('ais-ReverseHighlight-highlighted', classNames.highlighted),
16
+ nonHighlighted: cx('ais-ReverseHighlight-nonHighlighted', classNames.nonHighlighted),
17
+ separator: cx('ais-ReverseHighlight-separator', classNames.separator)
18
+ }
19
+ }, props));
20
+ }
@@ -1,12 +1,17 @@
1
1
  import React from 'react';
2
+ import { useAutocomplete } from 'react-instantsearch-core';
3
+ import type { PlainSearchParameters } from 'algoliasearch-helper';
2
4
  import type { AutocompleteIndexClassNames, AutocompleteIndexConfig, AutocompleteClassNames, AutocompleteIndexProps } from 'instantsearch-ui-components';
3
5
  import type { BaseHit, IndexUiState } from 'instantsearch.js';
4
6
  import type { ComponentProps } from 'react';
7
+ type AutocompleteSearchParameters = Omit<PlainSearchParameters, 'index'>;
5
8
  type IndexConfig<TItem extends BaseHit> = AutocompleteIndexConfig<TItem> & {
6
9
  headerComponent?: AutocompleteIndexProps<TItem>['HeaderComponent'];
7
10
  itemComponent: AutocompleteIndexProps<TItem>['ItemComponent'];
11
+ searchParameters?: AutocompleteSearchParameters;
8
12
  classNames?: Partial<AutocompleteIndexClassNames>;
9
13
  };
14
+ type PanelElements = Partial<Record<'recent' | 'suggestions' | (string & {}), React.JSX.Element>>;
10
15
  export type AutocompleteProps<TItem extends BaseHit> = ComponentProps<'div'> & {
11
16
  indices?: Array<IndexConfig<TItem>>;
12
17
  showSuggestions?: Partial<Pick<IndexConfig<{
@@ -28,7 +33,13 @@ export type AutocompleteProps<TItem extends BaseHit> = ComponentProps<'div'> & {
28
33
  };
29
34
  getSearchPageURL?: (nextUiState: IndexUiState) => string;
30
35
  onSelect?: AutocompleteIndexConfig<TItem>['onSelect'];
36
+ panelComponent?: (props: {
37
+ elements: PanelElements;
38
+ indices: ReturnType<typeof useAutocomplete>['indices'];
39
+ }) => React.JSX.Element;
40
+ searchParameters?: AutocompleteSearchParameters;
31
41
  classNames?: Partial<AutocompleteClassNames>;
42
+ placeholder?: string;
32
43
  };
33
- export declare function EXPERIMENTAL_Autocomplete<TItem extends BaseHit = BaseHit>({ indices, showSuggestions, showRecent, ...props }: AutocompleteProps<TItem>): React.JSX.Element;
44
+ export declare function EXPERIMENTAL_Autocomplete<TItem extends BaseHit = BaseHit>({ indices, showSuggestions, showRecent, searchParameters: userSearchParameters, ...props }: AutocompleteProps<TItem>): React.JSX.Element;
34
45
  export {};