instantsearch.js 4.38.1 → 4.39.2
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/version.js +1 -1
- package/dist/instantsearch.development.d.ts +46 -40
- package/dist/instantsearch.development.js +6 -5
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +46 -40
- package/dist/instantsearch.production.min.d.ts +46 -40
- 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/hierarchical-menu/connectHierarchicalMenu.d.ts +2 -1
- 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/connectors/menu/connectMenu.d.ts +2 -1
- package/es/connectors/refinement-list/connectRefinementList.d.ts +2 -1
- 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/types/results.d.ts +8 -5
- package/es/types/widget.d.ts +2 -1
- package/package.json +3 -3
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @jest-environment jsdom
|
|
5
|
+
*/
|
|
6
|
+
|
|
3
7
|
/** @jsx h */
|
|
4
8
|
import { h } from 'preact';
|
|
5
9
|
import Template from "../Template/Template.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SendEventForFacet } from '../../lib/utils';
|
|
2
|
+
import type { SearchResults } from 'algoliasearch-helper';
|
|
2
3
|
import type { Connector, CreateURL, TransformItems, SortBy, WidgetRenderState } from '../../types';
|
|
3
4
|
export declare type HierarchicalMenuItem = {
|
|
4
5
|
/**
|
|
@@ -58,7 +59,7 @@ export declare type HierarchicalMenuConnectorParams = {
|
|
|
58
59
|
*
|
|
59
60
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
60
61
|
*/
|
|
61
|
-
sortBy?: SortBy<
|
|
62
|
+
sortBy?: SortBy<SearchResults.HierarchicalFacet>;
|
|
62
63
|
/**
|
|
63
64
|
* Function to transform the items passed to the templates.
|
|
64
65
|
*/
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { SendEventForHits, BindEventForHits } from '../../lib/utils';
|
|
2
|
-
import type { TransformItems, Connector,
|
|
2
|
+
import type { TransformItems, Connector, Hit, WidgetRenderState, BaseHit } from '../../types';
|
|
3
3
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
4
|
-
export declare type HitsRenderState = {
|
|
4
|
+
export declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
5
5
|
/**
|
|
6
6
|
* The matched hits from Algolia API.
|
|
7
7
|
*/
|
|
8
|
-
hits:
|
|
8
|
+
hits: Array<Hit<THit>>;
|
|
9
9
|
/**
|
|
10
10
|
* The response from the Algolia API.
|
|
11
11
|
*/
|
|
12
|
-
results?: SearchResults<Hit
|
|
12
|
+
results?: SearchResults<Hit<THit>>;
|
|
13
13
|
/**
|
|
14
14
|
* Sends an event to the Insights middleware.
|
|
15
15
|
*/
|
|
@@ -19,7 +19,7 @@ export declare type HitsRenderState = {
|
|
|
19
19
|
*/
|
|
20
20
|
bindEvent: BindEventForHits;
|
|
21
21
|
};
|
|
22
|
-
export declare type HitsConnectorParams = {
|
|
22
|
+
export declare type HitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
23
23
|
/**
|
|
24
24
|
* Whether to escape HTML tags from hits string values.
|
|
25
25
|
*
|
|
@@ -29,15 +29,15 @@ export declare type HitsConnectorParams = {
|
|
|
29
29
|
/**
|
|
30
30
|
* Function to transform the items passed to the templates.
|
|
31
31
|
*/
|
|
32
|
-
transformItems?: TransformItems<Hit
|
|
32
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
33
33
|
};
|
|
34
|
-
export declare type HitsWidgetDescription = {
|
|
34
|
+
export declare type HitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
35
35
|
$$type: 'ais.hits';
|
|
36
|
-
renderState: HitsRenderState
|
|
36
|
+
renderState: HitsRenderState<THit>;
|
|
37
37
|
indexRenderState: {
|
|
38
|
-
hits: WidgetRenderState<HitsRenderState
|
|
38
|
+
hits: WidgetRenderState<HitsRenderState<THit>, HitsConnectorParams<THit>>;
|
|
39
39
|
};
|
|
40
40
|
};
|
|
41
|
-
export declare type HitsConnector = Connector<HitsWidgetDescription
|
|
41
|
+
export declare type HitsConnector<THit extends BaseHit = BaseHit> = Connector<HitsWidgetDescription<THit>, HitsConnectorParams<THit>>;
|
|
42
42
|
declare const connectHits: HitsConnector;
|
|
43
43
|
export default connectHits;
|
|
@@ -33,10 +33,10 @@ var connectHits = function connectHits(renderFn) {
|
|
|
33
33
|
},
|
|
34
34
|
render: function render(renderOptions) {
|
|
35
35
|
var renderState = this.getWidgetRenderState(renderOptions);
|
|
36
|
-
renderState.sendEvent('view', renderState.hits);
|
|
37
36
|
renderFn(_objectSpread(_objectSpread({}, renderState), {}, {
|
|
38
37
|
instantSearchInstance: renderOptions.instantSearchInstance
|
|
39
38
|
}), false);
|
|
39
|
+
renderState.sendEvent('view', renderState.hits);
|
|
40
40
|
},
|
|
41
41
|
getRenderState: function getRenderState(renderState, renderOptions) {
|
|
42
42
|
return _objectSpread(_objectSpread({}, renderState), {}, {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const connectHitsWithInsights: import("./connectHits").HitsConnector
|
|
1
|
+
declare const connectHitsWithInsights: import("./connectHits").HitsConnector<import("../../types").BaseHit>;
|
|
2
2
|
export default connectHitsWithInsights;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import type { PlainSearchParameters, SearchResults } from 'algoliasearch-helper';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Connector, TransformItems, Hit, WidgetRenderState, BaseHit } from '../../types';
|
|
3
3
|
import type { SendEventForHits, BindEventForHits } from '../../lib/utils';
|
|
4
|
-
export declare type InfiniteHitsCachedHits = {
|
|
5
|
-
[page: number]:
|
|
4
|
+
export declare type InfiniteHitsCachedHits<THit extends BaseHit> = {
|
|
5
|
+
[page: number]: Array<Hit<THit>>;
|
|
6
6
|
};
|
|
7
|
-
declare type Read = ({ state, }: {
|
|
7
|
+
declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
8
8
|
state: PlainSearchParameters;
|
|
9
|
-
}) => InfiniteHitsCachedHits | null;
|
|
10
|
-
declare type Write = ({ state, hits, }: {
|
|
9
|
+
}) => InfiniteHitsCachedHits<THit> | null;
|
|
10
|
+
declare type Write<THit extends BaseHit> = ({ state, hits, }: {
|
|
11
11
|
state: PlainSearchParameters;
|
|
12
|
-
hits: InfiniteHitsCachedHits
|
|
12
|
+
hits: InfiniteHitsCachedHits<THit>;
|
|
13
13
|
}) => void;
|
|
14
|
-
export declare type InfiniteHitsCache = {
|
|
15
|
-
read: Read
|
|
16
|
-
write: Write
|
|
14
|
+
export declare type InfiniteHitsCache<THit extends BaseHit = BaseHit> = {
|
|
15
|
+
read: Read<THit>;
|
|
16
|
+
write: Write<THit>;
|
|
17
17
|
};
|
|
18
|
-
export declare type InfiniteHitsConnectorParams = {
|
|
18
|
+
export declare type InfiniteHitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
19
19
|
/**
|
|
20
20
|
* Escapes HTML entities from hits string values.
|
|
21
21
|
*
|
|
@@ -32,15 +32,15 @@ export declare type InfiniteHitsConnectorParams = {
|
|
|
32
32
|
* Receives the items, and is called before displaying them.
|
|
33
33
|
* Useful for mapping over the items to transform, and remove or reorder them.
|
|
34
34
|
*/
|
|
35
|
-
transformItems?: TransformItems<Hit
|
|
35
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
36
36
|
/**
|
|
37
37
|
* Reads and writes hits from/to cache.
|
|
38
38
|
* When user comes back to the search page after leaving for product page,
|
|
39
39
|
* this helps restore InfiniteHits and its scroll position.
|
|
40
40
|
*/
|
|
41
|
-
cache?: InfiniteHitsCache
|
|
41
|
+
cache?: InfiniteHitsCache<THit>;
|
|
42
42
|
};
|
|
43
|
-
export declare type InfiniteHitsRenderState = {
|
|
43
|
+
export declare type InfiniteHitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
44
44
|
/**
|
|
45
45
|
* Loads the previous results.
|
|
46
46
|
*/
|
|
@@ -68,26 +68,26 @@ export declare type InfiniteHitsRenderState = {
|
|
|
68
68
|
/**
|
|
69
69
|
* Hits for the current page
|
|
70
70
|
*/
|
|
71
|
-
currentPageHits:
|
|
71
|
+
currentPageHits: Array<Hit<THit>>;
|
|
72
72
|
/**
|
|
73
73
|
* Hits for current and cached pages
|
|
74
74
|
*/
|
|
75
|
-
hits:
|
|
75
|
+
hits: Array<Hit<THit>>;
|
|
76
76
|
/**
|
|
77
77
|
* The response from the Algolia API.
|
|
78
78
|
*/
|
|
79
|
-
results?: SearchResults<Hit
|
|
79
|
+
results?: SearchResults<Hit<THit>>;
|
|
80
80
|
};
|
|
81
|
-
export declare type InfiniteHitsWidgetDescription = {
|
|
81
|
+
export declare type InfiniteHitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
82
82
|
$$type: 'ais.infiniteHits';
|
|
83
|
-
renderState: InfiniteHitsRenderState
|
|
83
|
+
renderState: InfiniteHitsRenderState<THit>;
|
|
84
84
|
indexRenderState: {
|
|
85
|
-
infiniteHits: WidgetRenderState<InfiniteHitsRenderState
|
|
85
|
+
infiniteHits: WidgetRenderState<InfiniteHitsRenderState<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
86
86
|
};
|
|
87
87
|
indexUiState: {
|
|
88
88
|
page: number;
|
|
89
89
|
};
|
|
90
90
|
};
|
|
91
|
-
export declare type InfiniteHitsConnector = Connector<InfiniteHitsWidgetDescription
|
|
91
|
+
export declare type InfiniteHitsConnector<THit extends BaseHit = BaseHit> = Connector<InfiniteHitsWidgetDescription<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
92
92
|
declare const connectInfiniteHits: InfiniteHitsConnector;
|
|
93
93
|
export default connectInfiniteHits;
|
|
@@ -61,7 +61,8 @@ function extractHitsFromCachedHits(cachedHits) {
|
|
|
61
61
|
|
|
62
62
|
var connectInfiniteHits = function connectInfiniteHits(renderFn) {
|
|
63
63
|
var unmountFn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : noop;
|
|
64
|
-
checkRendering(renderFn, withUsage());
|
|
64
|
+
checkRendering(renderFn, withUsage()); // @TODO: this should be a generic, but a Connector can not yet be generic itself
|
|
65
|
+
|
|
65
66
|
return function (widgetParams) {
|
|
66
67
|
var _ref4 = widgetParams || {},
|
|
67
68
|
_ref4$escapeHTML = _ref4.escapeHTML,
|
|
@@ -132,10 +133,10 @@ var connectInfiniteHits = function connectInfiniteHits(renderFn) {
|
|
|
132
133
|
render: function render(renderOptions) {
|
|
133
134
|
var instantSearchInstance = renderOptions.instantSearchInstance;
|
|
134
135
|
var widgetRenderState = this.getWidgetRenderState(renderOptions);
|
|
135
|
-
sendEvent('view', widgetRenderState.currentPageHits);
|
|
136
136
|
renderFn(_objectSpread(_objectSpread({}, widgetRenderState), {}, {
|
|
137
137
|
instantSearchInstance: instantSearchInstance
|
|
138
138
|
}), false);
|
|
139
|
+
sendEvent('view', widgetRenderState.currentPageHits);
|
|
139
140
|
},
|
|
140
141
|
getRenderState: function getRenderState(renderState, renderOptions) {
|
|
141
142
|
return _objectSpread(_objectSpread({}, renderState), {}, {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const connectInfiniteHitsWithInsights: import("./connectInfiniteHits").InfiniteHitsConnector
|
|
1
|
+
declare const connectInfiniteHitsWithInsights: import("./connectInfiniteHits").InfiniteHitsConnector<import("../../types").BaseHit>;
|
|
2
2
|
export default connectInfiniteHitsWithInsights;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SearchResults } from 'algoliasearch-helper';
|
|
1
2
|
import type { SendEventForFacet } from '../../lib/utils';
|
|
2
3
|
import type { Connector, CreateURL, SortBy, TransformItems, WidgetRenderState } from '../../types';
|
|
3
4
|
export declare type MenuItem = {
|
|
@@ -42,7 +43,7 @@ export declare type MenuConnectorParams = {
|
|
|
42
43
|
*
|
|
43
44
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
44
45
|
*/
|
|
45
|
-
sortBy?: SortBy<
|
|
46
|
+
sortBy?: SortBy<SearchResults.HierarchicalFacet>;
|
|
46
47
|
/**
|
|
47
48
|
* Function to transform the items passed to the templates.
|
|
48
49
|
*/
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { SearchResults } from 'algoliasearch-helper';
|
|
1
2
|
import type { SendEventForFacet } from '../../lib/utils';
|
|
2
3
|
import type { Connector, TransformItems, SortBy, CreateURL, WidgetRenderState } from '../../types';
|
|
3
4
|
export declare type RefinementListItem = {
|
|
@@ -52,7 +53,7 @@ export declare type RefinementListConnectorParams = {
|
|
|
52
53
|
*
|
|
53
54
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
54
55
|
*/
|
|
55
|
-
sortBy?: SortBy<
|
|
56
|
+
sortBy?: SortBy<SearchResults.FacetValue>;
|
|
56
57
|
/**
|
|
57
58
|
* Escapes the content of the facet values.
|
|
58
59
|
*/
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jest-environment jsdom
|
|
3
|
+
*/
|
|
1
4
|
import type { InstantSearch, Hit, Hits } from '../../types';
|
|
2
5
|
declare type BuiltInSendEventForHits = (eventType: string, hits: Hit | Hits, eventName?: string) => void;
|
|
3
6
|
declare type CustomSendEventForHits = (customPayload: any) => void;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @jest-environment jsdom
|
|
5
|
+
*/
|
|
3
6
|
import { serializePayload } from "./serializer.js";
|
|
4
7
|
|
|
5
8
|
function chunk(arr) {
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.39.2";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.39.2';
|
package/es/types/results.d.ts
CHANGED
|
@@ -16,8 +16,7 @@ export declare type GeoLoc = {
|
|
|
16
16
|
lat: number;
|
|
17
17
|
lng: number;
|
|
18
18
|
};
|
|
19
|
-
export declare type AlgoliaHit = {
|
|
20
|
-
[attribute: string]: any;
|
|
19
|
+
export declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
|
|
21
20
|
objectID: string;
|
|
22
21
|
_highlightResult?: HitHighlightResult;
|
|
23
22
|
_snippetResult?: HitSnippetResult;
|
|
@@ -40,11 +39,15 @@ export declare type AlgoliaHit = {
|
|
|
40
39
|
};
|
|
41
40
|
_distinctSeqID?: number;
|
|
42
41
|
_geoLoc?: GeoLoc;
|
|
43
|
-
};
|
|
44
|
-
export declare type
|
|
42
|
+
} & THit;
|
|
43
|
+
export declare type BaseHit = Record<string, unknown>;
|
|
44
|
+
export declare type Hit<THit extends BaseHit = Record<string, any>> = {
|
|
45
45
|
__position: number;
|
|
46
46
|
__queryID?: string;
|
|
47
|
-
} & AlgoliaHit
|
|
47
|
+
} & AlgoliaHit<THit>;
|
|
48
|
+
/**
|
|
49
|
+
* @deprecated use Hit[] directly instead
|
|
50
|
+
*/
|
|
48
51
|
export declare type Hits = Hit[];
|
|
49
52
|
export declare type EscapedHits<THit = Hit> = THit[] & {
|
|
50
53
|
__escaped: boolean;
|
package/es/types/widget.d.ts
CHANGED
|
@@ -136,10 +136,11 @@ export declare type TransformItemsMetadata = {
|
|
|
136
136
|
* Transforms the given items.
|
|
137
137
|
*/
|
|
138
138
|
export declare type TransformItems<TItem, TMetadata = TransformItemsMetadata> = (items: TItem[], metadata: TMetadata) => TItem[];
|
|
139
|
+
declare type SortByDirection<TCriterion extends string> = TCriterion | `${TCriterion}:asc` | `${TCriterion}:desc`;
|
|
139
140
|
/**
|
|
140
141
|
* Transforms the given items.
|
|
141
142
|
*/
|
|
142
|
-
export declare type SortBy<TItem> = ((a: TItem, b: TItem) => number) | Array<'count' | '
|
|
143
|
+
export declare type SortBy<TItem> = ((a: TItem, b: TItem) => number) | Array<SortByDirection<'count' | 'name' | 'isRefined'>>;
|
|
143
144
|
/**
|
|
144
145
|
* Creates the URL for the given value.
|
|
145
146
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.39.2",
|
|
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",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"test": "jest",
|
|
40
40
|
"test:watch": "jest --watch --bail",
|
|
41
41
|
"test:e2e": "yarn test:e2e:local",
|
|
42
|
-
"test:e2e:local": "wdio wdio
|
|
43
|
-
"test:e2e:saucelabs": "wdio wdio
|
|
42
|
+
"test:e2e:local": "wdio scripts/wdio/local.conf.js",
|
|
43
|
+
"test:e2e:saucelabs": "wdio scripts/wdio/saucelabs.conf.js",
|
|
44
44
|
"test:size": "bundlesize",
|
|
45
45
|
"test:argos": "argos upload functional-tests/screenshots --token $ARGOS_TOKEN || true",
|
|
46
46
|
"test:exports": "node test/module/is-es-module.mjs",
|