instantsearch.js 4.72.2 → 4.73.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/components/InfiniteHits/InfiniteHits.js +62 -19
- package/cjs/components/Template/Template.js +1 -1
- package/cjs/connectors/pagination/Paginator.js +2 -2
- package/cjs/lib/utils/getAppIdAndApiKey.js +4 -4
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createInsightsMiddleware.js +1 -1
- package/cjs/widgets/infinite-hits/infinite-hits.js +14 -3
- package/dist/instantsearch.development.d.ts +19 -0
- package/dist/instantsearch.development.js +92 -34
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +19 -0
- package/dist/instantsearch.production.min.d.ts +19 -0
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/InfiniteHits/InfiniteHits.d.ts +4 -3
- package/es/components/InfiniteHits/InfiniteHits.js +62 -19
- package/es/components/Template/Template.js +1 -1
- package/es/connectors/pagination/Paginator.js +2 -2
- package/es/lib/utils/getAppIdAndApiKey.js +4 -4
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/middlewares/createInsightsMiddleware.js +1 -1
- package/es/widgets/infinite-hits/infinite-hits.d.ts +19 -0
- package/es/widgets/infinite-hits/infinite-hits.js +14 -3
- package/package.json +7 -7
|
@@ -3,9 +3,9 @@ import { h } from 'preact';
|
|
|
3
3
|
import type { SendEventForHits, BindEventForHits } from '../../lib/utils';
|
|
4
4
|
import type { ComponentCSSClasses, Hit, InsightsClient } from '../../types';
|
|
5
5
|
import type { InfiniteHitsCSSClasses, InfiniteHitsTemplates } from '../../widgets/infinite-hits/infinite-hits';
|
|
6
|
-
import type { SearchResults } from 'algoliasearch-helper';
|
|
6
|
+
import type { Banner, SearchResults } from 'algoliasearch-helper';
|
|
7
7
|
export type InfiniteHitsComponentCSSClasses = ComponentCSSClasses<InfiniteHitsCSSClasses>;
|
|
8
|
-
export type InfiniteHitsComponentTemplates =
|
|
8
|
+
export type InfiniteHitsComponentTemplates = InfiniteHitsTemplates;
|
|
9
9
|
export type InfiniteHitsProps = {
|
|
10
10
|
cssClasses: InfiniteHitsComponentCSSClasses;
|
|
11
11
|
hits: Hit[];
|
|
@@ -22,6 +22,7 @@ export type InfiniteHitsProps = {
|
|
|
22
22
|
insights?: InsightsClient;
|
|
23
23
|
sendEvent: SendEventForHits;
|
|
24
24
|
bindEvent: BindEventForHits;
|
|
25
|
+
banner?: Banner;
|
|
25
26
|
};
|
|
26
|
-
declare const InfiniteHits: ({ results, hits, insights, bindEvent, sendEvent, hasShowPrevious, showPrevious, showMore, isFirstPage, isLastPage, cssClasses, templateProps, }: InfiniteHitsProps) => h.JSX.Element;
|
|
27
|
+
declare const InfiniteHits: ({ results, hits, insights, bindEvent, sendEvent, hasShowPrevious, showPrevious, showMore, isFirstPage, isLastPage, cssClasses, templateProps, banner, }: InfiniteHitsProps) => h.JSX.Element;
|
|
27
28
|
export default InfiniteHits;
|
|
@@ -10,32 +10,65 @@ import { h } from 'preact';
|
|
|
10
10
|
import { createInsightsEventHandler } from "../../lib/insights/listener.js";
|
|
11
11
|
import { warning } from "../../lib/utils/index.js";
|
|
12
12
|
import Template from "../Template/Template.js";
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
var DefaultBanner = function DefaultBanner(_ref) {
|
|
14
|
+
var banner = _ref.banner,
|
|
15
|
+
classNames = _ref.classNames;
|
|
16
|
+
if (!banner.image.urls[0].url) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
return h("aside", {
|
|
20
|
+
className: cx(classNames.bannerRoot)
|
|
21
|
+
}, banner.link ? h("a", {
|
|
22
|
+
className: cx(classNames.bannerLink),
|
|
23
|
+
href: banner.link.url,
|
|
24
|
+
target: banner.link.target
|
|
25
|
+
}, h("img", {
|
|
26
|
+
className: cx(classNames.bannerImage),
|
|
27
|
+
src: banner.image.urls[0].url,
|
|
28
|
+
alt: banner.image.title
|
|
29
|
+
})) : h("img", {
|
|
30
|
+
className: cx(classNames.bannerImage),
|
|
31
|
+
src: banner.image.urls[0].url,
|
|
32
|
+
alt: banner.image.title
|
|
33
|
+
}));
|
|
34
|
+
};
|
|
35
|
+
var InfiniteHits = function InfiniteHits(_ref2) {
|
|
36
|
+
var results = _ref2.results,
|
|
37
|
+
hits = _ref2.hits,
|
|
38
|
+
insights = _ref2.insights,
|
|
39
|
+
bindEvent = _ref2.bindEvent,
|
|
40
|
+
sendEvent = _ref2.sendEvent,
|
|
41
|
+
hasShowPrevious = _ref2.hasShowPrevious,
|
|
42
|
+
showPrevious = _ref2.showPrevious,
|
|
43
|
+
showMore = _ref2.showMore,
|
|
44
|
+
isFirstPage = _ref2.isFirstPage,
|
|
45
|
+
isLastPage = _ref2.isLastPage,
|
|
46
|
+
cssClasses = _ref2.cssClasses,
|
|
47
|
+
templateProps = _ref2.templateProps,
|
|
48
|
+
banner = _ref2.banner;
|
|
26
49
|
var handleInsightsClick = createInsightsEventHandler({
|
|
27
50
|
insights: insights,
|
|
28
51
|
sendEvent: sendEvent
|
|
29
52
|
});
|
|
30
53
|
if (results.hits.length === 0) {
|
|
31
|
-
return h(
|
|
54
|
+
return h("div", {
|
|
55
|
+
className: cx(cssClasses.root, cssClasses.emptyRoot),
|
|
56
|
+
onClick: handleInsightsClick
|
|
57
|
+
}, banner && (templateProps.templates.banner ? h(Template, _extends({}, templateProps, {
|
|
58
|
+
templateKey: "banner",
|
|
59
|
+
rootTagName: "fragment",
|
|
60
|
+
data: {
|
|
61
|
+
banner: banner,
|
|
62
|
+
className: cssClasses.bannerRoot
|
|
63
|
+
}
|
|
64
|
+
})) : h(DefaultBanner, {
|
|
65
|
+
banner: banner,
|
|
66
|
+
classNames: cssClasses
|
|
67
|
+
})), h(Template, _extends({}, templateProps, {
|
|
32
68
|
templateKey: "empty",
|
|
33
|
-
|
|
34
|
-
className: cx(cssClasses.root, cssClasses.emptyRoot),
|
|
35
|
-
onClick: handleInsightsClick
|
|
36
|
-
},
|
|
69
|
+
rootTagName: "fragment",
|
|
37
70
|
data: results
|
|
38
|
-
}));
|
|
71
|
+
})));
|
|
39
72
|
}
|
|
40
73
|
return h("div", {
|
|
41
74
|
className: cssClasses.root
|
|
@@ -47,6 +80,16 @@ var InfiniteHits = function InfiniteHits(_ref) {
|
|
|
47
80
|
disabled: isFirstPage,
|
|
48
81
|
onClick: showPrevious
|
|
49
82
|
}
|
|
83
|
+
})), banner && (templateProps.templates.banner ? h(Template, _extends({}, templateProps, {
|
|
84
|
+
templateKey: "banner",
|
|
85
|
+
rootTagName: "fragment",
|
|
86
|
+
data: {
|
|
87
|
+
banner: banner,
|
|
88
|
+
className: cssClasses.bannerRoot
|
|
89
|
+
}
|
|
90
|
+
})) : h(DefaultBanner, {
|
|
91
|
+
banner: banner,
|
|
92
|
+
classNames: cssClasses
|
|
50
93
|
})), h("ol", {
|
|
51
94
|
className: cssClasses.list
|
|
52
95
|
}, hits.map(function (hit, index) {
|
|
@@ -57,12 +57,12 @@ var Paginator = /*#__PURE__*/function () {
|
|
|
57
57
|
}, {
|
|
58
58
|
key: "isLastPage",
|
|
59
59
|
value: function isLastPage() {
|
|
60
|
-
return this.currentPage
|
|
60
|
+
return this.currentPage >= this.total - 1;
|
|
61
61
|
}
|
|
62
62
|
}, {
|
|
63
63
|
key: "isFirstPage",
|
|
64
64
|
value: function isFirstPage() {
|
|
65
|
-
return this.currentPage
|
|
65
|
+
return this.currentPage <= 0;
|
|
66
66
|
}
|
|
67
67
|
}]);
|
|
68
68
|
return Paginator;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// typed as any, since it accepts the _real_ js clients, not the interface we otherwise expect
|
|
2
2
|
export function getAppIdAndApiKey(searchClient) {
|
|
3
3
|
if (searchClient.transporter) {
|
|
4
|
-
// searchClient v4
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
// searchClient v4 or v5
|
|
5
|
+
var transporter = searchClient.transporter;
|
|
6
|
+
var headers = transporter.headers || transporter.baseHeaders;
|
|
7
|
+
var queryParameters = transporter.queryParameters || transporter.baseQueryParameters;
|
|
8
8
|
var APP_ID = 'x-algolia-application-id';
|
|
9
9
|
var API_KEY = 'x-algolia-api-key';
|
|
10
10
|
var appId = headers[APP_ID] || queryParameters[APP_ID];
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.73.1";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.73.1';
|
|
@@ -16,7 +16,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
|
|
|
16
16
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
17
17
|
import { getInsightsAnonymousUserTokenInternal } from "../helpers/index.js";
|
|
18
18
|
import { warning, noop, getAppIdAndApiKey, find, safelyRunOnBrowser } from "../lib/utils/index.js";
|
|
19
|
-
var ALGOLIA_INSIGHTS_VERSION = '2.
|
|
19
|
+
var ALGOLIA_INSIGHTS_VERSION = '2.15.0';
|
|
20
20
|
var ALGOLIA_INSIGHTS_SRC = "https://cdn.jsdelivr.net/npm/search-insights@".concat(ALGOLIA_INSIGHTS_VERSION, "/dist/search-insights.min.js");
|
|
21
21
|
export function createInsightsMiddleware() {
|
|
22
22
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
@@ -35,6 +35,18 @@ export type InfiniteHitsCSSClasses = Partial<{
|
|
|
35
35
|
* The disabled “Show more” button.
|
|
36
36
|
*/
|
|
37
37
|
disabledLoadMore: string | string[];
|
|
38
|
+
/**
|
|
39
|
+
* Class names to apply to the banner element
|
|
40
|
+
*/
|
|
41
|
+
bannerRoot: string | string[];
|
|
42
|
+
/**
|
|
43
|
+
* Class names to apply to the banner image element
|
|
44
|
+
*/
|
|
45
|
+
bannerImage: string | string[];
|
|
46
|
+
/**
|
|
47
|
+
* Class names to apply to the banner link element
|
|
48
|
+
*/
|
|
49
|
+
bannerLink: string | string[];
|
|
38
50
|
}>;
|
|
39
51
|
export type InfiniteHitsTemplates<THit extends NonNullable<object> = BaseHit> = Partial<{
|
|
40
52
|
/**
|
|
@@ -56,6 +68,13 @@ export type InfiniteHitsTemplates<THit extends NonNullable<object> = BaseHit> =
|
|
|
56
68
|
/** @deprecated the index in the hits array, use __position instead, which is the absolute position */
|
|
57
69
|
__hitIndex: number;
|
|
58
70
|
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Template to use for the banner.
|
|
73
|
+
*/
|
|
74
|
+
banner: Template<{
|
|
75
|
+
banner: Required<InfiniteHitsRenderState['banner']>;
|
|
76
|
+
className: string;
|
|
77
|
+
}>;
|
|
59
78
|
}>;
|
|
60
79
|
export type InfiniteHitsWidgetParams<THit extends NonNullable<object> = BaseHit> = {
|
|
61
80
|
/**
|
|
@@ -33,7 +33,8 @@ var renderer = function renderer(_ref) {
|
|
|
33
33
|
instantSearchInstance = _ref2.instantSearchInstance,
|
|
34
34
|
insights = _ref2.insights,
|
|
35
35
|
bindEvent = _ref2.bindEvent,
|
|
36
|
-
sendEvent = _ref2.sendEvent
|
|
36
|
+
sendEvent = _ref2.sendEvent,
|
|
37
|
+
banner = _ref2.banner;
|
|
37
38
|
if (isFirstRendering) {
|
|
38
39
|
renderState.templateProps = prepareTemplateProps({
|
|
39
40
|
defaultTemplates: defaultTemplates,
|
|
@@ -54,7 +55,8 @@ var renderer = function renderer(_ref) {
|
|
|
54
55
|
isLastPage: isLastPage,
|
|
55
56
|
insights: insights,
|
|
56
57
|
sendEvent: sendEvent,
|
|
57
|
-
bindEvent: bindEvent
|
|
58
|
+
bindEvent: bindEvent,
|
|
59
|
+
banner: banner
|
|
58
60
|
}), containerNode);
|
|
59
61
|
};
|
|
60
62
|
};
|
|
@@ -97,7 +99,16 @@ export default (function infiniteHits(widgetParams) {
|
|
|
97
99
|
disabledLoadMore: cx(suit({
|
|
98
100
|
descendantName: 'loadMore',
|
|
99
101
|
modifierName: 'disabled'
|
|
100
|
-
}), userCssClasses.disabledLoadMore)
|
|
102
|
+
}), userCssClasses.disabledLoadMore),
|
|
103
|
+
bannerRoot: cx(suit({
|
|
104
|
+
descendantName: 'banner'
|
|
105
|
+
}), userCssClasses.bannerRoot),
|
|
106
|
+
bannerImage: cx(suit({
|
|
107
|
+
descendantName: 'banner-image'
|
|
108
|
+
}), userCssClasses.bannerImage),
|
|
109
|
+
bannerLink: cx(suit({
|
|
110
|
+
descendantName: 'banner-link'
|
|
111
|
+
}), userCssClasses.bannerLink)
|
|
101
112
|
};
|
|
102
113
|
var specializedRenderer = renderer({
|
|
103
114
|
containerNode: containerNode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.73.1",
|
|
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",
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"@types/google.maps": "^3.45.3",
|
|
32
32
|
"@types/hogan.js": "^3.0.0",
|
|
33
33
|
"@types/qs": "^6.5.3",
|
|
34
|
-
"algoliasearch-helper": "3.22.
|
|
34
|
+
"algoliasearch-helper": "3.22.2",
|
|
35
35
|
"hogan.js": "^3.0.2",
|
|
36
36
|
"htm": "^3.0.0",
|
|
37
37
|
"instantsearch-ui-components": "0.7.0",
|
|
38
38
|
"preact": "^10.10.0",
|
|
39
39
|
"qs": "^6.5.1 < 6.10",
|
|
40
|
-
"search-insights": "^2.
|
|
40
|
+
"search-insights": "^2.15.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"algoliasearch": ">= 3.1 < 6"
|
|
@@ -56,9 +56,9 @@
|
|
|
56
56
|
"watch:es": "yarn --silent build:es:base --watch"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
|
-
"@instantsearch/mocks": "1.
|
|
60
|
-
"@instantsearch/tests": "1.
|
|
61
|
-
"@instantsearch/testutils": "1.
|
|
59
|
+
"@instantsearch/mocks": "1.51.0",
|
|
60
|
+
"@instantsearch/tests": "1.51.0",
|
|
61
|
+
"@instantsearch/testutils": "1.40.0",
|
|
62
62
|
"@storybook/html": "5.3.9",
|
|
63
63
|
"@types/scriptjs": "0.0.2",
|
|
64
64
|
"algoliasearch": "4.23.2",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"scriptjs": "2.5.9",
|
|
67
67
|
"webpack": "4.47.0"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "45dae35640d80a10e371990d653be2ec65e35ed8"
|
|
70
70
|
}
|