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.
- package/dist/cjs/ui/ReverseHighlight.js +27 -0
- package/dist/cjs/widgets/Autocomplete.js +97 -48
- package/dist/cjs/widgets/ReverseHighlight.js +46 -0
- package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +3 -3
- package/dist/cjs/widgets/index.js +11 -0
- package/dist/cjs/widgets/index.umd.js +12 -0
- package/dist/es/ui/ReverseHighlight.d.ts +7 -0
- package/dist/es/ui/ReverseHighlight.js +20 -0
- package/dist/es/widgets/Autocomplete.d.ts +12 -1
- package/dist/es/widgets/Autocomplete.js +97 -48
- package/dist/es/widgets/ReverseHighlight.d.ts +9 -0
- package/dist/es/widgets/ReverseHighlight.js +39 -0
- package/dist/es/widgets/chat/tools/SearchIndexTool.js +4 -4
- package/dist/es/widgets/index.d.ts +1 -0
- package/dist/es/widgets/index.js +1 -0
- package/dist/es/widgets/index.umd.d.ts +1 -0
- package/dist/es/widgets/index.umd.js +1 -0
- package/dist/umd/ReactInstantSearch.js +349 -194
- package/dist/umd/ReactInstantSearch.js.map +1 -1
- package/dist/umd/ReactInstantSearch.min.js +1 -1
- package/dist/umd/ReactInstantSearch.min.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
var _excluded = ["indices", "showSuggestions", "showRecent"],
|
|
2
|
-
_excluded2 = ["indicesConfig", "refineSearchBox", "getSearchPageURL", "onSelect", "indexUiState", "isSearchPage", "showRecent"];
|
|
1
|
+
var _excluded = ["indices", "showSuggestions", "showRecent", "searchParameters"],
|
|
2
|
+
_excluded2 = ["indicesConfig", "refineSearchBox", "getSearchPageURL", "onSelect", "indexUiState", "isSearchPage", "panelComponent", "showRecent", "showSuggestions", "placeholder"];
|
|
3
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
|
-
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; }
|
|
5
|
-
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; }
|
|
6
|
-
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; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
8
|
-
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); }
|
|
9
4
|
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); }
|
|
10
5
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
11
6
|
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."); }
|
|
@@ -13,12 +8,18 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
13
8
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
14
9
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
15
10
|
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; }
|
|
11
|
+
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; }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
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); }
|
|
16
16
|
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; }
|
|
17
17
|
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; }
|
|
18
18
|
import { createAutocompleteComponent, createAutocompleteIndexComponent, createAutocompletePanelComponent, createAutocompletePropGetters, createAutocompleteSuggestionComponent, createAutocompleteRecentSearchComponent, createAutocompleteStorage, cx } from 'instantsearch-ui-components';
|
|
19
19
|
import React, { createElement, Fragment, useEffect, useId, useMemo, useRef, useState } from 'react';
|
|
20
20
|
import { Configure, Index, useAutocomplete, useInstantSearch, useSearchBox } from 'react-instantsearch-core';
|
|
21
21
|
import { AutocompleteSearch } from "../components/AutocompleteSearch.js";
|
|
22
|
+
import { ReverseHighlight } from "./ReverseHighlight.js";
|
|
22
23
|
var Autocomplete = createAutocompleteComponent({
|
|
23
24
|
createElement: createElement,
|
|
24
25
|
Fragment: Fragment
|
|
@@ -51,14 +52,12 @@ var useStorage = createAutocompleteStorage({
|
|
|
51
52
|
useMemo: useMemo,
|
|
52
53
|
useState: useState
|
|
53
54
|
});
|
|
54
|
-
var _ref2 = /*#__PURE__*/React.createElement(Configure, {
|
|
55
|
-
hitsPerPage: 5
|
|
56
|
-
});
|
|
57
55
|
export function EXPERIMENTAL_Autocomplete(_ref) {
|
|
58
56
|
var _ref$indices = _ref.indices,
|
|
59
57
|
indices = _ref$indices === void 0 ? [] : _ref$indices,
|
|
60
58
|
showSuggestions = _ref.showSuggestions,
|
|
61
59
|
showRecent = _ref.showRecent,
|
|
60
|
+
userSearchParameters = _ref.searchParameters,
|
|
62
61
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
63
62
|
var _useInstantSearch = useInstantSearch(),
|
|
64
63
|
indexUiState = _useInstantSearch.indexUiState,
|
|
@@ -68,13 +67,25 @@ export function EXPERIMENTAL_Autocomplete(_ref) {
|
|
|
68
67
|
$$widgetType: 'ais.autocomplete'
|
|
69
68
|
}),
|
|
70
69
|
refine = _useSearchBox.refine;
|
|
70
|
+
var searchParameters = _objectSpread({
|
|
71
|
+
hitsPerPage: 5
|
|
72
|
+
}, userSearchParameters);
|
|
71
73
|
var indicesConfig = _toConsumableArray(indices);
|
|
72
74
|
if (showSuggestions !== null && showSuggestions !== void 0 && showSuggestions.indexName) {
|
|
73
75
|
var _showSuggestions$clas, _showSuggestions$clas2, _showSuggestions$clas3, _showSuggestions$clas4;
|
|
74
76
|
indicesConfig.unshift({
|
|
75
77
|
indexName: showSuggestions.indexName,
|
|
76
78
|
headerComponent: showSuggestions.headerComponent,
|
|
77
|
-
itemComponent: showSuggestions.itemComponent ||
|
|
79
|
+
itemComponent: showSuggestions.itemComponent || function (_ref2) {
|
|
80
|
+
var item = _ref2.item,
|
|
81
|
+
onSelect = _ref2.onSelect;
|
|
82
|
+
return /*#__PURE__*/React.createElement(AutocompleteSuggestion, {
|
|
83
|
+
item: item,
|
|
84
|
+
onSelect: onSelect
|
|
85
|
+
}, /*#__PURE__*/React.createElement(ConditionalReverseHighlight, {
|
|
86
|
+
item: item
|
|
87
|
+
}));
|
|
88
|
+
},
|
|
78
89
|
classNames: {
|
|
79
90
|
root: cx('ais-AutocompleteSuggestions', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions$clas = showSuggestions.classNames) === null || _showSuggestions$clas === void 0 ? void 0 : _showSuggestions$clas.root),
|
|
80
91
|
list: cx('ais-AutocompleteSuggestionsList', showSuggestions === null || showSuggestions === void 0 ? void 0 : (_showSuggestions$clas2 = showSuggestions.classNames) === null || _showSuggestions$clas2 === void 0 ? void 0 : _showSuggestions$clas2.list),
|
|
@@ -92,17 +103,18 @@ export function EXPERIMENTAL_Autocomplete(_ref) {
|
|
|
92
103
|
}, [indexRenderState]);
|
|
93
104
|
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Index, {
|
|
94
105
|
EXPERIMENTAL_isolated: true
|
|
95
|
-
},
|
|
106
|
+
}, /*#__PURE__*/React.createElement(Configure, searchParameters), indicesConfig.map(function (index) {
|
|
96
107
|
return /*#__PURE__*/React.createElement(Index, {
|
|
97
108
|
key: index.indexName,
|
|
98
109
|
indexName: index.indexName
|
|
99
|
-
});
|
|
110
|
+
}, /*#__PURE__*/React.createElement(Configure, index.searchParameters));
|
|
100
111
|
}), /*#__PURE__*/React.createElement(InnerAutocomplete, _extends({}, props, {
|
|
101
112
|
indicesConfig: indicesConfig,
|
|
102
113
|
refineSearchBox: refine,
|
|
103
114
|
indexUiState: indexUiState,
|
|
104
115
|
isSearchPage: isSearchPage,
|
|
105
|
-
showRecent: showRecent
|
|
116
|
+
showRecent: showRecent,
|
|
117
|
+
showSuggestions: showSuggestions
|
|
106
118
|
}))));
|
|
107
119
|
}
|
|
108
120
|
function InnerAutocomplete(_ref3) {
|
|
@@ -112,7 +124,10 @@ function InnerAutocomplete(_ref3) {
|
|
|
112
124
|
userOnSelect = _ref3.onSelect,
|
|
113
125
|
indexUiState = _ref3.indexUiState,
|
|
114
126
|
isSearchPage = _ref3.isSearchPage,
|
|
127
|
+
PanelComponent = _ref3.panelComponent,
|
|
115
128
|
showRecent = _ref3.showRecent,
|
|
129
|
+
showSuggestions = _ref3.showSuggestions,
|
|
130
|
+
placeholder = _ref3.placeholder,
|
|
116
131
|
props = _objectWithoutProperties(_ref3, _excluded2);
|
|
117
132
|
var _useAutocomplete = useAutocomplete(),
|
|
118
133
|
indices = _useAutocomplete.indices,
|
|
@@ -151,58 +166,92 @@ function InnerAutocomplete(_ref3) {
|
|
|
151
166
|
return;
|
|
152
167
|
}
|
|
153
168
|
setQuery(query);
|
|
154
|
-
}
|
|
169
|
+
},
|
|
170
|
+
placeholder: placeholder
|
|
155
171
|
}),
|
|
156
172
|
getInputProps = _usePropGetters.getInputProps,
|
|
157
173
|
getItemProps = _usePropGetters.getItemProps,
|
|
158
174
|
getPanelProps = _usePropGetters.getPanelProps,
|
|
159
175
|
getRootProps = _usePropGetters.getRootProps;
|
|
160
176
|
var AutocompleteRecentSearchComponent = _typeof(showRecent) === 'object' && showRecent.itemComponent || AutocompleteRecentSearch;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
}
|
|
177
|
+
var elements = {};
|
|
178
|
+
if (showRecent) {
|
|
179
|
+
elements.recent = /*#__PURE__*/React.createElement(AutocompleteIndex
|
|
180
|
+
// @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
|
|
181
|
+
, {
|
|
182
|
+
ItemComponent: function ItemComponent(_ref5) {
|
|
183
|
+
var item = _ref5.item,
|
|
184
|
+
onSelect = _ref5.onSelect;
|
|
185
|
+
return /*#__PURE__*/React.createElement(AutocompleteRecentSearchComponent, {
|
|
186
|
+
item: item,
|
|
187
|
+
onSelect: onSelect,
|
|
188
|
+
onRemoveRecentSearch: function onRemoveRecentSearch() {
|
|
189
|
+
return storage.onRemove(item.query);
|
|
190
|
+
}
|
|
191
|
+
}, /*#__PURE__*/React.createElement(ConditionalReverseHighlight, {
|
|
192
|
+
item: item
|
|
193
|
+
}));
|
|
194
|
+
},
|
|
195
|
+
classNames: {
|
|
196
|
+
root: 'ais-AutocompleteRecentSearches',
|
|
197
|
+
list: 'ais-AutocompleteRecentSearchesList',
|
|
198
|
+
item: 'ais-AutocompleteRecentSearchesItem'
|
|
199
|
+
},
|
|
200
|
+
items: storageHits,
|
|
201
|
+
getItemProps: getItemProps,
|
|
202
|
+
key: "recentSearches"
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
indices.forEach(function (_ref6, i) {
|
|
189
206
|
var indexId = _ref6.indexId,
|
|
207
|
+
indexName = _ref6.indexName,
|
|
190
208
|
hits = _ref6.hits;
|
|
191
|
-
|
|
209
|
+
var elementId = indexName === (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) ? 'suggestions' : indexName;
|
|
210
|
+
var filteredHits = elementId === 'suggestions' && showRecent ? hits.filter(function (suggestionHit) {
|
|
211
|
+
return !storageHits.find(function (storageHit) {
|
|
212
|
+
return storageHit.query === suggestionHit.query;
|
|
213
|
+
});
|
|
214
|
+
}) : hits;
|
|
215
|
+
elements[elementId] = /*#__PURE__*/React.createElement(AutocompleteIndex, {
|
|
192
216
|
key: indexId
|
|
193
217
|
// @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
|
|
194
218
|
,
|
|
195
|
-
HeaderComponent: indicesConfig[
|
|
219
|
+
HeaderComponent: indicesConfig[i].headerComponent
|
|
196
220
|
// @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
|
|
197
221
|
,
|
|
198
|
-
ItemComponent: indicesConfig[
|
|
199
|
-
items:
|
|
222
|
+
ItemComponent: indicesConfig[i].itemComponent,
|
|
223
|
+
items: filteredHits.map(function (item) {
|
|
200
224
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
201
225
|
__indexName: indexId
|
|
202
226
|
});
|
|
203
227
|
}),
|
|
204
228
|
getItemProps: getItemProps,
|
|
205
|
-
classNames: indicesConfig[
|
|
229
|
+
classNames: indicesConfig[i].classNames
|
|
206
230
|
});
|
|
231
|
+
});
|
|
232
|
+
return /*#__PURE__*/React.createElement(Autocomplete, _extends({}, props, getRootProps()), /*#__PURE__*/React.createElement(AutocompleteSearch, {
|
|
233
|
+
inputProps: getInputProps(),
|
|
234
|
+
clearQuery: function clearQuery() {
|
|
235
|
+
refineSearchBox('');
|
|
236
|
+
refineAutocomplete('');
|
|
237
|
+
}
|
|
238
|
+
}), /*#__PURE__*/React.createElement(AutocompletePanel, getPanelProps(), PanelComponent ? /*#__PURE__*/React.createElement(PanelComponent, {
|
|
239
|
+
elements: elements,
|
|
240
|
+
indices: indices
|
|
241
|
+
}) : Object.keys(elements).map(function (elementId) {
|
|
242
|
+
return elements[elementId];
|
|
207
243
|
})));
|
|
244
|
+
}
|
|
245
|
+
function ConditionalReverseHighlight(_ref7) {
|
|
246
|
+
var _item$_highlightResul;
|
|
247
|
+
var item = _ref7.item;
|
|
248
|
+
if (!((_item$_highlightResul = item._highlightResult) !== null && _item$_highlightResul !== void 0 && _item$_highlightResul.query) ||
|
|
249
|
+
// @ts-expect-error - we should not have matchLevel as arrays here
|
|
250
|
+
item._highlightResult.query.matchLevel === 'none') {
|
|
251
|
+
return item.query;
|
|
252
|
+
}
|
|
253
|
+
return /*#__PURE__*/React.createElement(ReverseHighlight, {
|
|
254
|
+
attribute: "query",
|
|
255
|
+
hit: item
|
|
256
|
+
});
|
|
208
257
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { PartialKeys } from '../types';
|
|
3
|
+
import type { ReverseHighlightProps as ReverseHighlightUiComponentProps } from '../ui/ReverseHighlight';
|
|
4
|
+
import type { BaseHit, Hit } from 'instantsearch.js';
|
|
5
|
+
export type ReverseHighlightProps<THit extends Hit<BaseHit>> = {
|
|
6
|
+
hit: THit;
|
|
7
|
+
attribute: keyof THit | string[];
|
|
8
|
+
} & PartialKeys<Omit<ReverseHighlightUiComponentProps, 'parts'>, 'highlightedTagName' | 'nonHighlightedTagName' | 'separator'>;
|
|
9
|
+
export declare function ReverseHighlight<THit extends Hit<BaseHit>>({ hit, attribute, highlightedTagName, nonHighlightedTagName, separator, ...props }: ReverseHighlightProps<THit>): React.JSX.Element;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
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); }
|
|
2
|
+
var _excluded = ["hit", "attribute", "highlightedTagName", "nonHighlightedTagName", "separator"],
|
|
3
|
+
_excluded2 = ["isHighlighted"];
|
|
4
|
+
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); }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
9
|
+
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); }
|
|
10
|
+
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; }
|
|
11
|
+
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; }
|
|
12
|
+
import { getHighlightedParts, getPropertyByPath, unescape } from "instantsearch.js/es/lib/utils/index.js";
|
|
13
|
+
import React from 'react';
|
|
14
|
+
import { ReverseHighlight as ReverseHighlightUiComponent } from "../ui/ReverseHighlight.js";
|
|
15
|
+
export function ReverseHighlight(_ref) {
|
|
16
|
+
var hit = _ref.hit,
|
|
17
|
+
attribute = _ref.attribute,
|
|
18
|
+
highlightedTagName = _ref.highlightedTagName,
|
|
19
|
+
nonHighlightedTagName = _ref.nonHighlightedTagName,
|
|
20
|
+
separator = _ref.separator,
|
|
21
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
22
|
+
var property = getPropertyByPath(hit._highlightResult, attribute) || [];
|
|
23
|
+
var properties = Array.isArray(property) ? property : [property];
|
|
24
|
+
var parts = properties.map(function (singleValue) {
|
|
25
|
+
return getHighlightedParts(unescape(singleValue.value || '')).map(function (_ref2) {
|
|
26
|
+
var isHighlighted = _ref2.isHighlighted,
|
|
27
|
+
rest = _objectWithoutProperties(_ref2, _excluded2);
|
|
28
|
+
return _objectSpread(_objectSpread({}, rest), {}, {
|
|
29
|
+
isHighlighted: !isHighlighted
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
return /*#__PURE__*/React.createElement(ReverseHighlightUiComponent, _extends({}, props, {
|
|
34
|
+
parts: parts,
|
|
35
|
+
highlightedTagName: highlightedTagName,
|
|
36
|
+
nonHighlightedTagName: nonHighlightedTagName,
|
|
37
|
+
separator: separator
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
@@ -5,7 +5,7 @@ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
6
6
|
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); }
|
|
7
7
|
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); }
|
|
8
|
-
import {
|
|
8
|
+
import { ChevronLeftIcon, ChevronRightIcon, ArrowRightIcon, createButtonComponent } from 'instantsearch-ui-components';
|
|
9
9
|
import React, { createElement } from 'react';
|
|
10
10
|
import { Carousel } from "../../../components/index.js";
|
|
11
11
|
function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
@@ -82,7 +82,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
|
82
82
|
window.location.href = getSearchPageURL(nextUiState);
|
|
83
83
|
},
|
|
84
84
|
className: "ais-ChatToolSearchIndexCarouselHeaderViewAll"
|
|
85
|
-
}, "View all", /*#__PURE__*/React.createElement(
|
|
85
|
+
}, "View all", /*#__PURE__*/React.createElement(ArrowRightIcon, {
|
|
86
86
|
createElement: createElement
|
|
87
87
|
}))), (hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) > 2 && /*#__PURE__*/React.createElement("div", {
|
|
88
88
|
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButtons"
|
|
@@ -93,7 +93,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
|
93
93
|
onClick: scrollLeft,
|
|
94
94
|
disabled: !canScrollLeft,
|
|
95
95
|
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
96
|
-
}, /*#__PURE__*/React.createElement(
|
|
96
|
+
}, /*#__PURE__*/React.createElement(ChevronLeftIcon, {
|
|
97
97
|
createElement: createElement
|
|
98
98
|
})), /*#__PURE__*/React.createElement(Button, {
|
|
99
99
|
variant: "outline",
|
|
@@ -102,7 +102,7 @@ function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
|
102
102
|
onClick: scrollRight,
|
|
103
103
|
disabled: !canScrollRight,
|
|
104
104
|
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
105
|
-
}, /*#__PURE__*/React.createElement(
|
|
105
|
+
}, /*#__PURE__*/React.createElement(ChevronRightIcon, {
|
|
106
106
|
createElement: createElement
|
|
107
107
|
}))));
|
|
108
108
|
}
|
|
@@ -16,6 +16,7 @@ export * from './PoweredBy';
|
|
|
16
16
|
export * from './RangeInput';
|
|
17
17
|
export * from './RefinementList';
|
|
18
18
|
export * from './RelatedProducts';
|
|
19
|
+
export * from './ReverseHighlight';
|
|
19
20
|
export * from './SearchBox';
|
|
20
21
|
export * from './Snippet';
|
|
21
22
|
export * from './SortBy';
|
package/dist/es/widgets/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export * from "./PoweredBy.js";
|
|
|
16
16
|
export * from "./RangeInput.js";
|
|
17
17
|
export * from "./RefinementList.js";
|
|
18
18
|
export * from "./RelatedProducts.js";
|
|
19
|
+
export * from "./ReverseHighlight.js";
|
|
19
20
|
export * from "./SearchBox.js";
|
|
20
21
|
export * from "./Snippet.js";
|
|
21
22
|
export * from "./SortBy.js";
|
|
@@ -19,6 +19,7 @@ export * from './PoweredBy';
|
|
|
19
19
|
export * from './RangeInput';
|
|
20
20
|
export * from './RefinementList';
|
|
21
21
|
export * from './RelatedProducts';
|
|
22
|
+
export * from './ReverseHighlight';
|
|
22
23
|
export * from './SearchBox';
|
|
23
24
|
export * from './Snippet';
|
|
24
25
|
export * from './SortBy';
|
|
@@ -21,6 +21,7 @@ export * from "./PoweredBy.js";
|
|
|
21
21
|
export * from "./RangeInput.js";
|
|
22
22
|
export * from "./RefinementList.js";
|
|
23
23
|
export * from "./RelatedProducts.js";
|
|
24
|
+
export * from "./ReverseHighlight.js";
|
|
24
25
|
export * from "./SearchBox.js";
|
|
25
26
|
export * from "./Snippet.js";
|
|
26
27
|
export * from "./SortBy.js";
|