instantsearch.js 4.84.0 → 4.85.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/cjs/connectors/chat/connectChat.js +12 -9
- package/cjs/lib/utils/getAlgoliaAgent.js +10 -0
- package/cjs/lib/utils/index.js +11 -0
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createMetadataMiddleware.js +1 -2
- package/cjs/widgets/autocomplete/autocomplete.js +18 -9
- package/cjs/widgets/chat/chat.js +3 -3
- package/dist/instantsearch.development.d.ts +109 -30
- package/dist/instantsearch.development.js +72 -57
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +109 -30
- package/dist/instantsearch.production.min.d.ts +109 -30
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/chat/connectChat.d.ts +165 -60
- package/es/connectors/chat/connectChat.js +13 -10
- package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.d.ts +2 -2
- package/es/connectors/geo-search/connectGeoSearch.d.ts +1 -1
- package/es/connectors/hits/connectHits.d.ts +1 -1
- package/es/connectors/hits/connectHitsWithInsights.d.ts +1 -1
- package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +1 -1
- package/es/connectors/infinite-hits/connectInfiniteHitsWithInsights.d.ts +1 -1
- package/es/connectors/looking-similar/connectLookingSimilar.d.ts +2 -2
- package/es/connectors/related-products/connectRelatedProducts.d.ts +2 -2
- package/es/connectors/trending-items/connectTrendingItems.d.ts +2 -2
- package/es/lib/utils/getAlgoliaAgent.d.ts +1 -0
- package/es/lib/utils/getAlgoliaAgent.js +4 -0
- package/es/lib/utils/index.d.ts +1 -0
- package/es/lib/utils/index.js +1 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createMetadataMiddleware.js +2 -3
- package/es/widgets/autocomplete/autocomplete.d.ts +4 -0
- package/es/widgets/autocomplete/autocomplete.js +19 -10
- package/es/widgets/chat/chat.d.ts +109 -6
- package/es/widgets/chat/chat.js +4 -4
- package/es/widgets/frequently-bought-together/frequently-bought-together.d.ts +5 -3
- package/es/widgets/geo-search/geo-search.d.ts +1 -1
- package/es/widgets/hits/hits.d.ts +1 -1
- package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -1
- package/es/widgets/looking-similar/looking-similar.d.ts +5 -3
- package/es/widgets/related-products/related-products.d.ts +5 -3
- package/es/widgets/trending-items/trending-items.d.ts +5 -3
- package/package.json +6 -6
|
@@ -80,7 +80,8 @@ var connectChat = exports.default = function connectChat(renderFn) {
|
|
|
80
80
|
api: "https://".concat(appId, ".algolia.net/agent-studio/1/agents/").concat(agentId, "/completions?compatibilityMode=ai-sdk-5"),
|
|
81
81
|
headers: {
|
|
82
82
|
'x-algolia-application-id': appId,
|
|
83
|
-
'x-algolia-api-Key': apiKey
|
|
83
|
+
'x-algolia-api-Key': apiKey,
|
|
84
|
+
'x-algolia-agent': (0, _utils.getAlgoliaAgent)(instantSearchInstance.client)
|
|
84
85
|
}
|
|
85
86
|
});
|
|
86
87
|
}
|
|
@@ -161,22 +162,24 @@ var connectChat = exports.default = function connectChat(renderFn) {
|
|
|
161
162
|
instantSearchInstance: renderOptions.instantSearchInstance
|
|
162
163
|
}), false);
|
|
163
164
|
},
|
|
164
|
-
getRenderState: function getRenderState(renderState) {
|
|
165
|
-
return renderState
|
|
165
|
+
getRenderState: function getRenderState(renderState, renderOptions) {
|
|
166
|
+
return _objectSpread(_objectSpread({}, renderState), {}, {
|
|
167
|
+
chat: this.getWidgetRenderState(renderOptions)
|
|
168
|
+
});
|
|
166
169
|
},
|
|
167
|
-
getWidgetRenderState: function getWidgetRenderState(
|
|
168
|
-
var instantSearchInstance =
|
|
169
|
-
parent =
|
|
170
|
+
getWidgetRenderState: function getWidgetRenderState(renderOptions) {
|
|
171
|
+
var instantSearchInstance = renderOptions.instantSearchInstance,
|
|
172
|
+
parent = renderOptions.parent;
|
|
170
173
|
if (!_chatInstance) {
|
|
171
|
-
this.init(_objectSpread(_objectSpread({},
|
|
174
|
+
this.init(_objectSpread(_objectSpread({}, renderOptions), {}, {
|
|
172
175
|
uiState: {},
|
|
173
176
|
results: undefined
|
|
174
177
|
}));
|
|
175
178
|
}
|
|
176
179
|
if (!sendEvent) {
|
|
177
180
|
sendEvent = (0, _utils.createSendEventForHits)({
|
|
178
|
-
instantSearchInstance:
|
|
179
|
-
helper:
|
|
181
|
+
instantSearchInstance: renderOptions.instantSearchInstance,
|
|
182
|
+
helper: renderOptions.helper,
|
|
180
183
|
widgetType: this.$$type
|
|
181
184
|
});
|
|
182
185
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getAlgoliaAgent = getAlgoliaAgent;
|
|
7
|
+
function getAlgoliaAgent(client) {
|
|
8
|
+
var clientTyped = client;
|
|
9
|
+
return clientTyped.transporter && clientTyped.transporter.userAgent ? clientTyped.transporter.userAgent.value : clientTyped._ua;
|
|
10
|
+
}
|
package/cjs/lib/utils/index.js
CHANGED
|
@@ -223,6 +223,17 @@ Object.keys(_geoSearch).forEach(function (key) {
|
|
|
223
223
|
}
|
|
224
224
|
});
|
|
225
225
|
});
|
|
226
|
+
var _getAlgoliaAgent = require("./getAlgoliaAgent");
|
|
227
|
+
Object.keys(_getAlgoliaAgent).forEach(function (key) {
|
|
228
|
+
if (key === "default" || key === "__esModule") return;
|
|
229
|
+
if (key in exports && exports[key] === _getAlgoliaAgent[key]) return;
|
|
230
|
+
Object.defineProperty(exports, key, {
|
|
231
|
+
enumerable: true,
|
|
232
|
+
get: function get() {
|
|
233
|
+
return _getAlgoliaAgent[key];
|
|
234
|
+
}
|
|
235
|
+
});
|
|
236
|
+
});
|
|
226
237
|
var _getAppIdAndApiKey = require("./getAppIdAndApiKey");
|
|
227
238
|
Object.keys(_getAppIdAndApiKey).forEach(function (key) {
|
|
228
239
|
if (key === "default" || key === "__esModule") return;
|
package/cjs/lib/version.js
CHANGED
|
@@ -70,8 +70,7 @@ function createMetadataMiddleware() {
|
|
|
70
70
|
subscribe: function subscribe() {
|
|
71
71
|
// using setTimeout here to delay extraction until widgets have been added in a tick (e.g. Vue)
|
|
72
72
|
setTimeout(function () {
|
|
73
|
-
|
|
74
|
-
payload.ua = client.transporter && client.transporter.userAgent ? client.transporter.userAgent.value : client._ua;
|
|
73
|
+
payload.ua = (0, _utils.getAlgoliaAgent)(instantSearchInstance.client);
|
|
75
74
|
extractWidgetPayload(instantSearchInstance.mainIndex.getWidgets(), instantSearchInstance, payload);
|
|
76
75
|
instantSearchInstance.middleware.forEach(function (middleware) {
|
|
77
76
|
return payload.widgets.push({
|
|
@@ -110,13 +110,14 @@ function AutocompleteWrapper(_ref) {
|
|
|
110
110
|
indices = _ref.indices,
|
|
111
111
|
getSearchPageURL = _ref.getSearchPageURL,
|
|
112
112
|
userOnSelect = _ref.onSelect,
|
|
113
|
-
|
|
113
|
+
refineAutocomplete = _ref.refine,
|
|
114
114
|
cssClasses = _ref.cssClasses,
|
|
115
115
|
renderState = _ref.renderState,
|
|
116
116
|
instantSearchInstance = _ref.instantSearchInstance,
|
|
117
117
|
showRecent = _ref.showRecent,
|
|
118
118
|
showSuggestions = _ref.showSuggestions,
|
|
119
|
-
templates = _ref.templates
|
|
119
|
+
templates = _ref.templates,
|
|
120
|
+
placeholder = _ref.placeholder;
|
|
120
121
|
var isolatedIndex = renderState.isolatedIndex,
|
|
121
122
|
targetIndex = renderState.targetIndex;
|
|
122
123
|
var searchboxQuery = isolatedIndex === null || isolatedIndex === void 0 ? void 0 : (_isolatedIndex$getHel = isolatedIndex.getHelper()) === null || _isolatedIndex$getHel === void 0 ? void 0 : _isolatedIndex$getHel.state.query;
|
|
@@ -135,6 +136,7 @@ function AutocompleteWrapper(_ref) {
|
|
|
135
136
|
return ['ais.hits', 'ais.infiniteHits'].includes($$type);
|
|
136
137
|
})) !== null && _targetIndex$getWidge !== void 0 ? _targetIndex$getWidge : false;
|
|
137
138
|
var onRefine = function onRefine(query) {
|
|
139
|
+
refineAutocomplete(query);
|
|
138
140
|
instantSearchInstance.setUiState(function (uiState) {
|
|
139
141
|
var _objectSpread2;
|
|
140
142
|
return _objectSpread(_objectSpread({}, uiState), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, targetIndex.getIndexId(), _objectSpread(_objectSpread({}, uiState[targetIndex.getIndexId()]), {}, {
|
|
@@ -165,7 +167,8 @@ function AutocompleteWrapper(_ref) {
|
|
|
165
167
|
return;
|
|
166
168
|
}
|
|
167
169
|
setQuery(query);
|
|
168
|
-
}
|
|
170
|
+
},
|
|
171
|
+
placeholder: placeholder
|
|
169
172
|
}),
|
|
170
173
|
getInputProps = _usePropGetters.getInputProps,
|
|
171
174
|
getItemProps = _usePropGetters.getItemProps,
|
|
@@ -264,11 +267,16 @@ function AutocompleteWrapper(_ref) {
|
|
|
264
267
|
}));
|
|
265
268
|
};
|
|
266
269
|
var elementId = indexName === (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) ? 'suggestions' : indexName;
|
|
270
|
+
var filteredHits = elementId === 'suggestions' && showRecent ? hits.filter(function (suggestionHit) {
|
|
271
|
+
return !(0, _utils.find)(storageHits, function (storageHit) {
|
|
272
|
+
return storageHit.query === suggestionHit.query;
|
|
273
|
+
});
|
|
274
|
+
}) : hits;
|
|
267
275
|
elements[elementId] = (0, _preact.h)(AutocompleteIndex, {
|
|
268
276
|
key: indexId,
|
|
269
277
|
HeaderComponent: headerComponent,
|
|
270
278
|
ItemComponent: itemComponent,
|
|
271
|
-
items:
|
|
279
|
+
items: filteredHits.map(function (item) {
|
|
272
280
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
273
281
|
__indexName: indexId
|
|
274
282
|
});
|
|
@@ -282,13 +290,12 @@ function AutocompleteWrapper(_ref) {
|
|
|
282
290
|
}), (0, _preact.h)(AutocompleteSearchBox, {
|
|
283
291
|
query: searchboxQuery || '',
|
|
284
292
|
inputProps: _objectSpread(_objectSpread({}, getInputProps()), {}, {
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
return refine(evt.currentTarget.value);
|
|
293
|
+
onInput: function onInput(event) {
|
|
294
|
+
return refineAutocomplete(event.currentTarget.value);
|
|
288
295
|
}
|
|
289
296
|
}),
|
|
290
297
|
onClear: function onClear() {
|
|
291
|
-
|
|
298
|
+
onRefine('');
|
|
292
299
|
},
|
|
293
300
|
isSearchStalled: instantSearchInstance.status === 'stalled'
|
|
294
301
|
}), (0, _preact.h)(AutocompletePanel, getPanelProps(), templates.panel ? (0, _preact.h)(_Template.default, _extends({}, renderState.templateProps, {
|
|
@@ -316,7 +323,8 @@ function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
316
323
|
_ref0$templates = _ref0.templates,
|
|
317
324
|
templates = _ref0$templates === void 0 ? {} : _ref0$templates,
|
|
318
325
|
_ref0$cssClasses = _ref0.cssClasses,
|
|
319
|
-
userCssClasses = _ref0$cssClasses === void 0 ? {} : _ref0$cssClasses
|
|
326
|
+
userCssClasses = _ref0$cssClasses === void 0 ? {} : _ref0$cssClasses,
|
|
327
|
+
placeholder = _ref0.placeholder;
|
|
320
328
|
if (!container) {
|
|
321
329
|
throw new Error(withUsage('The `container` option is required.'));
|
|
322
330
|
}
|
|
@@ -367,6 +375,7 @@ function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
367
375
|
cssClasses: cssClasses,
|
|
368
376
|
showRecent: showRecent,
|
|
369
377
|
showSuggestions: showSuggestions,
|
|
378
|
+
placeholder: placeholder,
|
|
370
379
|
renderState: {
|
|
371
380
|
indexTemplateProps: [],
|
|
372
381
|
isolatedIndex: undefined,
|
package/cjs/widgets/chat/chat.js
CHANGED
|
@@ -57,13 +57,13 @@ function getDefinedProperties(obj) {
|
|
|
57
57
|
return value !== undefined;
|
|
58
58
|
}));
|
|
59
59
|
}
|
|
60
|
-
var _ref6 = (0, _preact.h)(_instantsearchUiComponents.
|
|
60
|
+
var _ref6 = (0, _preact.h)(_instantsearchUiComponents.ArrowRightIcon, {
|
|
61
61
|
createElement: _preact.h
|
|
62
62
|
});
|
|
63
|
-
var _ref7 = (0, _preact.h)(_instantsearchUiComponents.
|
|
63
|
+
var _ref7 = (0, _preact.h)(_instantsearchUiComponents.ChevronLeftIcon, {
|
|
64
64
|
createElement: _preact.h
|
|
65
65
|
});
|
|
66
|
-
var _ref8 = (0, _preact.h)(_instantsearchUiComponents.
|
|
66
|
+
var _ref8 = (0, _preact.h)(_instantsearchUiComponents.ChevronRightIcon, {
|
|
67
67
|
createElement: _preact.h
|
|
68
68
|
});
|
|
69
69
|
function createCarouselTool(showViewAll, templates, getSearchPageURL) {
|