instantsearch.js 4.84.0 → 4.85.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 +2 -1
- 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 +17 -7
- package/cjs/widgets/chat/chat.js +3 -3
- package/dist/instantsearch.development.d.ts +4 -0
- package/dist/instantsearch.development.js +54 -38
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +4 -0
- package/dist/instantsearch.production.min.d.ts +4 -0
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/chat/connectChat.js +3 -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 +18 -8
- package/es/widgets/chat/chat.js +4 -4
- package/package.json +6 -6
|
@@ -15,7 +15,7 @@ function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i
|
|
|
15
15
|
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; }
|
|
16
16
|
import { DefaultChatTransport, lastAssistantMessageIsCompleteWithToolCalls } from 'ai';
|
|
17
17
|
import { Chat } from "../../lib/chat/index.js";
|
|
18
|
-
import { checkRendering, createDocumentationMessageGenerator, createSendEventForHits, getAppIdAndApiKey, noop, warning } from "../../lib/utils/index.js";
|
|
18
|
+
import { checkRendering, createDocumentationMessageGenerator, createSendEventForHits, getAlgoliaAgent, getAppIdAndApiKey, noop, warning } from "../../lib/utils/index.js";
|
|
19
19
|
var withUsage = createDocumentationMessageGenerator({
|
|
20
20
|
name: 'chat',
|
|
21
21
|
connector: true
|
|
@@ -74,7 +74,8 @@ export default (function connectChat(renderFn) {
|
|
|
74
74
|
api: "https://".concat(appId, ".algolia.net/agent-studio/1/agents/").concat(agentId, "/completions?compatibilityMode=ai-sdk-5"),
|
|
75
75
|
headers: {
|
|
76
76
|
'x-algolia-application-id': appId,
|
|
77
|
-
'x-algolia-api-Key': apiKey
|
|
77
|
+
'x-algolia-api-Key': apiKey,
|
|
78
|
+
'x-algolia-agent': getAlgoliaAgent(instantSearchInstance.client)
|
|
78
79
|
}
|
|
79
80
|
});
|
|
80
81
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getAlgoliaAgent(client: unknown): string;
|
package/es/lib/utils/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export * from './escapeFacetValue';
|
|
|
18
18
|
export * from './find';
|
|
19
19
|
export * from './findIndex';
|
|
20
20
|
export * from './geo-search';
|
|
21
|
+
export * from './getAlgoliaAgent';
|
|
21
22
|
export * from './getAppIdAndApiKey';
|
|
22
23
|
export * from './getContainerNode';
|
|
23
24
|
export * from './getHighlightedParts';
|
package/es/lib/utils/index.js
CHANGED
|
@@ -18,6 +18,7 @@ export * from "./escapeFacetValue.js";
|
|
|
18
18
|
export * from "./find.js";
|
|
19
19
|
export * from "./findIndex.js";
|
|
20
20
|
export * from "./geo-search.js";
|
|
21
|
+
export * from "./getAlgoliaAgent.js";
|
|
21
22
|
export * from "./getAppIdAndApiKey.js";
|
|
22
23
|
export * from "./getContainerNode.js";
|
|
23
24
|
export * from "./getHighlightedParts.js";
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.85.0";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.85.0';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createInitArgs, safelyRunOnBrowser } from "../lib/utils/index.js";
|
|
1
|
+
import { createInitArgs, getAlgoliaAgent, safelyRunOnBrowser } from "../lib/utils/index.js";
|
|
2
2
|
function extractWidgetPayload(widgets, instantSearchInstance, payload) {
|
|
3
3
|
var initOptions = createInitArgs(instantSearchInstance, instantSearchInstance.mainIndex, instantSearchInstance._initialUiState);
|
|
4
4
|
widgets.forEach(function (widget) {
|
|
@@ -63,8 +63,7 @@ export function createMetadataMiddleware() {
|
|
|
63
63
|
subscribe: function subscribe() {
|
|
64
64
|
// using setTimeout here to delay extraction until widgets have been added in a tick (e.g. Vue)
|
|
65
65
|
setTimeout(function () {
|
|
66
|
-
|
|
67
|
-
payload.ua = client.transporter && client.transporter.userAgent ? client.transporter.userAgent.value : client._ua;
|
|
66
|
+
payload.ua = getAlgoliaAgent(instantSearchInstance.client);
|
|
68
67
|
extractWidgetPayload(instantSearchInstance.mainIndex.getWidgets(), instantSearchInstance, payload);
|
|
69
68
|
instantSearchInstance.middleware.forEach(function (middleware) {
|
|
70
69
|
return payload.widgets.push({
|
|
@@ -84,6 +84,10 @@ type AutocompleteWidgetParams<TItem extends BaseHit> = {
|
|
|
84
84
|
* CSS classes to add.
|
|
85
85
|
*/
|
|
86
86
|
cssClasses?: AutocompleteCSSClasses;
|
|
87
|
+
/**
|
|
88
|
+
* Placeholder text for the search input.
|
|
89
|
+
*/
|
|
90
|
+
placeholder?: string;
|
|
87
91
|
};
|
|
88
92
|
export type AutocompleteWidget<TItem extends BaseHit = BaseHit> = WidgetFactory<AutocompleteWidgetDescription & {
|
|
89
93
|
$$widgetType: 'ais.autocomplete';
|
|
@@ -22,7 +22,7 @@ import { connectAutocomplete, connectSearchBox } from "../../connectors/index.um
|
|
|
22
22
|
import { ReverseHighlight } from "../../helpers/components/index.js";
|
|
23
23
|
import { component } from "../../lib/suit.js";
|
|
24
24
|
import { prepareTemplateProps } from "../../lib/templating/index.js";
|
|
25
|
-
import { createDocumentationMessageGenerator, getContainerNode, walkIndex } from "../../lib/utils/index.js";
|
|
25
|
+
import { createDocumentationMessageGenerator, find, getContainerNode, walkIndex } from "../../lib/utils/index.js";
|
|
26
26
|
import configure from "../configure/configure.js";
|
|
27
27
|
import index from "../index/index.js";
|
|
28
28
|
var autocompleteInstanceId = 0;
|
|
@@ -103,13 +103,14 @@ function AutocompleteWrapper(_ref) {
|
|
|
103
103
|
indices = _ref.indices,
|
|
104
104
|
getSearchPageURL = _ref.getSearchPageURL,
|
|
105
105
|
userOnSelect = _ref.onSelect,
|
|
106
|
-
|
|
106
|
+
refineAutocomplete = _ref.refine,
|
|
107
107
|
cssClasses = _ref.cssClasses,
|
|
108
108
|
renderState = _ref.renderState,
|
|
109
109
|
instantSearchInstance = _ref.instantSearchInstance,
|
|
110
110
|
showRecent = _ref.showRecent,
|
|
111
111
|
showSuggestions = _ref.showSuggestions,
|
|
112
|
-
templates = _ref.templates
|
|
112
|
+
templates = _ref.templates,
|
|
113
|
+
placeholder = _ref.placeholder;
|
|
113
114
|
var isolatedIndex = renderState.isolatedIndex,
|
|
114
115
|
targetIndex = renderState.targetIndex;
|
|
115
116
|
var searchboxQuery = isolatedIndex === null || isolatedIndex === void 0 ? void 0 : (_isolatedIndex$getHel = isolatedIndex.getHelper()) === null || _isolatedIndex$getHel === void 0 ? void 0 : _isolatedIndex$getHel.state.query;
|
|
@@ -128,6 +129,7 @@ function AutocompleteWrapper(_ref) {
|
|
|
128
129
|
return ['ais.hits', 'ais.infiniteHits'].includes($$type);
|
|
129
130
|
})) !== null && _targetIndex$getWidge !== void 0 ? _targetIndex$getWidge : false;
|
|
130
131
|
var onRefine = function onRefine(query) {
|
|
132
|
+
refineAutocomplete(query);
|
|
131
133
|
instantSearchInstance.setUiState(function (uiState) {
|
|
132
134
|
var _objectSpread2;
|
|
133
135
|
return _objectSpread(_objectSpread({}, uiState), {}, (_objectSpread2 = {}, _defineProperty(_objectSpread2, targetIndex.getIndexId(), _objectSpread(_objectSpread({}, uiState[targetIndex.getIndexId()]), {}, {
|
|
@@ -158,7 +160,8 @@ function AutocompleteWrapper(_ref) {
|
|
|
158
160
|
return;
|
|
159
161
|
}
|
|
160
162
|
setQuery(query);
|
|
161
|
-
}
|
|
163
|
+
},
|
|
164
|
+
placeholder: placeholder
|
|
162
165
|
}),
|
|
163
166
|
getInputProps = _usePropGetters.getInputProps,
|
|
164
167
|
getItemProps = _usePropGetters.getItemProps,
|
|
@@ -257,11 +260,16 @@ function AutocompleteWrapper(_ref) {
|
|
|
257
260
|
}));
|
|
258
261
|
};
|
|
259
262
|
var elementId = indexName === (showSuggestions === null || showSuggestions === void 0 ? void 0 : showSuggestions.indexName) ? 'suggestions' : indexName;
|
|
263
|
+
var filteredHits = elementId === 'suggestions' && showRecent ? hits.filter(function (suggestionHit) {
|
|
264
|
+
return !find(storageHits, function (storageHit) {
|
|
265
|
+
return storageHit.query === suggestionHit.query;
|
|
266
|
+
});
|
|
267
|
+
}) : hits;
|
|
260
268
|
elements[elementId] = h(AutocompleteIndex, {
|
|
261
269
|
key: indexId,
|
|
262
270
|
HeaderComponent: headerComponent,
|
|
263
271
|
ItemComponent: itemComponent,
|
|
264
|
-
items:
|
|
272
|
+
items: filteredHits.map(function (item) {
|
|
265
273
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
266
274
|
__indexName: indexId
|
|
267
275
|
});
|
|
@@ -277,11 +285,11 @@ function AutocompleteWrapper(_ref) {
|
|
|
277
285
|
inputProps: _objectSpread(_objectSpread({}, getInputProps()), {}, {
|
|
278
286
|
// @ts-ignore - This clashes with some ambient React JSX declarations.
|
|
279
287
|
onInput: function onInput(evt) {
|
|
280
|
-
return
|
|
288
|
+
return refineAutocomplete(evt.currentTarget.value);
|
|
281
289
|
}
|
|
282
290
|
}),
|
|
283
291
|
onClear: function onClear() {
|
|
284
|
-
|
|
292
|
+
onRefine('');
|
|
285
293
|
},
|
|
286
294
|
isSearchStalled: instantSearchInstance.status === 'stalled'
|
|
287
295
|
}), h(AutocompletePanel, getPanelProps(), templates.panel ? h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
@@ -309,7 +317,8 @@ export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
309
317
|
_ref0$templates = _ref0.templates,
|
|
310
318
|
templates = _ref0$templates === void 0 ? {} : _ref0$templates,
|
|
311
319
|
_ref0$cssClasses = _ref0.cssClasses,
|
|
312
|
-
userCssClasses = _ref0$cssClasses === void 0 ? {} : _ref0$cssClasses
|
|
320
|
+
userCssClasses = _ref0$cssClasses === void 0 ? {} : _ref0$cssClasses,
|
|
321
|
+
placeholder = _ref0.placeholder;
|
|
313
322
|
if (!container) {
|
|
314
323
|
throw new Error(withUsage('The `container` option is required.'));
|
|
315
324
|
}
|
|
@@ -360,6 +369,7 @@ export function EXPERIMENTAL_autocomplete(widgetParams) {
|
|
|
360
369
|
cssClasses: cssClasses,
|
|
361
370
|
showRecent: showRecent,
|
|
362
371
|
showSuggestions: showSuggestions,
|
|
372
|
+
placeholder: placeholder,
|
|
363
373
|
renderState: {
|
|
364
374
|
indexTemplateProps: [],
|
|
365
375
|
isolatedIndex: undefined,
|
package/es/widgets/chat/chat.js
CHANGED
|
@@ -14,7 +14,7 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
14
14
|
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; }
|
|
15
15
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
16
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
17
|
-
import {
|
|
17
|
+
import { ArrowRightIcon, ChevronLeftIcon, ChevronRightIcon, createButtonComponent, createChatComponent } from 'instantsearch-ui-components';
|
|
18
18
|
import { Fragment, h, render } from 'preact';
|
|
19
19
|
import { useMemo } from 'preact/hooks';
|
|
20
20
|
import TemplateComponent from "../../components/Template/Template.js";
|
|
@@ -39,13 +39,13 @@ function getDefinedProperties(obj) {
|
|
|
39
39
|
return value !== undefined;
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
|
-
var _ref6 = h(
|
|
42
|
+
var _ref6 = h(ArrowRightIcon, {
|
|
43
43
|
createElement: h
|
|
44
44
|
});
|
|
45
|
-
var _ref7 = h(
|
|
45
|
+
var _ref7 = h(ChevronLeftIcon, {
|
|
46
46
|
createElement: h
|
|
47
47
|
});
|
|
48
|
-
var _ref8 = h(
|
|
48
|
+
var _ref8 = h(ChevronRightIcon, {
|
|
49
49
|
createElement: h
|
|
50
50
|
});
|
|
51
51
|
function createCarouselTool(showViewAll, templates, getSearchPageURL) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.85.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",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"algoliasearch-helper": "3.26.1",
|
|
36
36
|
"hogan.js": "^3.0.2",
|
|
37
37
|
"htm": "^3.0.0",
|
|
38
|
-
"instantsearch-ui-components": "0.15.
|
|
38
|
+
"instantsearch-ui-components": "0.15.1",
|
|
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.83.0",
|
|
64
|
+
"@instantsearch/tests": "1.83.0",
|
|
65
|
+
"@instantsearch/testutils": "1.72.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": "417c7fb9ebaa31063d7a817466a303ce51558453"
|
|
74
74
|
}
|