instantsearch.js 4.38.0 → 4.39.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/CHANGELOG.md +27 -0
- package/cjs/connectors/hits/connectHits.js +1 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +3 -2
- package/cjs/lib/routers/history.js +44 -29
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createMetadataMiddleware.js +3 -1
- package/dist/instantsearch.development.d.ts +51 -36
- package/dist/instantsearch.development.js +53 -35
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +51 -36
- package/dist/instantsearch.production.min.d.ts +51 -36
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/ToggleRefinement/ToggleRefinement.d.ts +3 -0
- package/es/components/ToggleRefinement/ToggleRefinement.js +4 -0
- package/es/connectors/hits/connectHits.d.ts +10 -10
- package/es/connectors/hits/connectHits.js +1 -1
- package/es/connectors/hits/connectHitsWithInsights.d.ts +1 -1
- package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +21 -21
- package/es/connectors/infinite-hits/connectInfiniteHits.js +3 -2
- package/es/connectors/infinite-hits/connectInfiniteHitsWithInsights.d.ts +1 -1
- package/es/lib/routers/history.d.ts +11 -0
- package/es/lib/routers/history.js +44 -29
- package/es/lib/utils/createSendEventForHits.d.ts +3 -0
- package/es/lib/utils/createSendEventForHits.js +3 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createMetadataMiddleware.js +3 -1
- package/es/types/results.d.ts +8 -5
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
## [4.39.1](https://github.com/algolia/instantsearch.js/compare/v4.39.0...v4.39.1) (2022-03-01)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* **insights:** send view events after rendering ([#5014](https://github.com/algolia/instantsearch.js/issues/5014)) ([e952abc](https://github.com/algolia/instantsearch.js/commit/e952abc64043a55e06c9c46a656bc98ad45d1502))
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# [4.39.0](https://github.com/algolia/instantsearch.js/compare/v4.38.1...v4.39.0) (2022-02-23)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
|
|
15
|
+
* **ts:** allow Hits related connectors to be generic ([#5019](https://github.com/algolia/instantsearch.js/issues/5019)) ([e986f7e](https://github.com/algolia/instantsearch.js/commit/e986f7e46d57173da4d3d6c3c23fbdf3f9c0f78c))
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
## [4.38.1](https://github.com/algolia/instantsearch.js/compare/v4.38.0...v4.38.1) (2022-02-08)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
* **routing:** fix history router based on history length ([#5004](https://github.com/algolia/instantsearch.js/issues/5004)) ([40541af](https://github.com/algolia/instantsearch.js/commit/40541af5c8face0e32a1ec3a4665a8387d89c626))
|
|
25
|
+
* **metadata:** ensure safe user agent detection ([#5009](https://github.com/algolia/instantsearch.js/pull/5009) [15a6a9d](https://github.com/algolia/instantsearch.js/commit/15a6a9d10ee512fab6884696bc59bedea13bd1b3))
|
|
26
|
+
|
|
27
|
+
|
|
1
28
|
# [4.38.0](https://github.com/algolia/instantsearch.js/compare/v4.37.3...v4.38.0) (2022-01-28)
|
|
2
29
|
|
|
3
30
|
|
|
@@ -41,10 +41,10 @@ var connectHits = function connectHits(renderFn) {
|
|
|
41
41
|
},
|
|
42
42
|
render: function render(renderOptions) {
|
|
43
43
|
var renderState = this.getWidgetRenderState(renderOptions);
|
|
44
|
-
renderState.sendEvent('view', renderState.hits);
|
|
45
44
|
renderFn(_objectSpread(_objectSpread({}, renderState), {}, {
|
|
46
45
|
instantSearchInstance: renderOptions.instantSearchInstance
|
|
47
46
|
}), false);
|
|
47
|
+
renderState.sendEvent('view', renderState.hits);
|
|
48
48
|
},
|
|
49
49
|
getRenderState: function getRenderState(renderState, renderOptions) {
|
|
50
50
|
return _objectSpread(_objectSpread({}, renderState), {}, {
|
|
@@ -69,7 +69,8 @@ function extractHitsFromCachedHits(cachedHits) {
|
|
|
69
69
|
|
|
70
70
|
var connectInfiniteHits = function connectInfiniteHits(renderFn) {
|
|
71
71
|
var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _index.noop;
|
|
72
|
-
(0, _index.checkRendering)(renderFn, withUsage());
|
|
72
|
+
(0, _index.checkRendering)(renderFn, withUsage()); // @TODO: this should be a generic, but a Connector can not yet be generic itself
|
|
73
|
+
|
|
73
74
|
return function (widgetParams) {
|
|
74
75
|
var _ref4 = widgetParams || {},
|
|
75
76
|
_ref4$escapeHTML = _ref4.escapeHTML,
|
|
@@ -140,10 +141,10 @@ var connectInfiniteHits = function connectInfiniteHits(renderFn) {
|
|
|
140
141
|
render: function render(renderOptions) {
|
|
141
142
|
var instantSearchInstance = renderOptions.instantSearchInstance;
|
|
142
143
|
var widgetRenderState = this.getWidgetRenderState(renderOptions);
|
|
143
|
-
sendEvent('view', widgetRenderState.currentPageHits);
|
|
144
144
|
renderFn(_objectSpread(_objectSpread({}, widgetRenderState), {}, {
|
|
145
145
|
instantSearchInstance: instantSearchInstance
|
|
146
146
|
}), false);
|
|
147
|
+
sendEvent('view', widgetRenderState.currentPageHits);
|
|
147
148
|
},
|
|
148
149
|
getRenderState: function getRenderState(renderState, renderOptions) {
|
|
149
150
|
return _objectSpread(_objectSpread({}, renderState), {}, {
|
|
@@ -58,16 +58,23 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
58
58
|
|
|
59
59
|
_defineProperty(this, "shouldPushState", true);
|
|
60
60
|
|
|
61
|
+
_defineProperty(this, "isDisposed", false);
|
|
62
|
+
|
|
63
|
+
_defineProperty(this, "latestAcknowledgedHistory", 0);
|
|
64
|
+
|
|
61
65
|
this.windowTitle = windowTitle;
|
|
62
66
|
this.writeTimer = undefined;
|
|
63
67
|
this.writeDelay = writeDelay;
|
|
64
68
|
this._createURL = createURL;
|
|
65
69
|
this.parseURL = parseURL;
|
|
66
70
|
this.getLocation = getLocation;
|
|
67
|
-
(0, _index.safelyRunOnBrowser)(function () {
|
|
71
|
+
(0, _index.safelyRunOnBrowser)(function (_ref2) {
|
|
72
|
+
var window = _ref2.window;
|
|
73
|
+
|
|
68
74
|
var title = _this.windowTitle && _this.windowTitle(_this.read());
|
|
69
75
|
|
|
70
76
|
setWindowTitle(title);
|
|
77
|
+
_this.latestAcknowledgedHistory = window.history.length;
|
|
71
78
|
});
|
|
72
79
|
}
|
|
73
80
|
/**
|
|
@@ -92,8 +99,8 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
92
99
|
value: function write(routeState) {
|
|
93
100
|
var _this2 = this;
|
|
94
101
|
|
|
95
|
-
(0, _index.safelyRunOnBrowser)(function (
|
|
96
|
-
var window =
|
|
102
|
+
(0, _index.safelyRunOnBrowser)(function (_ref3) {
|
|
103
|
+
var window = _ref3.window;
|
|
97
104
|
|
|
98
105
|
var url = _this2.createURL(routeState);
|
|
99
106
|
|
|
@@ -104,10 +111,17 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
104
111
|
}
|
|
105
112
|
|
|
106
113
|
_this2.writeTimer = setTimeout(function () {
|
|
107
|
-
setWindowTitle(title);
|
|
114
|
+
setWindowTitle(title); // We do want to `pushState` if:
|
|
115
|
+
// - the router is not disposed, IS.js needs to update the URL
|
|
116
|
+
// OR
|
|
117
|
+
// - the last write was from InstantSearch.js
|
|
118
|
+
// (unlike a SPA, where it would have last written)
|
|
119
|
+
|
|
120
|
+
var lastPushWasByISAfterDispose = !_this2.isDisposed || _this2.latestAcknowledgedHistory === window.history.length;
|
|
108
121
|
|
|
109
|
-
if (_this2.shouldPushState) {
|
|
122
|
+
if (_this2.shouldPushState && lastPushWasByISAfterDispose) {
|
|
110
123
|
window.history.pushState(routeState, title || '', url);
|
|
124
|
+
_this2.latestAcknowledgedHistory = window.history.length;
|
|
111
125
|
}
|
|
112
126
|
|
|
113
127
|
_this2.shouldPushState = true;
|
|
@@ -143,8 +157,8 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
143
157
|
}
|
|
144
158
|
};
|
|
145
159
|
|
|
146
|
-
(0, _index.safelyRunOnBrowser)(function (
|
|
147
|
-
var window =
|
|
160
|
+
(0, _index.safelyRunOnBrowser)(function (_ref4) {
|
|
161
|
+
var window = _ref4.window;
|
|
148
162
|
window.addEventListener('popstate', _this3._onPopState);
|
|
149
163
|
});
|
|
150
164
|
}
|
|
@@ -174,8 +188,9 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
174
188
|
value: function dispose() {
|
|
175
189
|
var _this4 = this;
|
|
176
190
|
|
|
177
|
-
|
|
178
|
-
|
|
191
|
+
this.isDisposed = true;
|
|
192
|
+
(0, _index.safelyRunOnBrowser)(function (_ref5) {
|
|
193
|
+
var window = _ref5.window;
|
|
179
194
|
|
|
180
195
|
if (_this4._onPopState) {
|
|
181
196
|
window.removeEventListener('popstate', _this4._onPopState);
|
|
@@ -194,12 +209,12 @@ var BrowserHistory = /*#__PURE__*/function () {
|
|
|
194
209
|
}();
|
|
195
210
|
|
|
196
211
|
function historyRouter() {
|
|
197
|
-
var
|
|
198
|
-
|
|
199
|
-
createURL =
|
|
200
|
-
var qsModule =
|
|
201
|
-
routeState =
|
|
202
|
-
location =
|
|
212
|
+
var _ref6 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
213
|
+
_ref6$createURL = _ref6.createURL,
|
|
214
|
+
createURL = _ref6$createURL === void 0 ? function (_ref7) {
|
|
215
|
+
var qsModule = _ref7.qsModule,
|
|
216
|
+
routeState = _ref7.routeState,
|
|
217
|
+
location = _ref7.location;
|
|
203
218
|
var protocol = location.protocol,
|
|
204
219
|
hostname = location.hostname,
|
|
205
220
|
_location$port = location.port,
|
|
@@ -215,11 +230,11 @@ function historyRouter() {
|
|
|
215
230
|
}
|
|
216
231
|
|
|
217
232
|
return "".concat(protocol, "//").concat(hostname).concat(portWithPrefix).concat(pathname, "?").concat(queryString).concat(hash);
|
|
218
|
-
} :
|
|
219
|
-
|
|
220
|
-
parseURL =
|
|
221
|
-
var qsModule =
|
|
222
|
-
location =
|
|
233
|
+
} : _ref6$createURL,
|
|
234
|
+
_ref6$parseURL = _ref6.parseURL,
|
|
235
|
+
parseURL = _ref6$parseURL === void 0 ? function (_ref8) {
|
|
236
|
+
var qsModule = _ref8.qsModule,
|
|
237
|
+
location = _ref8.location;
|
|
223
238
|
// `qs` by default converts arrays with more than 20 items to an object.
|
|
224
239
|
// We want to avoid this because the data structure manipulated can therefore vary.
|
|
225
240
|
// Setting the limit to `100` seems a good number because the engine's default is 100
|
|
@@ -233,21 +248,21 @@ function historyRouter() {
|
|
|
233
248
|
return qsModule.parse(location.search.slice(1), {
|
|
234
249
|
arrayLimit: 99
|
|
235
250
|
});
|
|
236
|
-
} :
|
|
237
|
-
|
|
238
|
-
writeDelay =
|
|
239
|
-
windowTitle =
|
|
240
|
-
|
|
241
|
-
getLocation =
|
|
242
|
-
return (0, _index.safelyRunOnBrowser)(function (
|
|
243
|
-
var window =
|
|
251
|
+
} : _ref6$parseURL,
|
|
252
|
+
_ref6$writeDelay = _ref6.writeDelay,
|
|
253
|
+
writeDelay = _ref6$writeDelay === void 0 ? 400 : _ref6$writeDelay,
|
|
254
|
+
windowTitle = _ref6.windowTitle,
|
|
255
|
+
_ref6$getLocation = _ref6.getLocation,
|
|
256
|
+
getLocation = _ref6$getLocation === void 0 ? function () {
|
|
257
|
+
return (0, _index.safelyRunOnBrowser)(function (_ref9) {
|
|
258
|
+
var window = _ref9.window;
|
|
244
259
|
return window.location;
|
|
245
260
|
}, {
|
|
246
261
|
fallback: function fallback() {
|
|
247
262
|
throw new Error('You need to provide `getLocation` to the `history` router in environments where `window` does not exist.');
|
|
248
263
|
}
|
|
249
264
|
});
|
|
250
|
-
} :
|
|
265
|
+
} : _ref6$getLocation;
|
|
251
266
|
|
|
252
267
|
return new BrowserHistory({
|
|
253
268
|
createURL: createURL,
|
package/cjs/lib/version.js
CHANGED
|
@@ -54,8 +54,10 @@ function extractPayload(widgets, instantSearchInstance, payload) {
|
|
|
54
54
|
|
|
55
55
|
function isMetadataEnabled() {
|
|
56
56
|
return (0, _index.safelyRunOnBrowser)(function (_ref) {
|
|
57
|
+
var _window$navigator, _window$navigator$use;
|
|
58
|
+
|
|
57
59
|
var window = _ref.window;
|
|
58
|
-
return window.navigator.userAgent.indexOf('Algolia Crawler') > -1;
|
|
60
|
+
return ((_window$navigator = window.navigator) === null || _window$navigator === void 0 ? void 0 : (_window$navigator$use = _window$navigator.userAgent) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.indexOf('Algolia Crawler')) > -1;
|
|
59
61
|
}, {
|
|
60
62
|
fallback: function fallback() {
|
|
61
63
|
return false;
|
|
@@ -12,8 +12,7 @@ import { default as qs_2 } from 'qs';
|
|
|
12
12
|
import type { SearchParameters } from 'algoliasearch-helper';
|
|
13
13
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
14
14
|
|
|
15
|
-
declare type AlgoliaHit = {
|
|
16
|
-
[attribute: string]: any;
|
|
15
|
+
declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
|
|
17
16
|
objectID: string;
|
|
18
17
|
_highlightResult?: HitHighlightResult;
|
|
19
18
|
_snippetResult?: HitSnippetResult;
|
|
@@ -36,7 +35,7 @@ declare type AlgoliaHit = {
|
|
|
36
35
|
};
|
|
37
36
|
_distinctSeqID?: number;
|
|
38
37
|
_geoLoc?: GeoLoc;
|
|
39
|
-
};
|
|
38
|
+
} & THit;
|
|
40
39
|
|
|
41
40
|
declare const analytics: AnalyticsWidget;
|
|
42
41
|
|
|
@@ -292,6 +291,8 @@ declare type AutocompleteWidgetDescription = {
|
|
|
292
291
|
};
|
|
293
292
|
};
|
|
294
293
|
|
|
294
|
+
declare type BaseHit = Record<string, unknown>;
|
|
295
|
+
|
|
295
296
|
declare type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits;
|
|
296
297
|
|
|
297
298
|
declare type Bounds = {
|
|
@@ -466,6 +467,17 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
466
467
|
* It needs to avoid pushing state to history in case of back/forward in browser
|
|
467
468
|
*/
|
|
468
469
|
private shouldPushState;
|
|
470
|
+
/**
|
|
471
|
+
* Indicates whether the history router is disposed or not.
|
|
472
|
+
*/
|
|
473
|
+
private isDisposed;
|
|
474
|
+
/**
|
|
475
|
+
* Indicates the window.history.length before the last call to
|
|
476
|
+
* window.history.pushState (called in `write`).
|
|
477
|
+
* It allows to determine if a `pushState` has been triggered elsewhere,
|
|
478
|
+
* and thus to prevent the `write` method from calling `pushState`.
|
|
479
|
+
*/
|
|
480
|
+
private latestAcknowledgedHistory;
|
|
469
481
|
/**
|
|
470
482
|
* Initializes a new storage provider that syncs the search state to the URL
|
|
471
483
|
* using web APIs (`window.location.pushState` and `onpopstate` event).
|
|
@@ -723,11 +735,11 @@ declare const connectHits: HitsConnector;
|
|
|
723
735
|
|
|
724
736
|
declare const connectHitsPerPage: HitsPerPageConnector;
|
|
725
737
|
|
|
726
|
-
declare const connectHitsWithInsights: HitsConnector
|
|
738
|
+
declare const connectHitsWithInsights: HitsConnector<BaseHit>;
|
|
727
739
|
|
|
728
740
|
declare const connectInfiniteHits: InfiniteHitsConnector;
|
|
729
741
|
|
|
730
|
-
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector
|
|
742
|
+
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector<BaseHit>;
|
|
731
743
|
|
|
732
744
|
/**
|
|
733
745
|
* **Menu** connector provides the logic to build a widget that will give the user the ability to choose a single value for a specific facet. The typical usage of menu is for navigation in categories.
|
|
@@ -1749,10 +1761,10 @@ declare type HighlightOptions = {
|
|
|
1749
1761
|
|
|
1750
1762
|
declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
|
|
1751
1763
|
|
|
1752
|
-
declare type Hit = {
|
|
1764
|
+
declare type Hit<THit extends BaseHit = Record<string, any>> = {
|
|
1753
1765
|
__position: number;
|
|
1754
1766
|
__queryID?: string;
|
|
1755
|
-
} & AlgoliaHit
|
|
1767
|
+
} & AlgoliaHit<THit>;
|
|
1756
1768
|
|
|
1757
1769
|
declare type HitAttributeHighlightResult = {
|
|
1758
1770
|
value: string;
|
|
@@ -1767,13 +1779,16 @@ declare type HitHighlightResult = {
|
|
|
1767
1779
|
[attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult;
|
|
1768
1780
|
};
|
|
1769
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* @deprecated use Hit[] directly instead
|
|
1784
|
+
*/
|
|
1770
1785
|
declare type Hits = Hit[];
|
|
1771
1786
|
|
|
1772
1787
|
declare const hits: HitsWidget;
|
|
1773
1788
|
|
|
1774
|
-
declare type HitsConnector = Connector<HitsWidgetDescription
|
|
1789
|
+
declare type HitsConnector<THit extends BaseHit = BaseHit> = Connector<HitsWidgetDescription<THit>, HitsConnectorParams<THit>>;
|
|
1775
1790
|
|
|
1776
|
-
declare type HitsConnectorParams = {
|
|
1791
|
+
declare type HitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
1777
1792
|
/**
|
|
1778
1793
|
* Whether to escape HTML tags from hits string values.
|
|
1779
1794
|
*
|
|
@@ -1783,7 +1798,7 @@ declare type HitsConnectorParams = {
|
|
|
1783
1798
|
/**
|
|
1784
1799
|
* Function to transform the items passed to the templates.
|
|
1785
1800
|
*/
|
|
1786
|
-
transformItems?: TransformItems<Hit
|
|
1801
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
1787
1802
|
};
|
|
1788
1803
|
|
|
1789
1804
|
declare type HitsCSSClasses = Partial<{
|
|
@@ -1912,15 +1927,15 @@ declare type HitsPerPageWidgetParams = {
|
|
|
1912
1927
|
cssClasses?: HitsPerPageCSSClasses;
|
|
1913
1928
|
};
|
|
1914
1929
|
|
|
1915
|
-
declare type HitsRenderState = {
|
|
1930
|
+
declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
1916
1931
|
/**
|
|
1917
1932
|
* The matched hits from Algolia API.
|
|
1918
1933
|
*/
|
|
1919
|
-
hits:
|
|
1934
|
+
hits: Array<Hit<THit>>;
|
|
1920
1935
|
/**
|
|
1921
1936
|
* The response from the Algolia API.
|
|
1922
1937
|
*/
|
|
1923
|
-
results?: SearchResults<Hit
|
|
1938
|
+
results?: SearchResults<Hit<THit>>;
|
|
1924
1939
|
/**
|
|
1925
1940
|
* Sends an event to the Insights middleware.
|
|
1926
1941
|
*/
|
|
@@ -1952,11 +1967,11 @@ declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
|
|
|
1952
1967
|
$$widgetType: 'ais.hits';
|
|
1953
1968
|
}, HitsConnectorParams, HitsWidgetParams>;
|
|
1954
1969
|
|
|
1955
|
-
declare type HitsWidgetDescription = {
|
|
1970
|
+
declare type HitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
1956
1971
|
$$type: 'ais.hits';
|
|
1957
|
-
renderState: HitsRenderState
|
|
1972
|
+
renderState: HitsRenderState<THit>;
|
|
1958
1973
|
indexRenderState: {
|
|
1959
|
-
hits: WidgetRenderState<HitsRenderState
|
|
1974
|
+
hits: WidgetRenderState<HitsRenderState<THit>, HitsConnectorParams<THit>>;
|
|
1960
1975
|
};
|
|
1961
1976
|
};
|
|
1962
1977
|
|
|
@@ -2037,18 +2052,18 @@ declare type IndexWidgetParams = {
|
|
|
2037
2052
|
|
|
2038
2053
|
declare const infiniteHits: InfiniteHitsWidget;
|
|
2039
2054
|
|
|
2040
|
-
declare type InfiniteHitsCache = {
|
|
2041
|
-
read: Read
|
|
2042
|
-
write: Write
|
|
2055
|
+
declare type InfiniteHitsCache<THit extends BaseHit = BaseHit> = {
|
|
2056
|
+
read: Read<THit>;
|
|
2057
|
+
write: Write<THit>;
|
|
2043
2058
|
};
|
|
2044
2059
|
|
|
2045
|
-
declare type InfiniteHitsCachedHits = {
|
|
2046
|
-
[page: number]:
|
|
2060
|
+
declare type InfiniteHitsCachedHits<THit extends BaseHit> = {
|
|
2061
|
+
[page: number]: Array<Hit<THit>>;
|
|
2047
2062
|
};
|
|
2048
2063
|
|
|
2049
|
-
declare type InfiniteHitsConnector = Connector<InfiniteHitsWidgetDescription
|
|
2064
|
+
declare type InfiniteHitsConnector<THit extends BaseHit = BaseHit> = Connector<InfiniteHitsWidgetDescription<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2050
2065
|
|
|
2051
|
-
declare type InfiniteHitsConnectorParams = {
|
|
2066
|
+
declare type InfiniteHitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
2052
2067
|
/**
|
|
2053
2068
|
* Escapes HTML entities from hits string values.
|
|
2054
2069
|
*
|
|
@@ -2065,13 +2080,13 @@ declare type InfiniteHitsConnectorParams = {
|
|
|
2065
2080
|
* Receives the items, and is called before displaying them.
|
|
2066
2081
|
* Useful for mapping over the items to transform, and remove or reorder them.
|
|
2067
2082
|
*/
|
|
2068
|
-
transformItems?: TransformItems<Hit
|
|
2083
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
2069
2084
|
/**
|
|
2070
2085
|
* Reads and writes hits from/to cache.
|
|
2071
2086
|
* When user comes back to the search page after leaving for product page,
|
|
2072
2087
|
* this helps restore InfiniteHits and its scroll position.
|
|
2073
2088
|
*/
|
|
2074
|
-
cache?: InfiniteHitsCache
|
|
2089
|
+
cache?: InfiniteHitsCache<THit>;
|
|
2075
2090
|
};
|
|
2076
2091
|
|
|
2077
2092
|
declare type InfiniteHitsCSSClasses = Partial<{
|
|
@@ -2109,7 +2124,7 @@ declare type InfiniteHitsCSSClasses = Partial<{
|
|
|
2109
2124
|
disabledLoadMore: string | string[];
|
|
2110
2125
|
}>;
|
|
2111
2126
|
|
|
2112
|
-
declare type InfiniteHitsRenderState = {
|
|
2127
|
+
declare type InfiniteHitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
2113
2128
|
/**
|
|
2114
2129
|
* Loads the previous results.
|
|
2115
2130
|
*/
|
|
@@ -2137,15 +2152,15 @@ declare type InfiniteHitsRenderState = {
|
|
|
2137
2152
|
/**
|
|
2138
2153
|
* Hits for the current page
|
|
2139
2154
|
*/
|
|
2140
|
-
currentPageHits:
|
|
2155
|
+
currentPageHits: Array<Hit<THit>>;
|
|
2141
2156
|
/**
|
|
2142
2157
|
* Hits for current and cached pages
|
|
2143
2158
|
*/
|
|
2144
|
-
hits:
|
|
2159
|
+
hits: Array<Hit<THit>>;
|
|
2145
2160
|
/**
|
|
2146
2161
|
* The response from the Algolia API.
|
|
2147
2162
|
*/
|
|
2148
|
-
results?: SearchResults<Hit
|
|
2163
|
+
results?: SearchResults<Hit<THit>>;
|
|
2149
2164
|
};
|
|
2150
2165
|
|
|
2151
2166
|
declare type InfiniteHitsTemplates = Partial<{
|
|
@@ -2175,11 +2190,11 @@ declare type InfiniteHitsWidget = WidgetFactory<InfiniteHitsWidgetDescription &
|
|
|
2175
2190
|
$$widgetType: 'ais.infiniteHits';
|
|
2176
2191
|
}, InfiniteHitsConnectorParams, InfiniteHitsWidgetParams>;
|
|
2177
2192
|
|
|
2178
|
-
declare type InfiniteHitsWidgetDescription = {
|
|
2193
|
+
declare type InfiniteHitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
2179
2194
|
$$type: 'ais.infiniteHits';
|
|
2180
|
-
renderState: InfiniteHitsRenderState
|
|
2195
|
+
renderState: InfiniteHitsRenderState<THit>;
|
|
2181
2196
|
indexRenderState: {
|
|
2182
|
-
infiniteHits: WidgetRenderState<InfiniteHitsRenderState
|
|
2197
|
+
infiniteHits: WidgetRenderState<InfiniteHitsRenderState<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2183
2198
|
};
|
|
2184
2199
|
indexUiState: {
|
|
2185
2200
|
page: number;
|
|
@@ -3796,9 +3811,9 @@ declare type RatingMenuWidgetParams = {
|
|
|
3796
3811
|
cssClasses?: RatingMenuCSSClasses;
|
|
3797
3812
|
};
|
|
3798
3813
|
|
|
3799
|
-
declare type Read = ({ state, }: {
|
|
3814
|
+
declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
3800
3815
|
state: PlainSearchParameters;
|
|
3801
|
-
}) => InfiniteHitsCachedHits | null;
|
|
3816
|
+
}) => InfiniteHitsCachedHits<THit> | null;
|
|
3802
3817
|
|
|
3803
3818
|
declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
3804
3819
|
|
|
@@ -5240,9 +5255,9 @@ declare type WidgetType<TWidgetDescription extends WidgetDescription> = TWidgetD
|
|
|
5240
5255
|
|
|
5241
5256
|
declare type WidgetUiStates = PlacesWidgetDescription['indexUiState'];
|
|
5242
5257
|
|
|
5243
|
-
declare type Write = ({ state, hits, }: {
|
|
5258
|
+
declare type Write<THit extends BaseHit> = ({ state, hits, }: {
|
|
5244
5259
|
state: PlainSearchParameters;
|
|
5245
|
-
hits: InfiniteHitsCachedHits
|
|
5260
|
+
hits: InfiniteHitsCachedHits<THit>;
|
|
5246
5261
|
}) => void;
|
|
5247
5262
|
|
|
5248
5263
|
export { }
|