instantsearch.js 4.85.1 → 4.86.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.
- package/cjs/connectors/chat/connectChat.js +3 -1
- package/cjs/connectors/sort-by/connectSortBy.js +118 -18
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/autocomplete/autocomplete.js +140 -103
- package/dist/instantsearch.development.d.ts +76 -11
- package/dist/instantsearch.development.js +311 -131
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +76 -11
- package/dist/instantsearch.production.min.d.ts +76 -11
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/chat/connectChat.d.ts +2 -150
- package/es/connectors/chat/connectChat.js +3 -1
- package/es/connectors/sort-by/connectSortBy.d.ts +41 -9
- package/es/connectors/sort-by/connectSortBy.js +118 -18
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/widgets/autocomplete/autocomplete.d.ts +9 -0
- package/es/widgets/autocomplete/autocomplete.js +140 -103
- package/es/widgets/chat/chat.d.ts +2 -150
- package/es/widgets/sort-by/sort-by.d.ts +22 -2
- package/package.json +7 -7
|
@@ -1,3 +1,4 @@
|
|
|
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); }
|
|
1
2
|
var _excluded = ["instanceId", "containerNode"];
|
|
2
3
|
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
3
4
|
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."); }
|
|
@@ -5,7 +6,6 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
5
6
|
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
6
7
|
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
7
8
|
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; }
|
|
8
|
-
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); }
|
|
9
9
|
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; }
|
|
10
10
|
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; }
|
|
11
11
|
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; }
|
|
@@ -73,6 +73,7 @@ var createRenderer = function createRenderer(params) {
|
|
|
73
73
|
return function (connectorParams, isFirstRendering) {
|
|
74
74
|
if (isFirstRendering) {
|
|
75
75
|
var _targetIndex$getHelpe, _targetIndex$getHelpe2;
|
|
76
|
+
var showRecentObj = rendererParams.showRecent;
|
|
76
77
|
var isolatedIndex = connectorParams.instantSearchInstance.mainIndex;
|
|
77
78
|
var targetIndex = connectorParams.instantSearchInstance.mainIndex;
|
|
78
79
|
walkIndex(targetIndex, function (childIndex) {
|
|
@@ -81,6 +82,56 @@ var createRenderer = function createRenderer(params) {
|
|
|
81
82
|
targetIndex = childIndex.parent;
|
|
82
83
|
}
|
|
83
84
|
});
|
|
85
|
+
var RecentSearchComponent = function RecentSearchComponent(_ref) {
|
|
86
|
+
var item = _ref.item,
|
|
87
|
+
onSelect = _ref.onSelect,
|
|
88
|
+
onApply = _ref.onApply,
|
|
89
|
+
onRemoveRecentSearch = _ref.onRemoveRecentSearch;
|
|
90
|
+
return h(AutocompleteRecentSearch, {
|
|
91
|
+
item: item,
|
|
92
|
+
onSelect: onSelect,
|
|
93
|
+
onApply: onApply,
|
|
94
|
+
onRemoveRecentSearch: onRemoveRecentSearch
|
|
95
|
+
}, h(ConditionalReverseHighlight, {
|
|
96
|
+
item: item
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
99
|
+
var recentSearchHeaderComponent = undefined;
|
|
100
|
+
if (showRecentObj && showRecentObj.templates) {
|
|
101
|
+
var recentTemplateProps = prepareTemplateProps({
|
|
102
|
+
defaultTemplates: {},
|
|
103
|
+
templatesConfig: connectorParams.instantSearchInstance.templatesConfig,
|
|
104
|
+
templates: showRecentObj.templates
|
|
105
|
+
});
|
|
106
|
+
if (showRecentObj.templates.item) {
|
|
107
|
+
RecentSearchComponent = function RecentSearchComponent(_ref2) {
|
|
108
|
+
var item = _ref2.item,
|
|
109
|
+
onSelect = _ref2.onSelect,
|
|
110
|
+
onRemoveRecentSearch = _ref2.onRemoveRecentSearch;
|
|
111
|
+
return h(TemplateComponent, _extends({}, recentTemplateProps, {
|
|
112
|
+
templateKey: "item",
|
|
113
|
+
rootTagName: "fragment",
|
|
114
|
+
data: {
|
|
115
|
+
item: item,
|
|
116
|
+
onSelect: onSelect,
|
|
117
|
+
onRemoveRecentSearch: onRemoveRecentSearch
|
|
118
|
+
}
|
|
119
|
+
}));
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
if (showRecentObj.templates.header) {
|
|
123
|
+
recentSearchHeaderComponent = function recentSearchHeaderComponent(_ref3) {
|
|
124
|
+
var items = _ref3.items;
|
|
125
|
+
return h(TemplateComponent, _extends({}, recentTemplateProps, {
|
|
126
|
+
templateKey: "header",
|
|
127
|
+
rootTagName: "fragment",
|
|
128
|
+
data: {
|
|
129
|
+
items: items
|
|
130
|
+
}
|
|
131
|
+
}));
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
84
135
|
rendererParams.renderState = {
|
|
85
136
|
indexTemplateProps: [],
|
|
86
137
|
isolatedIndex: isolatedIndex,
|
|
@@ -89,7 +140,9 @@ var createRenderer = function createRenderer(params) {
|
|
|
89
140
|
defaultTemplates: {},
|
|
90
141
|
templatesConfig: connectorParams.instantSearchInstance.templatesConfig,
|
|
91
142
|
templates: rendererParams.templates
|
|
92
|
-
})
|
|
143
|
+
}),
|
|
144
|
+
RecentSearchComponent: RecentSearchComponent,
|
|
145
|
+
recentSearchHeaderComponent: recentSearchHeaderComponent
|
|
93
146
|
};
|
|
94
147
|
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 : '');
|
|
95
148
|
return;
|
|
@@ -97,20 +150,20 @@ var createRenderer = function createRenderer(params) {
|
|
|
97
150
|
render(h(AutocompleteWrapper, _extends({}, rendererParams, connectorParams)), containerNode);
|
|
98
151
|
};
|
|
99
152
|
};
|
|
100
|
-
function AutocompleteWrapper(
|
|
101
|
-
var _isolatedIndex$getHel,
|
|
102
|
-
var indicesConfig =
|
|
103
|
-
indices =
|
|
104
|
-
getSearchPageURL =
|
|
105
|
-
userOnSelect =
|
|
106
|
-
refineAutocomplete =
|
|
107
|
-
cssClasses =
|
|
108
|
-
renderState =
|
|
109
|
-
instantSearchInstance =
|
|
110
|
-
showRecent =
|
|
111
|
-
showSuggestions =
|
|
112
|
-
templates =
|
|
113
|
-
placeholder =
|
|
153
|
+
function AutocompleteWrapper(_ref4) {
|
|
154
|
+
var _isolatedIndex$getHel, _showRecentObj$cssCla, _showRecentObj$cssCla2, _showRecentObj$cssCla3, _showRecentObj$cssCla4, _targetIndex$getWidge;
|
|
155
|
+
var indicesConfig = _ref4.indicesConfig,
|
|
156
|
+
indices = _ref4.indices,
|
|
157
|
+
getSearchPageURL = _ref4.getSearchPageURL,
|
|
158
|
+
userOnSelect = _ref4.onSelect,
|
|
159
|
+
refineAutocomplete = _ref4.refine,
|
|
160
|
+
cssClasses = _ref4.cssClasses,
|
|
161
|
+
renderState = _ref4.renderState,
|
|
162
|
+
instantSearchInstance = _ref4.instantSearchInstance,
|
|
163
|
+
showRecent = _ref4.showRecent,
|
|
164
|
+
showSuggestions = _ref4.showSuggestions,
|
|
165
|
+
templates = _ref4.templates,
|
|
166
|
+
placeholder = _ref4.placeholder;
|
|
114
167
|
var isolatedIndex = renderState.isolatedIndex,
|
|
115
168
|
targetIndex = renderState.targetIndex;
|
|
116
169
|
var searchboxQuery = isolatedIndex === null || isolatedIndex === void 0 ? void 0 : (_isolatedIndex$getHel = isolatedIndex.getHelper()) === null || _isolatedIndex$getHel === void 0 ? void 0 : _isolatedIndex$getHel.state.query;
|
|
@@ -124,8 +177,15 @@ function AutocompleteWrapper(_ref) {
|
|
|
124
177
|
storageHits = _useStorage.storageHits,
|
|
125
178
|
indicesConfigForPropGetters = _useStorage.indicesConfigForPropGetters,
|
|
126
179
|
indicesForPropGetters = _useStorage.indicesForPropGetters;
|
|
127
|
-
var
|
|
128
|
-
|
|
180
|
+
var showRecentObj = showRecent;
|
|
181
|
+
var recentSearchCssClasses = {
|
|
182
|
+
root: cx('ais-AutocompleteRecentSearches', showRecentObj === null || showRecentObj === void 0 ? void 0 : (_showRecentObj$cssCla = showRecentObj.cssClasses) === null || _showRecentObj$cssCla === void 0 ? void 0 : _showRecentObj$cssCla.root),
|
|
183
|
+
list: cx('ais-AutocompleteRecentSearchesList', showRecentObj === null || showRecentObj === void 0 ? void 0 : (_showRecentObj$cssCla2 = showRecentObj.cssClasses) === null || _showRecentObj$cssCla2 === void 0 ? void 0 : _showRecentObj$cssCla2.list),
|
|
184
|
+
header: cx('ais-AutocompleteRecentSearchesHeader', showRecentObj === null || showRecentObj === void 0 ? void 0 : (_showRecentObj$cssCla3 = showRecentObj.cssClasses) === null || _showRecentObj$cssCla3 === void 0 ? void 0 : _showRecentObj$cssCla3.header),
|
|
185
|
+
item: cx('ais-AutocompleteRecentSearchesItem', showRecentObj === null || showRecentObj === void 0 ? void 0 : (_showRecentObj$cssCla4 = showRecentObj.cssClasses) === null || _showRecentObj$cssCla4 === void 0 ? void 0 : _showRecentObj$cssCla4.item)
|
|
186
|
+
};
|
|
187
|
+
var isSearchPage = (_targetIndex$getWidge = targetIndex === null || targetIndex === void 0 ? void 0 : targetIndex.getWidgets().some(function (_ref5) {
|
|
188
|
+
var $$type = _ref5.$$type;
|
|
129
189
|
return ['ais.hits', 'ais.infiniteHits'].includes($$type);
|
|
130
190
|
})) !== null && _targetIndex$getWidge !== void 0 ? _targetIndex$getWidge : false;
|
|
131
191
|
var onRefine = function onRefine(query) {
|
|
@@ -144,10 +204,10 @@ function AutocompleteWrapper(_ref) {
|
|
|
144
204
|
indices: indicesForPropGetters,
|
|
145
205
|
indicesConfig: indicesConfigForPropGetters,
|
|
146
206
|
onRefine: onRefine,
|
|
147
|
-
onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function (
|
|
148
|
-
var query =
|
|
149
|
-
setQuery =
|
|
150
|
-
url =
|
|
207
|
+
onSelect: userOnSelect !== null && userOnSelect !== void 0 ? userOnSelect : function (_ref6) {
|
|
208
|
+
var query = _ref6.query,
|
|
209
|
+
setQuery = _ref6.setQuery,
|
|
210
|
+
url = _ref6.url;
|
|
151
211
|
if (url) {
|
|
152
212
|
window.location.href = url;
|
|
153
213
|
return;
|
|
@@ -161,75 +221,44 @@ function AutocompleteWrapper(_ref) {
|
|
|
161
221
|
}
|
|
162
222
|
setQuery(query);
|
|
163
223
|
},
|
|
224
|
+
onApply: function onApply(query) {
|
|
225
|
+
refineAutocomplete(query);
|
|
226
|
+
},
|
|
164
227
|
placeholder: placeholder
|
|
165
228
|
}),
|
|
166
229
|
getInputProps = _usePropGetters.getInputProps,
|
|
167
230
|
getItemProps = _usePropGetters.getItemProps,
|
|
168
231
|
getPanelProps = _usePropGetters.getPanelProps,
|
|
169
232
|
getRootProps = _usePropGetters.getRootProps;
|
|
170
|
-
var AutocompleteRecentSearchComponent = function AutocompleteRecentSearchComponent(_ref4) {
|
|
171
|
-
var item = _ref4.item,
|
|
172
|
-
onSelect = _ref4.onSelect,
|
|
173
|
-
onRemoveRecentSearch = _ref4.onRemoveRecentSearch;
|
|
174
|
-
return h(AutocompleteRecentSearch, {
|
|
175
|
-
item: item,
|
|
176
|
-
onSelect: onSelect,
|
|
177
|
-
onRemoveRecentSearch: onRemoveRecentSearch
|
|
178
|
-
}, h(ConditionalReverseHighlight, {
|
|
179
|
-
item: item
|
|
180
|
-
}));
|
|
181
|
-
};
|
|
182
|
-
if (_typeof(showRecent) === 'object' && (_showRecent$templates = showRecent.templates) !== null && _showRecent$templates !== void 0 && _showRecent$templates.item) {
|
|
183
|
-
var props = prepareTemplateProps({
|
|
184
|
-
defaultTemplates: {},
|
|
185
|
-
templatesConfig: instantSearchInstance.templatesConfig,
|
|
186
|
-
templates: showRecent.templates
|
|
187
|
-
});
|
|
188
|
-
AutocompleteRecentSearchComponent = function AutocompleteRecentSearchComponent(_ref5) {
|
|
189
|
-
var item = _ref5.item,
|
|
190
|
-
onSelect = _ref5.onSelect,
|
|
191
|
-
onRemoveRecentSearch = _ref5.onRemoveRecentSearch;
|
|
192
|
-
return h(TemplateComponent, _extends({}, props, {
|
|
193
|
-
templateKey: "item",
|
|
194
|
-
rootTagName: "fragment",
|
|
195
|
-
data: {
|
|
196
|
-
item: item,
|
|
197
|
-
onSelect: onSelect,
|
|
198
|
-
onRemoveRecentSearch: onRemoveRecentSearch
|
|
199
|
-
}
|
|
200
|
-
}));
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
233
|
var elements = {};
|
|
204
234
|
if (showRecent) {
|
|
205
|
-
elements.recent = h(AutocompleteIndex
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
235
|
+
elements.recent = h(AutocompleteIndex, {
|
|
236
|
+
HeaderComponent: renderState.recentSearchHeaderComponent
|
|
237
|
+
// @ts-ignore - there seems to be problems with React.ComponentType and this, but it's actually correct
|
|
238
|
+
,
|
|
239
|
+
ItemComponent: function ItemComponent(_ref7) {
|
|
240
|
+
var item = _ref7.item,
|
|
241
|
+
onSelect = _ref7.onSelect,
|
|
242
|
+
onApply = _ref7.onApply;
|
|
243
|
+
return h(renderState.RecentSearchComponent, {
|
|
212
244
|
item: item,
|
|
213
245
|
onSelect: onSelect,
|
|
246
|
+
onApply: onApply,
|
|
214
247
|
onRemoveRecentSearch: function onRemoveRecentSearch() {
|
|
215
248
|
return storage.onRemove(item.query);
|
|
216
249
|
}
|
|
217
250
|
});
|
|
218
251
|
},
|
|
219
|
-
classNames:
|
|
220
|
-
root: 'ais-AutocompleteRecentSearches',
|
|
221
|
-
list: 'ais-AutocompleteRecentSearchesList',
|
|
222
|
-
item: 'ais-AutocompleteRecentSearchesItem'
|
|
223
|
-
},
|
|
252
|
+
classNames: recentSearchCssClasses,
|
|
224
253
|
items: storageHits,
|
|
225
254
|
getItemProps: getItemProps
|
|
226
255
|
});
|
|
227
256
|
}
|
|
228
|
-
indices.forEach(function (
|
|
257
|
+
indices.forEach(function (_ref8, i) {
|
|
229
258
|
var _indicesConfig$i$temp;
|
|
230
|
-
var indexId =
|
|
231
|
-
indexName =
|
|
232
|
-
hits =
|
|
259
|
+
var indexId = _ref8.indexId,
|
|
260
|
+
indexName = _ref8.indexName,
|
|
261
|
+
hits = _ref8.hits;
|
|
233
262
|
if (!renderState.indexTemplateProps[i]) {
|
|
234
263
|
renderState.indexTemplateProps[i] = prepareTemplateProps({
|
|
235
264
|
defaultTemplates: {},
|
|
@@ -237,8 +266,8 @@ function AutocompleteWrapper(_ref) {
|
|
|
237
266
|
templates: indicesConfig[i].templates
|
|
238
267
|
});
|
|
239
268
|
}
|
|
240
|
-
var headerComponent = (_indicesConfig$i$temp = indicesConfig[i].templates) !== null && _indicesConfig$i$temp !== void 0 && _indicesConfig$i$temp.header ? function (
|
|
241
|
-
var items =
|
|
269
|
+
var headerComponent = (_indicesConfig$i$temp = indicesConfig[i].templates) !== null && _indicesConfig$i$temp !== void 0 && _indicesConfig$i$temp.header ? function (_ref9) {
|
|
270
|
+
var items = _ref9.items;
|
|
242
271
|
return h(TemplateComponent, _extends({}, renderState.indexTemplateProps[i], {
|
|
243
272
|
templateKey: "header",
|
|
244
273
|
rootTagName: "fragment",
|
|
@@ -247,15 +276,17 @@ function AutocompleteWrapper(_ref) {
|
|
|
247
276
|
}
|
|
248
277
|
}));
|
|
249
278
|
} : undefined;
|
|
250
|
-
var itemComponent = function itemComponent(
|
|
251
|
-
var item =
|
|
252
|
-
onSelect =
|
|
279
|
+
var itemComponent = function itemComponent(_ref0) {
|
|
280
|
+
var item = _ref0.item,
|
|
281
|
+
onSelect = _ref0.onSelect,
|
|
282
|
+
onApply = _ref0.onApply;
|
|
253
283
|
return h(TemplateComponent, _extends({}, renderState.indexTemplateProps[i], {
|
|
254
284
|
templateKey: "item",
|
|
255
285
|
rootTagName: "fragment",
|
|
256
286
|
data: {
|
|
257
287
|
item: item,
|
|
258
|
-
onSelect: onSelect
|
|
288
|
+
onSelect: onSelect,
|
|
289
|
+
onApply: onApply
|
|
259
290
|
}
|
|
260
291
|
}));
|
|
261
292
|
};
|
|
@@ -303,21 +334,21 @@ function AutocompleteWrapper(_ref) {
|
|
|
303
334
|
})));
|
|
304
335
|
}
|
|
305
336
|
export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
306
|
-
var
|
|
307
|
-
container =
|
|
308
|
-
escapeHTML =
|
|
309
|
-
|
|
310
|
-
indices =
|
|
311
|
-
showSuggestions =
|
|
312
|
-
showRecent =
|
|
313
|
-
userSearchParameters =
|
|
314
|
-
getSearchPageURL =
|
|
315
|
-
onSelect =
|
|
316
|
-
|
|
317
|
-
templates =
|
|
318
|
-
|
|
319
|
-
userCssClasses =
|
|
320
|
-
placeholder =
|
|
337
|
+
var _ref1 = widgetParams || {},
|
|
338
|
+
container = _ref1.container,
|
|
339
|
+
escapeHTML = _ref1.escapeHTML,
|
|
340
|
+
_ref1$indices = _ref1.indices,
|
|
341
|
+
indices = _ref1$indices === void 0 ? [] : _ref1$indices,
|
|
342
|
+
showSuggestions = _ref1.showSuggestions,
|
|
343
|
+
showRecent = _ref1.showRecent,
|
|
344
|
+
userSearchParameters = _ref1.searchParameters,
|
|
345
|
+
getSearchPageURL = _ref1.getSearchPageURL,
|
|
346
|
+
onSelect = _ref1.onSelect,
|
|
347
|
+
_ref1$templates = _ref1.templates,
|
|
348
|
+
templates = _ref1$templates === void 0 ? {} : _ref1$templates,
|
|
349
|
+
_ref1$cssClasses = _ref1.cssClasses,
|
|
350
|
+
userCssClasses = _ref1$cssClasses === void 0 ? {} : _ref1$cssClasses,
|
|
351
|
+
placeholder = _ref1.placeholder;
|
|
321
352
|
if (!container) {
|
|
322
353
|
throw new Error(withUsage('The `container` option is required.'));
|
|
323
354
|
}
|
|
@@ -335,12 +366,14 @@ export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
335
366
|
indexName: showSuggestions.indexName,
|
|
336
367
|
templates: _objectSpread({
|
|
337
368
|
// @ts-expect-error
|
|
338
|
-
item: function item(
|
|
339
|
-
var _item =
|
|
340
|
-
onSelectItem =
|
|
369
|
+
item: function item(_ref10) {
|
|
370
|
+
var _item = _ref10.item,
|
|
371
|
+
onSelectItem = _ref10.onSelect,
|
|
372
|
+
onApply = _ref10.onApply;
|
|
341
373
|
return h(AutocompleteSuggestion, {
|
|
342
374
|
item: _item,
|
|
343
|
-
onSelect: onSelectItem
|
|
375
|
+
onSelect: onSelectItem,
|
|
376
|
+
onApply: onApply
|
|
344
377
|
}, h(ConditionalReverseHighlight, {
|
|
345
378
|
item: _item
|
|
346
379
|
}));
|
|
@@ -359,6 +392,8 @@ export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
359
392
|
});
|
|
360
393
|
}
|
|
361
394
|
var instanceId = ++autocompleteInstanceId;
|
|
395
|
+
var shouldShowRecent = showRecent || undefined;
|
|
396
|
+
var showRecentOptions = typeof shouldShowRecent === 'boolean' ? {} : shouldShowRecent;
|
|
362
397
|
var specializedRenderer = createRenderer({
|
|
363
398
|
instanceId: instanceId,
|
|
364
399
|
containerNode: containerNode,
|
|
@@ -366,14 +401,16 @@ export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
366
401
|
getSearchPageURL: getSearchPageURL,
|
|
367
402
|
onSelect: onSelect,
|
|
368
403
|
cssClasses: cssClasses,
|
|
369
|
-
showRecent:
|
|
404
|
+
showRecent: showRecentOptions,
|
|
370
405
|
showSuggestions: showSuggestions,
|
|
371
406
|
placeholder: placeholder,
|
|
372
407
|
renderState: {
|
|
373
408
|
indexTemplateProps: [],
|
|
374
409
|
isolatedIndex: undefined,
|
|
375
410
|
targetIndex: undefined,
|
|
376
|
-
templateProps: undefined
|
|
411
|
+
templateProps: undefined,
|
|
412
|
+
RecentSearchComponent: AutocompleteRecentSearch,
|
|
413
|
+
recentSearchHeaderComponent: undefined
|
|
377
414
|
},
|
|
378
415
|
templates: templates
|
|
379
416
|
});
|
|
@@ -385,9 +422,9 @@ export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
385
422
|
})({}), index({
|
|
386
423
|
indexId: "ais-autocomplete-".concat(instanceId),
|
|
387
424
|
EXPERIMENTAL_isolated: true
|
|
388
|
-
}).addWidgets([configure(searchParameters)].concat(_toConsumableArray(indicesConfig.map(function (
|
|
389
|
-
var indexName =
|
|
390
|
-
indexSearchParameters =
|
|
425
|
+
}).addWidgets([configure(searchParameters)].concat(_toConsumableArray(indicesConfig.map(function (_ref11) {
|
|
426
|
+
var indexName = _ref11.indexName,
|
|
427
|
+
indexSearchParameters = _ref11.searchParameters;
|
|
391
428
|
return index({
|
|
392
429
|
indexName: indexName,
|
|
393
430
|
indexId: indexName
|
|
@@ -398,9 +435,9 @@ export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
398
435
|
$$widgetType: 'ais.autocomplete'
|
|
399
436
|
})]))];
|
|
400
437
|
}
|
|
401
|
-
function ConditionalReverseHighlight(
|
|
438
|
+
function ConditionalReverseHighlight(_ref12) {
|
|
402
439
|
var _item$_highlightResul;
|
|
403
|
-
var item =
|
|
440
|
+
var item = _ref12.item;
|
|
404
441
|
if (!((_item$_highlightResul = item._highlightResult) !== null && _item$_highlightResul !== void 0 && _item$_highlightResul.query) ||
|
|
405
442
|
// @ts-expect-error - we should not have matchLevel as arrays here
|
|
406
443
|
item._highlightResult.query.matchLevel === 'none') {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import { SearchIndexToolType, RecommendToolType } from '../../lib/chat';
|
|
3
3
|
import type { ChatRenderState, ChatConnectorParams, ChatWidgetDescription } from '../../connectors/chat/connectChat';
|
|
4
|
-
import type { WidgetFactory, Hit, TemplateWithBindEvent, BaseHit, Template, IndexUiState
|
|
4
|
+
import type { WidgetFactory, Hit, TemplateWithBindEvent, BaseHit, Template, IndexUiState } from '../../types';
|
|
5
5
|
import type { ChatClassNames, ChatHeaderProps, ChatMessageActionProps, ChatMessageBase, ChatMessageErrorProps, ChatMessageLoaderProps, ChatPromptProps, ChatToggleButtonProps, ClientSideToolComponentProps, ClientSideTools, RecordWithObjectID, UserClientSideTool } from 'instantsearch-ui-components';
|
|
6
6
|
export { SearchIndexToolType, RecommendToolType };
|
|
7
7
|
export type UserClientSideToolTemplates = Partial<{
|
|
@@ -276,155 +276,7 @@ declare const _default: <THit extends RecordWithObjectID = RecordWithObjectID>(w
|
|
|
276
276
|
voiceSearch?: import("../../types").WidgetRenderState<import("../../connectors/voice-search/connectVoiceSearch").VoiceSearchRenderState, import("../../connectors/voice-search/connectVoiceSearch").VoiceSearchConnectorParams> | undefined;
|
|
277
277
|
analytics?: import("../../types").WidgetRenderState<Record<string, unknown>, import("../analytics/analytics").AnalyticsWidgetParams> | undefined;
|
|
278
278
|
places?: import("../../types").WidgetRenderState<Record<string, unknown>, import("../places/places").PlacesWidgetParams> | undefined;
|
|
279
|
-
}, renderOptions: import("../../types").InitOptions | import("../../types").RenderOptions):
|
|
280
|
-
chat: {
|
|
281
|
-
indexUiState: Partial<{
|
|
282
|
-
query: string;
|
|
283
|
-
} & {
|
|
284
|
-
configure: import("algoliasearch-helper").PlainSearchParameters;
|
|
285
|
-
} & {
|
|
286
|
-
geoSearch: {
|
|
287
|
-
boundingBox: string;
|
|
288
|
-
};
|
|
289
|
-
} & {
|
|
290
|
-
hierarchicalMenu: {
|
|
291
|
-
[rootAttribute: string]: string[];
|
|
292
|
-
};
|
|
293
|
-
} & {
|
|
294
|
-
hitsPerPage: number;
|
|
295
|
-
} & {
|
|
296
|
-
page: number;
|
|
297
|
-
} & {
|
|
298
|
-
menu: {
|
|
299
|
-
[attribute: string]: string;
|
|
300
|
-
};
|
|
301
|
-
} & {
|
|
302
|
-
numericMenu: {
|
|
303
|
-
[attribute: string]: string;
|
|
304
|
-
};
|
|
305
|
-
} & {
|
|
306
|
-
page: number;
|
|
307
|
-
} & {
|
|
308
|
-
range: {
|
|
309
|
-
[attribute: string]: string;
|
|
310
|
-
};
|
|
311
|
-
} & {
|
|
312
|
-
ratingMenu: {
|
|
313
|
-
[attribute: string]: number | undefined;
|
|
314
|
-
};
|
|
315
|
-
} & {
|
|
316
|
-
refinementList: {
|
|
317
|
-
[attribute: string]: string[];
|
|
318
|
-
};
|
|
319
|
-
} & {
|
|
320
|
-
relevantSort: number;
|
|
321
|
-
} & {
|
|
322
|
-
query: string;
|
|
323
|
-
} & {
|
|
324
|
-
sortBy: string;
|
|
325
|
-
} & {
|
|
326
|
-
toggle: {
|
|
327
|
-
[attribute: string]: boolean;
|
|
328
|
-
};
|
|
329
|
-
} & {
|
|
330
|
-
query: string;
|
|
331
|
-
} & {
|
|
332
|
-
places: {
|
|
333
|
-
query: string;
|
|
334
|
-
position: string;
|
|
335
|
-
};
|
|
336
|
-
}>;
|
|
337
|
-
input: string;
|
|
338
|
-
open: boolean;
|
|
339
|
-
sendEvent: import("../../lib/utils").SendEventForHits;
|
|
340
|
-
setIndexUiState: IndexWidget["setIndexUiState"];
|
|
341
|
-
setInput: (input: string) => void;
|
|
342
|
-
setOpen: (open: boolean) => void;
|
|
343
|
-
setMessages: (messages: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[] | ((m: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[]) => import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[])) => void;
|
|
344
|
-
isClearing: boolean;
|
|
345
|
-
clearMessages: () => void;
|
|
346
|
-
onClearTransitionEnd: () => void;
|
|
347
|
-
tools: ClientSideTools;
|
|
348
|
-
readonly id: string;
|
|
349
|
-
readonly error: Error | undefined;
|
|
350
|
-
readonly status: import("ai").ChatStatus;
|
|
351
|
-
addToolResult: <TOOL extends string>({ tool, toolCallId, output, }: {
|
|
352
|
-
tool: TOOL;
|
|
353
|
-
toolCallId: string;
|
|
354
|
-
output: unknown;
|
|
355
|
-
}) => Promise<void>;
|
|
356
|
-
clearError: () => void;
|
|
357
|
-
messages: import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>[];
|
|
358
|
-
regenerate: ({ messageId, ...options }?: {
|
|
359
|
-
messageId?: string;
|
|
360
|
-
} & import("ai").ChatRequestOptions) => Promise<void>;
|
|
361
|
-
resumeStream: (options?: import("ai").ChatRequestOptions) => Promise<void>;
|
|
362
|
-
sendMessage: (message?: (Omit<import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>, "id" | "role"> & {
|
|
363
|
-
id?: string | undefined;
|
|
364
|
-
role?: "system" | "user" | "assistant" | undefined;
|
|
365
|
-
} & {
|
|
366
|
-
text?: never;
|
|
367
|
-
files?: never;
|
|
368
|
-
messageId?: string;
|
|
369
|
-
}) | {
|
|
370
|
-
text: string;
|
|
371
|
-
files?: FileList | import("ai").FileUIPart[];
|
|
372
|
-
metadata?: unknown;
|
|
373
|
-
parts?: never;
|
|
374
|
-
messageId?: string;
|
|
375
|
-
} | {
|
|
376
|
-
files: FileList | import("ai").FileUIPart[];
|
|
377
|
-
metadata?: unknown;
|
|
378
|
-
parts?: never;
|
|
379
|
-
messageId?: string;
|
|
380
|
-
} | undefined, options?: import("ai").ChatRequestOptions) => Promise<void>;
|
|
381
|
-
stop: () => Promise<void>;
|
|
382
|
-
widgetParams: ChatConnectorParams<import("ai").UIMessage<unknown, import("ai").UIDataTypes, import("ai").UITools>> & TWidgetParams;
|
|
383
|
-
};
|
|
384
|
-
answers?: import("../../types").WidgetRenderState<import("../../connectors/answers/connectAnswers").AnswersRenderState, import("../../connectors/answers/connectAnswers").AnswersConnectorParams> | undefined;
|
|
385
|
-
autocomplete?: import("../../types").WidgetRenderState<import("../../connectors/autocomplete/connectAutocomplete").AutocompleteRenderState, import("../../connectors/autocomplete/connectAutocomplete").AutocompleteConnectorParams> | undefined;
|
|
386
|
-
breadcrumb?: {
|
|
387
|
-
[rootAttribute: string]: import("../../types").WidgetRenderState<import("../../connectors/breadcrumb/connectBreadcrumb").BreadcrumbRenderState, import("../../connectors/breadcrumb/connectBreadcrumb").BreadcrumbConnectorParams>;
|
|
388
|
-
} | undefined;
|
|
389
|
-
clearRefinements?: import("../../types").WidgetRenderState<import("../../connectors/clear-refinements/connectClearRefinements").ClearRefinementsRenderState, import("../../connectors/clear-refinements/connectClearRefinements").ClearRefinementsConnectorParams> | undefined;
|
|
390
|
-
configure?: import("../../types").WidgetRenderState<import("../../connectors/configure/connectConfigure").ConfigureRenderState, import("../../connectors/configure/connectConfigure").ConfigureConnectorParams> | undefined;
|
|
391
|
-
currentRefinements?: import("../../types").WidgetRenderState<import("../../connectors/current-refinements/connectCurrentRefinements").CurrentRefinementsRenderState, import("../../connectors/current-refinements/connectCurrentRefinements").CurrentRefinementsConnectorParams> | undefined;
|
|
392
|
-
geoSearch?: import("../../types").WidgetRenderState<import("../../connectors/geo-search/connectGeoSearch").GeoSearchRenderState<import("../../types").GeoHit>, import("../../connectors/geo-search/connectGeoSearch").GeoSearchConnectorParams<import("../../types").GeoHit>> | undefined;
|
|
393
|
-
hierarchicalMenu?: {
|
|
394
|
-
[rootAttribute: string]: import("../../types").WidgetRenderState<import("../../connectors/hierarchical-menu/connectHierarchicalMenu").HierarchicalMenuRenderState, import("../../connectors/hierarchical-menu/connectHierarchicalMenu").HierarchicalMenuConnectorParams>;
|
|
395
|
-
} | undefined;
|
|
396
|
-
hits?: import("../../types").WidgetRenderState<import("../../connectors/hits/connectHits").HitsRenderState<BaseHit>, import("../../connectors/hits/connectHits").HitsConnectorParams<BaseHit>> | undefined;
|
|
397
|
-
hitsPerPage?: import("../../types").WidgetRenderState<import("../../connectors/hits-per-page/connectHitsPerPage").HitsPerPageRenderState, import("../../connectors/hits-per-page/connectHitsPerPage").HitsPerPageConnectorParams> | undefined;
|
|
398
|
-
infiniteHits?: import("../../types").WidgetRenderState<import("../../connectors/infinite-hits/connectInfiniteHits").InfiniteHitsRenderState<BaseHit>, import("../../connectors/infinite-hits/connectInfiniteHits").InfiniteHitsConnectorParams<BaseHit>> | undefined;
|
|
399
|
-
menu?: {
|
|
400
|
-
[attribute: string]: import("../../types").WidgetRenderState<import("../../connectors/menu/connectMenu").MenuRenderState, import("../../connectors/menu/connectMenu").MenuConnectorParams>;
|
|
401
|
-
} | undefined;
|
|
402
|
-
numericMenu?: {
|
|
403
|
-
[attribute: string]: import("../../types").WidgetRenderState<import("../../connectors/numeric-menu/connectNumericMenu").NumericMenuRenderState, import("../../connectors/numeric-menu/connectNumericMenu").NumericMenuConnectorParams>;
|
|
404
|
-
} | undefined;
|
|
405
|
-
pagination?: import("../../types").WidgetRenderState<import("../../connectors/pagination/connectPagination").PaginationRenderState, import("../../connectors/pagination/connectPagination").PaginationConnectorParams> | undefined;
|
|
406
|
-
poweredBy?: import("../../types").WidgetRenderState<import("../../connectors/powered-by/connectPoweredBy").PoweredByRenderState, import("../../connectors/powered-by/connectPoweredBy").PoweredByConnectorParams> | undefined;
|
|
407
|
-
queryRules?: import("../../types").WidgetRenderState<import("../../connectors/query-rules/connectQueryRules").QueryRulesRenderState, import("../../connectors/query-rules/connectQueryRules").QueryRulesConnectorParams> | undefined;
|
|
408
|
-
range?: {
|
|
409
|
-
[attribute: string]: import("../../types").WidgetRenderState<import("../../connectors/range/connectRange").RangeRenderState, import("../../connectors/range/connectRange").RangeConnectorParams>;
|
|
410
|
-
} | undefined;
|
|
411
|
-
ratingMenu?: {
|
|
412
|
-
[attribute: string]: import("../../types").WidgetRenderState<import("../../connectors/rating-menu/connectRatingMenu").RatingMenuRenderState, import("../../connectors/rating-menu/connectRatingMenu").RatingMenuConnectorParams>;
|
|
413
|
-
} | undefined;
|
|
414
|
-
refinementList?: {
|
|
415
|
-
[attribute: string]: import("../../types").WidgetRenderState<import("../../connectors/refinement-list/connectRefinementList").RefinementListRenderState, import("../../connectors/refinement-list/connectRefinementList").RefinementListConnectorParams>;
|
|
416
|
-
} | undefined;
|
|
417
|
-
relevantSort?: import("../../types").WidgetRenderState<import("../../connectors/relevant-sort/connectRelevantSort").RelevantSortRenderState, import("../../connectors/relevant-sort/connectRelevantSort").RelevantSortConnectorParams> | undefined;
|
|
418
|
-
searchBox?: import("../../types").WidgetRenderState<import("../../connectors/search-box/connectSearchBox").SearchBoxRenderState, import("../../connectors/search-box/connectSearchBox").SearchBoxConnectorParams> | undefined;
|
|
419
|
-
sortBy?: import("../../types").WidgetRenderState<import("../../connectors/sort-by/connectSortBy").SortByRenderState, import("../../connectors/sort-by/connectSortBy").SortByConnectorParams> | undefined;
|
|
420
|
-
stats?: import("../../types").WidgetRenderState<import("../../connectors/stats/connectStats").StatsRenderState, import("../../connectors/stats/connectStats").StatsConnectorParams> | undefined;
|
|
421
|
-
toggleRefinement?: {
|
|
422
|
-
[attribute: string]: import("../../types").WidgetRenderState<import("../../connectors/toggle-refinement/connectToggleRefinement").ToggleRefinementRenderState, import("../../connectors/toggle-refinement/connectToggleRefinement").ToggleRefinementConnectorParams>;
|
|
423
|
-
} | undefined;
|
|
424
|
-
voiceSearch?: import("../../types").WidgetRenderState<import("../../connectors/voice-search/connectVoiceSearch").VoiceSearchRenderState, import("../../connectors/voice-search/connectVoiceSearch").VoiceSearchConnectorParams> | undefined;
|
|
425
|
-
analytics?: import("../../types").WidgetRenderState<Record<string, unknown>, import("../analytics/analytics").AnalyticsWidgetParams> | undefined;
|
|
426
|
-
places?: import("../../types").WidgetRenderState<Record<string, unknown>, import("../places/places").PlacesWidgetParams> | undefined;
|
|
427
|
-
};
|
|
279
|
+
}, renderOptions: import("../../types").InitOptions | import("../../types").RenderOptions): import("../../types").IndexRenderState & ChatWidgetDescription["indexRenderState"];
|
|
428
280
|
getWidgetRenderState(renderOptions: import("../../types").InitOptions | import("../../types").RenderOptions): {
|
|
429
281
|
indexUiState: Partial<{
|
|
430
282
|
query: string;
|
|
@@ -24,16 +24,36 @@ export type SortByIndexDefinition = {
|
|
|
24
24
|
* The label of the index to display.
|
|
25
25
|
*/
|
|
26
26
|
label: string;
|
|
27
|
+
/**
|
|
28
|
+
* Ensures mutual exclusivity with strategy.
|
|
29
|
+
*/
|
|
30
|
+
strategy?: never;
|
|
31
|
+
};
|
|
32
|
+
export type SortByStrategyDefinition = {
|
|
33
|
+
/**
|
|
34
|
+
* The name of the sorting strategy to use.
|
|
35
|
+
* Only available in composition mode.
|
|
36
|
+
*/
|
|
37
|
+
strategy: string;
|
|
38
|
+
/**
|
|
39
|
+
* The label of the strategy to display.
|
|
40
|
+
*/
|
|
41
|
+
label: string;
|
|
42
|
+
/**
|
|
43
|
+
* Ensures mutual exclusivity with value.
|
|
44
|
+
*/
|
|
45
|
+
value?: never;
|
|
27
46
|
};
|
|
47
|
+
export type SortByDefinition = SortByIndexDefinition | SortByStrategyDefinition;
|
|
28
48
|
export type SortByWidgetParams = {
|
|
29
49
|
/**
|
|
30
50
|
* CSS Selector or HTMLElement to insert the widget.
|
|
31
51
|
*/
|
|
32
52
|
container: string | HTMLElement;
|
|
33
53
|
/**
|
|
34
|
-
* Array of objects defining the different indices to choose from.
|
|
54
|
+
* Array of objects defining the different indices or strategies to choose from.
|
|
35
55
|
*/
|
|
36
|
-
items:
|
|
56
|
+
items: SortByDefinition[];
|
|
37
57
|
/**
|
|
38
58
|
* CSS classes to be added.
|
|
39
59
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.86.0",
|
|
4
4
|
"description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
|
|
5
5
|
"homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
|
|
6
6
|
"types": "es/index.d.ts",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"@types/hogan.js": "^3.0.0",
|
|
33
33
|
"@types/qs": "^6.5.3",
|
|
34
34
|
"ai": "^5.0.18",
|
|
35
|
-
"algoliasearch-helper": "3.
|
|
35
|
+
"algoliasearch-helper": "3.27.0",
|
|
36
36
|
"hogan.js": "^3.0.2",
|
|
37
37
|
"htm": "^3.0.0",
|
|
38
|
-
"instantsearch-ui-components": "0.
|
|
38
|
+
"instantsearch-ui-components": "0.16.0",
|
|
39
39
|
"preact": "^10.10.0",
|
|
40
40
|
"qs": "^6.5.1 < 6.10",
|
|
41
41
|
"react": ">= 0.14.0",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"watch:es": "yarn --silent build:es:base --watch"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@instantsearch/mocks": "1.
|
|
64
|
-
"@instantsearch/tests": "1.
|
|
65
|
-
"@instantsearch/testutils": "1.
|
|
63
|
+
"@instantsearch/mocks": "1.86.0",
|
|
64
|
+
"@instantsearch/tests": "1.86.0",
|
|
65
|
+
"@instantsearch/testutils": "1.75.0",
|
|
66
66
|
"@storybook/html": "5.3.9",
|
|
67
67
|
"@types/scriptjs": "0.0.2",
|
|
68
68
|
"algoliasearch": "5.1.1",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
"scriptjs": "2.5.9",
|
|
71
71
|
"webpack": "4.47.0"
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "13c7c916b870f34f5f6dde9bd7b16850990dc7ea"
|
|
74
74
|
}
|