instantsearch.js 4.46.3 → 4.47.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/CHANGELOG.md +14 -0
- package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -1
- package/cjs/lib/InstantSearch.js +45 -6
- package/cjs/lib/utils/createSendEventForFacet.js +2 -1
- package/cjs/lib/utils/createSendEventForHits.js +1 -1
- package/cjs/lib/utils/index.js +13 -0
- package/cjs/lib/utils/render-args.js +47 -0
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createMetadataMiddleware.js +1 -15
- package/cjs/widgets/hierarchical-menu/defaultTemplates.js +3 -2
- package/cjs/widgets/hierarchical-menu/hierarchical-menu.js +4 -0
- package/cjs/widgets/index/index.js +6 -84
- package/dist/instantsearch.development.d.ts +27 -4
- package/dist/instantsearch.development.js +107 -112
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +27 -4
- package/dist/instantsearch.production.min.d.ts +27 -4
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -1
- package/es/connectors/search-box/connectSearchBox.d.ts +1 -0
- package/es/lib/InstantSearch.d.ts +17 -4
- package/es/lib/InstantSearch.js +45 -6
- package/es/lib/utils/createSendEventForFacet.d.ts +4 -3
- package/es/lib/utils/createSendEventForFacet.js +2 -1
- package/es/lib/utils/createSendEventForHits.js +1 -1
- package/es/lib/utils/defer.d.ts +2 -2
- package/es/lib/utils/index.d.ts +1 -0
- package/es/lib/utils/index.js +1 -0
- package/es/lib/utils/render-args.d.ts +34 -0
- package/es/lib/utils/render-args.js +38 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createMetadataMiddleware.js +2 -16
- package/es/types/widget.d.ts +4 -0
- package/es/widgets/hierarchical-menu/defaultTemplates.js +3 -2
- package/es/widgets/hierarchical-menu/hierarchical-menu.d.ts +4 -0
- package/es/widgets/hierarchical-menu/hierarchical-menu.js +4 -0
- package/es/widgets/index/index.js +7 -85
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [4.47.0](https://github.com/algolia/instantsearch.js/compare/v4.46.3...v4.47.0) (2022-10-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **hierarchicalMenu:** pass correct attribute name to Insights ([#5124](https://github.com/algolia/instantsearch.js/issues/5124)) ([fe18a16](https://github.com/algolia/instantsearch.js/commit/fe18a168b1b195d067298770b55fd29a7fdb6edb))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* **status:** introduce status in InstantSearch class ([#5115](https://github.com/algolia/instantsearch.js/issues/5115)) ([21f3147](https://github.com/algolia/instantsearch.js/commit/21f31476e75e162b38b002d5439f231f3990e785))
|
|
12
|
+
* **hierarchicalMenu**: introduce `ais-HierarchicalMenu-item--selected` class ([#5125](https://github.com/algolia/instantsearch.js/issues/5125)) ([4ebb828](https://github.com/algolia/instantsearch.js/commit/4ebb828c93afabfd8083246dfe7edfd33932d5fd))
|
|
13
|
+
|
|
14
|
+
|
|
1
15
|
## [4.46.3](https://github.com/algolia/instantsearch.js/compare/v4.46.2...v4.46.3) (2022-09-27)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -175,7 +175,10 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
|
|
|
175
175
|
sendEvent = (0, _index.createSendEventForFacet)({
|
|
176
176
|
instantSearchInstance: instantSearchInstance,
|
|
177
177
|
helper: helper,
|
|
178
|
-
attribute:
|
|
178
|
+
attribute: function attribute(facetValue) {
|
|
179
|
+
var index = facetValue.split(separator).length - 1;
|
|
180
|
+
return attributes[index];
|
|
181
|
+
},
|
|
179
182
|
widgetType: this.$$type
|
|
180
183
|
});
|
|
181
184
|
}
|
package/cjs/lib/InstantSearch.js
CHANGED
|
@@ -103,8 +103,6 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
103
103
|
|
|
104
104
|
_defineProperty(_assertThisInitialized(_this), "_searchStalledTimer", void 0);
|
|
105
105
|
|
|
106
|
-
_defineProperty(_assertThisInitialized(_this), "_isSearchStalled", void 0);
|
|
107
|
-
|
|
108
106
|
_defineProperty(_assertThisInitialized(_this), "_initialUiState", void 0);
|
|
109
107
|
|
|
110
108
|
_defineProperty(_assertThisInitialized(_this), "_initialResults", void 0);
|
|
@@ -119,6 +117,10 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
119
117
|
|
|
120
118
|
_defineProperty(_assertThisInitialized(_this), "sendEventToInsights", void 0);
|
|
121
119
|
|
|
120
|
+
_defineProperty(_assertThisInitialized(_this), "status", 'idle');
|
|
121
|
+
|
|
122
|
+
_defineProperty(_assertThisInitialized(_this), "error", undefined);
|
|
123
|
+
|
|
122
124
|
_defineProperty(_assertThisInitialized(_this), "scheduleSearch", (0, _index2.defer)(function () {
|
|
123
125
|
if (_this.started) {
|
|
124
126
|
_this.mainHelper.search();
|
|
@@ -126,10 +128,16 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
126
128
|
}));
|
|
127
129
|
|
|
128
130
|
_defineProperty(_assertThisInitialized(_this), "scheduleRender", (0, _index2.defer)(function () {
|
|
131
|
+
var shouldResetStatus = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
132
|
+
|
|
129
133
|
if (!_this.mainHelper.hasPendingRequests()) {
|
|
130
134
|
clearTimeout(_this._searchStalledTimer);
|
|
131
135
|
_this._searchStalledTimer = null;
|
|
132
|
-
|
|
136
|
+
|
|
137
|
+
if (shouldResetStatus) {
|
|
138
|
+
_this.status = 'idle';
|
|
139
|
+
_this.error = undefined;
|
|
140
|
+
}
|
|
133
141
|
}
|
|
134
142
|
|
|
135
143
|
_this.mainIndex.render({
|
|
@@ -210,7 +218,6 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
210
218
|
};
|
|
211
219
|
_this._stalledSearchDelay = stalledSearchDelay;
|
|
212
220
|
_this._searchStalledTimer = null;
|
|
213
|
-
_this._isSearchStalled = false;
|
|
214
221
|
_this._createURL = defaultCreateURL;
|
|
215
222
|
_this._initialUiState = initialUiState;
|
|
216
223
|
_this._initialResults = null;
|
|
@@ -239,6 +246,25 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
239
246
|
|
|
240
247
|
|
|
241
248
|
_createClass(InstantSearch, [{
|
|
249
|
+
key: "_isSearchStalled",
|
|
250
|
+
get:
|
|
251
|
+
/**
|
|
252
|
+
* The status of the search. Can be "idle", "loading", "stalled", or "error".
|
|
253
|
+
*/
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* The last returned error from the Search API.
|
|
257
|
+
* The error gets cleared when the next valid search response is rendered.
|
|
258
|
+
*/
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* @deprecated use `status === 'stalled'` instead
|
|
262
|
+
*/
|
|
263
|
+
function get() {
|
|
264
|
+
process.env.NODE_ENV === 'development' ? (0, _index2.warning)(false, "`InstantSearch._isSearchStalled` is deprecated and will be removed in InstantSearch.js 5.0.\n\nUse `InstantSearch.status === \"stalled\"` instead.") : void 0;
|
|
265
|
+
return this.status === 'stalled';
|
|
266
|
+
}
|
|
267
|
+
}, {
|
|
242
268
|
key: "use",
|
|
243
269
|
value: function use() {
|
|
244
270
|
var _this2 = this;
|
|
@@ -400,10 +426,18 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
400
426
|
var mainHelper = this.mainHelper || (0, _algoliasearchHelper.default)(this.client, this.indexName);
|
|
401
427
|
|
|
402
428
|
mainHelper.search = function () {
|
|
403
|
-
|
|
429
|
+
_this3.status = 'loading'; // @MAJOR: use scheduleRender here
|
|
430
|
+
// For now, widgets don't expect to be rendered at the start of `loading`,
|
|
431
|
+
// so it would be a breaking change to add an extra render. We don't have
|
|
432
|
+
// these guarantees about the render event, thus emitting it once more
|
|
433
|
+
// isn't a breaking change.
|
|
434
|
+
|
|
435
|
+
_this3.emit('render'); // This solution allows us to keep the exact same API for the users but
|
|
404
436
|
// under the hood, we have a different implementation. It should be
|
|
405
437
|
// completely transparent for the rest of the codebase. Only this module
|
|
406
438
|
// is impacted.
|
|
439
|
+
|
|
440
|
+
|
|
407
441
|
return mainHelper.searchOnlyWithDerivedHelpers();
|
|
408
442
|
};
|
|
409
443
|
|
|
@@ -460,6 +494,11 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
460
494
|
|
|
461
495
|
|
|
462
496
|
error.error = error;
|
|
497
|
+
_this3.error = error;
|
|
498
|
+
_this3.status = 'error';
|
|
499
|
+
|
|
500
|
+
_this3.scheduleRender(false); // This needs to execute last because it throws the error.
|
|
501
|
+
|
|
463
502
|
|
|
464
503
|
_this3.emit('error', error);
|
|
465
504
|
});
|
|
@@ -548,7 +587,7 @@ var InstantSearch = /*#__PURE__*/function (_EventEmitter) {
|
|
|
548
587
|
|
|
549
588
|
if (!this._searchStalledTimer) {
|
|
550
589
|
this._searchStalledTimer = setTimeout(function () {
|
|
551
|
-
_this4.
|
|
590
|
+
_this4.status = 'stalled';
|
|
552
591
|
|
|
553
592
|
_this4.scheduleRender();
|
|
554
593
|
}, this._stalledSearchDelay);
|
|
@@ -12,7 +12,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
|
|
|
12
12
|
function createSendEventForFacet(_ref) {
|
|
13
13
|
var instantSearchInstance = _ref.instantSearchInstance,
|
|
14
14
|
helper = _ref.helper,
|
|
15
|
-
|
|
15
|
+
attr = _ref.attribute,
|
|
16
16
|
widgetType = _ref.widgetType;
|
|
17
17
|
|
|
18
18
|
var sendEventForFacet = function sendEventForFacet() {
|
|
@@ -24,6 +24,7 @@ function createSendEventForFacet(_ref) {
|
|
|
24
24
|
facetValue = args[1],
|
|
25
25
|
_args$ = args[2],
|
|
26
26
|
eventName = _args$ === void 0 ? 'Filter Applied' : _args$;
|
|
27
|
+
var attribute = typeof attr === 'string' ? attr : attr(facetValue);
|
|
27
28
|
|
|
28
29
|
if (args.length === 1 && _typeof(args[0]) === 'object') {
|
|
29
30
|
instantSearchInstance.sendEventToInsights(args[0]);
|
|
@@ -148,7 +148,7 @@ function createSendEventForHits(_ref2) {
|
|
|
148
148
|
index: index,
|
|
149
149
|
methodName: 'sendEvent',
|
|
150
150
|
args: args,
|
|
151
|
-
isSearchStalled: instantSearchInstance.
|
|
151
|
+
isSearchStalled: instantSearchInstance.status === 'stalled'
|
|
152
152
|
});
|
|
153
153
|
payloads.forEach(function (payload) {
|
|
154
154
|
return instantSearchInstance.sendEventToInsights(payload);
|
package/cjs/lib/utils/index.js
CHANGED
|
@@ -524,6 +524,19 @@ Object.keys(_range).forEach(function (key) {
|
|
|
524
524
|
});
|
|
525
525
|
});
|
|
526
526
|
|
|
527
|
+
var _renderArgs = require("./render-args.js");
|
|
528
|
+
|
|
529
|
+
Object.keys(_renderArgs).forEach(function (key) {
|
|
530
|
+
if (key === "default" || key === "__esModule") return;
|
|
531
|
+
if (key in exports && exports[key] === _renderArgs[key]) return;
|
|
532
|
+
Object.defineProperty(exports, key, {
|
|
533
|
+
enumerable: true,
|
|
534
|
+
get: function get() {
|
|
535
|
+
return _renderArgs[key];
|
|
536
|
+
}
|
|
537
|
+
});
|
|
538
|
+
});
|
|
539
|
+
|
|
527
540
|
var _resolveSearchParameters = require("./resolveSearchParameters.js");
|
|
528
541
|
|
|
529
542
|
Object.keys(_resolveSearchParameters).forEach(function (key) {
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createInitArgs = createInitArgs;
|
|
7
|
+
exports.createRenderArgs = createRenderArgs;
|
|
8
|
+
|
|
9
|
+
function createInitArgs(instantSearchInstance, parent, uiState) {
|
|
10
|
+
var helper = parent.getHelper();
|
|
11
|
+
return {
|
|
12
|
+
uiState: uiState,
|
|
13
|
+
helper: helper,
|
|
14
|
+
parent: parent,
|
|
15
|
+
instantSearchInstance: instantSearchInstance,
|
|
16
|
+
state: helper.state,
|
|
17
|
+
renderState: instantSearchInstance.renderState,
|
|
18
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
19
|
+
createURL: parent.createURL,
|
|
20
|
+
scopedResults: [],
|
|
21
|
+
searchMetadata: {
|
|
22
|
+
isSearchStalled: instantSearchInstance.status === 'stalled'
|
|
23
|
+
},
|
|
24
|
+
status: instantSearchInstance.status,
|
|
25
|
+
error: instantSearchInstance.error
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function createRenderArgs(instantSearchInstance, parent) {
|
|
30
|
+
var results = parent.getResults();
|
|
31
|
+
return {
|
|
32
|
+
helper: parent.getHelper(),
|
|
33
|
+
parent: parent,
|
|
34
|
+
instantSearchInstance: instantSearchInstance,
|
|
35
|
+
results: results,
|
|
36
|
+
scopedResults: parent.getScopedResults(),
|
|
37
|
+
state: results._state,
|
|
38
|
+
renderState: instantSearchInstance.renderState,
|
|
39
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
40
|
+
createURL: parent.createURL,
|
|
41
|
+
searchMetadata: {
|
|
42
|
+
isSearchStalled: instantSearchInstance.status === 'stalled'
|
|
43
|
+
},
|
|
44
|
+
status: instantSearchInstance.status,
|
|
45
|
+
error: instantSearchInstance.error
|
|
46
|
+
};
|
|
47
|
+
}
|
package/cjs/lib/version.js
CHANGED
|
@@ -9,21 +9,7 @@ exports.createMetadataMiddleware = createMetadataMiddleware;
|
|
|
9
9
|
var _index = require("../lib/utils/index.js");
|
|
10
10
|
|
|
11
11
|
function extractPayload(widgets, instantSearchInstance, payload) {
|
|
12
|
-
var
|
|
13
|
-
var initOptions = {
|
|
14
|
-
instantSearchInstance: instantSearchInstance,
|
|
15
|
-
parent: parent,
|
|
16
|
-
scopedResults: [],
|
|
17
|
-
state: parent.getHelper().state,
|
|
18
|
-
helper: parent.getHelper(),
|
|
19
|
-
createURL: parent.createURL,
|
|
20
|
-
uiState: instantSearchInstance._initialUiState,
|
|
21
|
-
renderState: instantSearchInstance.renderState,
|
|
22
|
-
templatesConfig: instantSearchInstance.templatesConfig,
|
|
23
|
-
searchMetadata: {
|
|
24
|
-
isSearchStalled: instantSearchInstance._isSearchStalled
|
|
25
|
-
}
|
|
26
|
-
};
|
|
12
|
+
var initOptions = (0, _index.createInitArgs)(instantSearchInstance, instantSearchInstance.mainIndex, instantSearchInstance._initialUiState);
|
|
27
13
|
widgets.forEach(function (widget) {
|
|
28
14
|
var widgetParams = {};
|
|
29
15
|
|
|
@@ -16,9 +16,10 @@ var defaultTemplates = {
|
|
|
16
16
|
var url = _ref.url,
|
|
17
17
|
label = _ref.label,
|
|
18
18
|
count = _ref.count,
|
|
19
|
-
cssClasses = _ref.cssClasses
|
|
19
|
+
cssClasses = _ref.cssClasses,
|
|
20
|
+
isRefined = _ref.isRefined;
|
|
20
21
|
return (0, _preact.h)("a", {
|
|
21
|
-
className: (0, _index.cx)(cssClasses.link),
|
|
22
|
+
className: (0, _index.cx)([(0, _index.cx)(cssClasses.link), (0, _index.cx)(isRefined ? cssClasses.selectedItemLink : undefined)]),
|
|
22
23
|
href: url
|
|
23
24
|
}, (0, _preact.h)("span", {
|
|
24
25
|
className: (0, _index.cx)(cssClasses.label)
|
|
@@ -173,6 +173,10 @@ var hierarchicalMenu = function hierarchicalMenu(widgetParams) {
|
|
|
173
173
|
link: (0, _classnames.default)(suit({
|
|
174
174
|
descendantName: 'link'
|
|
175
175
|
}), userCssClasses.link),
|
|
176
|
+
selectedItemLink: (0, _classnames.default)(suit({
|
|
177
|
+
descendantName: 'link',
|
|
178
|
+
modifierName: 'selected'
|
|
179
|
+
}), userCssClasses.selectedItemLink),
|
|
176
180
|
label: (0, _classnames.default)(suit({
|
|
177
181
|
descendantName: 'label'
|
|
178
182
|
}), userCssClasses.label),
|
|
@@ -195,20 +195,7 @@ var index = function index(widgetParams) {
|
|
|
195
195
|
|
|
196
196
|
widgets.forEach(function (widget) {
|
|
197
197
|
if (widget.getRenderState) {
|
|
198
|
-
var renderState = widget.getRenderState(localInstantSearchInstance.renderState[_this.getIndexId()] || {},
|
|
199
|
-
uiState: localInstantSearchInstance._initialUiState,
|
|
200
|
-
helper: _this.getHelper(),
|
|
201
|
-
parent: _this,
|
|
202
|
-
instantSearchInstance: localInstantSearchInstance,
|
|
203
|
-
state: helper.state,
|
|
204
|
-
renderState: localInstantSearchInstance.renderState,
|
|
205
|
-
templatesConfig: localInstantSearchInstance.templatesConfig,
|
|
206
|
-
createURL: _this.createURL,
|
|
207
|
-
scopedResults: [],
|
|
208
|
-
searchMetadata: {
|
|
209
|
-
isSearchStalled: localInstantSearchInstance._isSearchStalled
|
|
210
|
-
}
|
|
211
|
-
});
|
|
198
|
+
var renderState = widget.getRenderState(localInstantSearchInstance.renderState[_this.getIndexId()] || {}, (0, _index.createInitArgs)(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));
|
|
212
199
|
storeRenderState({
|
|
213
200
|
renderState: renderState,
|
|
214
201
|
instantSearchInstance: localInstantSearchInstance,
|
|
@@ -218,20 +205,7 @@ var index = function index(widgetParams) {
|
|
|
218
205
|
});
|
|
219
206
|
widgets.forEach(function (widget) {
|
|
220
207
|
if (widget.init) {
|
|
221
|
-
widget.init(
|
|
222
|
-
helper: helper,
|
|
223
|
-
parent: _this,
|
|
224
|
-
uiState: localInstantSearchInstance._initialUiState,
|
|
225
|
-
instantSearchInstance: localInstantSearchInstance,
|
|
226
|
-
state: helper.state,
|
|
227
|
-
renderState: localInstantSearchInstance.renderState,
|
|
228
|
-
templatesConfig: localInstantSearchInstance.templatesConfig,
|
|
229
|
-
createURL: _this.createURL,
|
|
230
|
-
scopedResults: [],
|
|
231
|
-
searchMetadata: {
|
|
232
|
-
isSearchStalled: localInstantSearchInstance._isSearchStalled
|
|
233
|
-
}
|
|
234
|
-
});
|
|
208
|
+
widget.init((0, _index.createInitArgs)(localInstantSearchInstance, _this, localInstantSearchInstance._initialUiState));
|
|
235
209
|
}
|
|
236
210
|
});
|
|
237
211
|
localInstantSearchInstance.scheduleSearch();
|
|
@@ -397,20 +371,7 @@ var index = function index(widgetParams) {
|
|
|
397
371
|
|
|
398
372
|
localWidgets.forEach(function (widget) {
|
|
399
373
|
if (widget.getRenderState) {
|
|
400
|
-
var renderState = widget.getRenderState(instantSearchInstance.renderState[_this3.getIndexId()] || {},
|
|
401
|
-
uiState: uiState,
|
|
402
|
-
helper: helper,
|
|
403
|
-
parent: _this3,
|
|
404
|
-
instantSearchInstance: instantSearchInstance,
|
|
405
|
-
state: helper.state,
|
|
406
|
-
renderState: instantSearchInstance.renderState,
|
|
407
|
-
templatesConfig: instantSearchInstance.templatesConfig,
|
|
408
|
-
createURL: _this3.createURL,
|
|
409
|
-
scopedResults: [],
|
|
410
|
-
searchMetadata: {
|
|
411
|
-
isSearchStalled: instantSearchInstance._isSearchStalled
|
|
412
|
-
}
|
|
413
|
-
});
|
|
374
|
+
var renderState = widget.getRenderState(instantSearchInstance.renderState[_this3.getIndexId()] || {}, (0, _index.createInitArgs)(instantSearchInstance, _this3, uiState));
|
|
414
375
|
storeRenderState({
|
|
415
376
|
renderState: renderState,
|
|
416
377
|
instantSearchInstance: instantSearchInstance,
|
|
@@ -424,20 +385,7 @@ var index = function index(widgetParams) {
|
|
|
424
385
|
!widget.getWidgetState || Boolean(widget.getWidgetUiState), 'The `getWidgetState` method is renamed `getWidgetUiState` and will no longer exist under that name in InstantSearch.js 5.x. Please use `getWidgetUiState` instead.') : void 0;
|
|
425
386
|
|
|
426
387
|
if (widget.init) {
|
|
427
|
-
widget.init(
|
|
428
|
-
uiState: uiState,
|
|
429
|
-
helper: helper,
|
|
430
|
-
parent: _this3,
|
|
431
|
-
instantSearchInstance: instantSearchInstance,
|
|
432
|
-
state: helper.state,
|
|
433
|
-
renderState: instantSearchInstance.renderState,
|
|
434
|
-
templatesConfig: instantSearchInstance.templatesConfig,
|
|
435
|
-
createURL: _this3.createURL,
|
|
436
|
-
scopedResults: [],
|
|
437
|
-
searchMetadata: {
|
|
438
|
-
isSearchStalled: instantSearchInstance._isSearchStalled
|
|
439
|
-
}
|
|
440
|
-
});
|
|
388
|
+
widget.init((0, _index.createInitArgs)(instantSearchInstance, _this3, uiState));
|
|
441
389
|
}
|
|
442
390
|
}); // Subscribe to the Helper state changes for the `uiState` once widgets
|
|
443
391
|
// are initialized. Until the first render, state changes are part of the
|
|
@@ -478,20 +426,7 @@ var index = function index(widgetParams) {
|
|
|
478
426
|
|
|
479
427
|
localWidgets.forEach(function (widget) {
|
|
480
428
|
if (widget.getRenderState) {
|
|
481
|
-
var renderState = widget.getRenderState(instantSearchInstance.renderState[_this4.getIndexId()] || {},
|
|
482
|
-
helper: _this4.getHelper(),
|
|
483
|
-
parent: _this4,
|
|
484
|
-
instantSearchInstance: instantSearchInstance,
|
|
485
|
-
results: _this4.getResults(),
|
|
486
|
-
scopedResults: _this4.getScopedResults(),
|
|
487
|
-
state: _this4.getResults()._state,
|
|
488
|
-
renderState: instantSearchInstance.renderState,
|
|
489
|
-
templatesConfig: instantSearchInstance.templatesConfig,
|
|
490
|
-
createURL: _this4.createURL,
|
|
491
|
-
searchMetadata: {
|
|
492
|
-
isSearchStalled: instantSearchInstance._isSearchStalled
|
|
493
|
-
}
|
|
494
|
-
});
|
|
429
|
+
var renderState = widget.getRenderState(instantSearchInstance.renderState[_this4.getIndexId()] || {}, (0, _index.createRenderArgs)(instantSearchInstance, _this4));
|
|
495
430
|
storeRenderState({
|
|
496
431
|
renderState: renderState,
|
|
497
432
|
instantSearchInstance: instantSearchInstance,
|
|
@@ -507,20 +442,7 @@ var index = function index(widgetParams) {
|
|
|
507
442
|
// be delayed. The render is triggered for the complete tree but some parts do
|
|
508
443
|
// not have results yet.
|
|
509
444
|
if (widget.render) {
|
|
510
|
-
widget.render(
|
|
511
|
-
helper: helper,
|
|
512
|
-
parent: _this4,
|
|
513
|
-
instantSearchInstance: instantSearchInstance,
|
|
514
|
-
results: _this4.getResults(),
|
|
515
|
-
scopedResults: _this4.getScopedResults(),
|
|
516
|
-
state: _this4.getResults()._state,
|
|
517
|
-
renderState: instantSearchInstance.renderState,
|
|
518
|
-
templatesConfig: instantSearchInstance.templatesConfig,
|
|
519
|
-
createURL: _this4.createURL,
|
|
520
|
-
searchMetadata: {
|
|
521
|
-
isSearchStalled: instantSearchInstance._isSearchStalled
|
|
522
|
-
}
|
|
523
|
-
});
|
|
445
|
+
widget.render((0, _index.createRenderArgs)(instantSearchInstance, _this4));
|
|
524
446
|
}
|
|
525
447
|
});
|
|
526
448
|
},
|
|
@@ -1516,6 +1516,10 @@ declare type HierarchicalMenuCSSClasses = Partial<{
|
|
|
1516
1516
|
* CSS class to add to each link (when using the default template).
|
|
1517
1517
|
*/
|
|
1518
1518
|
link: string | string[];
|
|
1519
|
+
/**
|
|
1520
|
+
* CSS class to add to the link of each selected item element (when using the default template).
|
|
1521
|
+
*/
|
|
1522
|
+
selectedItemLink: string | string[];
|
|
1519
1523
|
/**
|
|
1520
1524
|
* CSS class to add to each label (when using the default template).
|
|
1521
1525
|
*/
|
|
@@ -2317,7 +2321,6 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2317
2321
|
renderState: RenderState;
|
|
2318
2322
|
_stalledSearchDelay: number;
|
|
2319
2323
|
_searchStalledTimer: any;
|
|
2320
|
-
_isSearchStalled: boolean;
|
|
2321
2324
|
_initialUiState: TUiState;
|
|
2322
2325
|
_initialResults: InitialResults | null;
|
|
2323
2326
|
_createURL: CreateURL<TUiState>;
|
|
@@ -2328,6 +2331,19 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2328
2331
|
instance: MiddlewareDefinition;
|
|
2329
2332
|
}>;
|
|
2330
2333
|
sendEventToInsights: (event: InsightsEvent) => void;
|
|
2334
|
+
/**
|
|
2335
|
+
* The status of the search. Can be "idle", "loading", "stalled", or "error".
|
|
2336
|
+
*/
|
|
2337
|
+
status: InstantSearchStatus;
|
|
2338
|
+
/**
|
|
2339
|
+
* The last returned error from the Search API.
|
|
2340
|
+
* The error gets cleared when the next valid search response is rendered.
|
|
2341
|
+
*/
|
|
2342
|
+
error: Error | undefined;
|
|
2343
|
+
/**
|
|
2344
|
+
* @deprecated use `status === 'stalled'` instead
|
|
2345
|
+
*/
|
|
2346
|
+
get _isSearchStalled(): boolean;
|
|
2331
2347
|
constructor(options: InstantSearchOptions<TUiState, TRouteState>);
|
|
2332
2348
|
/**
|
|
2333
2349
|
* Hooks a middleware into the InstantSearch lifecycle.
|
|
@@ -2381,11 +2397,11 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2381
2397
|
* @return {undefined} This method does not return anything
|
|
2382
2398
|
*/
|
|
2383
2399
|
dispose(): void;
|
|
2384
|
-
scheduleSearch: ((
|
|
2400
|
+
scheduleSearch: (() => void) & {
|
|
2385
2401
|
wait(): Promise<void>;
|
|
2386
2402
|
cancel(): void;
|
|
2387
2403
|
};
|
|
2388
|
-
scheduleRender: ((
|
|
2404
|
+
scheduleRender: ((shouldResetStatus?: boolean) => void) & {
|
|
2389
2405
|
wait(): Promise<void>;
|
|
2390
2406
|
cancel(): void;
|
|
2391
2407
|
};
|
|
@@ -2397,7 +2413,7 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2397
2413
|
*/
|
|
2398
2414
|
setUiState(uiState: TUiState | ((previousUiState: TUiState) => TUiState), callOnStateChange?: boolean): void;
|
|
2399
2415
|
getUiState(): TUiState;
|
|
2400
|
-
onInternalStateChange: ((
|
|
2416
|
+
onInternalStateChange: (() => void) & {
|
|
2401
2417
|
wait(): Promise<void>;
|
|
2402
2418
|
cancel(): void;
|
|
2403
2419
|
};
|
|
@@ -2525,6 +2541,8 @@ declare type InstantSearchOptions<TUiState extends UiState = UiState, TRouteStat
|
|
|
2525
2541
|
insightsClient?: InsightsClient;
|
|
2526
2542
|
};
|
|
2527
2543
|
|
|
2544
|
+
declare type InstantSearchStatus = 'idle' | 'loading' | 'stalled' | 'error';
|
|
2545
|
+
|
|
2528
2546
|
declare type InternalMiddleware<TUiState extends UiState = UiState> = (options: MiddlewareOptions) => MiddlewareDefinition<TUiState>;
|
|
2529
2547
|
|
|
2530
2548
|
declare function isMetadataEnabled(): boolean;
|
|
@@ -4592,6 +4610,7 @@ declare type SearchBoxRenderState = {
|
|
|
4592
4610
|
* `true` if the search results takes more than a certain time to come back
|
|
4593
4611
|
* from Algolia servers. This can be configured on the InstantSearch constructor with the attribute
|
|
4594
4612
|
* `stalledSearchDelay` which is 200ms, by default.
|
|
4613
|
+
* @deprecated use `instantSearchInstance.status` instead
|
|
4595
4614
|
*/
|
|
4596
4615
|
isSearchStalled: boolean;
|
|
4597
4616
|
};
|
|
@@ -4703,9 +4722,13 @@ declare type SharedRenderOptions = {
|
|
|
4703
4722
|
state: SearchParameters;
|
|
4704
4723
|
renderState: IndexRenderState;
|
|
4705
4724
|
helper: AlgoliaSearchHelper;
|
|
4725
|
+
/** @deprecated use `status` instead */
|
|
4706
4726
|
searchMetadata: {
|
|
4727
|
+
/** @deprecated use `status === "stalled"` instead */
|
|
4707
4728
|
isSearchStalled: boolean;
|
|
4708
4729
|
};
|
|
4730
|
+
status: InstantSearch['status'];
|
|
4731
|
+
error: InstantSearch['error'];
|
|
4709
4732
|
createURL(state: SearchParameters): string;
|
|
4710
4733
|
};
|
|
4711
4734
|
|