instantsearch.js 4.71.1 → 4.72.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.
@@ -1,7 +1,6 @@
1
1
  import type { SendEventForHits, BindEventForHits } from '../../lib/utils';
2
2
  import type { TransformItems, Connector, Hit, WidgetRenderState, BaseHit, Unmounter, Renderer, IndexRenderState } from '../../types';
3
- import type { SearchResults } from 'algoliasearch-helper';
4
- type Banner = NonNullable<NonNullable<Required<SearchResults<Hit>['renderingContent']>>['widgets']['banners']>[number];
3
+ import type { Banner, SearchResults } from 'algoliasearch-helper';
5
4
  export type HitsRenderState<THit extends NonNullable<object> = BaseHit> = {
6
5
  /**
7
6
  * The matched hits from Algolia API.
@@ -110,18 +109,7 @@ declare const _default: <TWidgetParams>(renderFn: Renderer<HitsRenderState<BaseH
110
109
  hits: Hit<BaseHit>[] | Hit<THit>[];
111
110
  items: Hit<BaseHit>[] | Hit<THit>[];
112
111
  results: SearchResults<any>;
113
- banner: {
114
- image: {
115
- urls: {
116
- url: string;
117
- }[];
118
- title?: string | undefined;
119
- };
120
- link?: {
121
- url: string;
122
- target?: "_blank" | "_self" | undefined;
123
- } | undefined;
124
- } | undefined;
112
+ banner: Banner | undefined;
125
113
  sendEvent: SendEventForHits;
126
114
  bindEvent: BindEventForHits;
127
115
  widgetParams: TWidgetParams & HitsConnectorParams<THit>;
@@ -132,18 +132,7 @@ declare const connectHitsWithInsights: <TWidgetParams>(renderFn: import("../../t
132
132
  hits: import("../../types").Hit<import("../../types").BaseHit>[] | import("../../types").Hit<THit>[];
133
133
  items: import("../../types").Hit<import("../../types").BaseHit>[] | import("../../types").Hit<THit>[];
134
134
  results: import("algoliasearch-helper").SearchResults<any>;
135
- banner: {
136
- image: {
137
- urls: {
138
- url: string;
139
- }[];
140
- title?: string | undefined;
141
- };
142
- link?: {
143
- url: string;
144
- target?: "_blank" | "_self" | undefined;
145
- } | undefined;
146
- } | undefined;
135
+ banner: import("algoliasearch-helper").Banner | undefined;
147
136
  sendEvent: import("../../lib/utils").SendEventForHits;
148
137
  bindEvent: import("../../lib/utils").BindEventForHits;
149
138
  widgetParams: TWidgetParams & HitsConnectorParams<THit>;
@@ -1,6 +1,6 @@
1
1
  import type { SendEventForHits, BindEventForHits } from '../../lib/utils';
2
2
  import type { Connector, TransformItems, Hit, WidgetRenderState, BaseHit, Renderer, Unmounter, IndexRenderState } from '../../types';
3
- import type { AlgoliaSearchHelper as Helper, PlainSearchParameters, SearchParameters, SearchResults } from 'algoliasearch-helper';
3
+ import type { Banner, AlgoliaSearchHelper as Helper, PlainSearchParameters, SearchParameters, SearchResults } from 'algoliasearch-helper';
4
4
  export type InfiniteHitsCachedHits<THit extends NonNullable<object>> = {
5
5
  [page: number]: Array<Hit<THit>>;
6
6
  };
@@ -82,6 +82,10 @@ export type InfiniteHitsRenderState<THit extends NonNullable<object> = BaseHit>
82
82
  * The response from the Algolia API.
83
83
  */
84
84
  results?: SearchResults<Hit<THit>>;
85
+ /**
86
+ * The banner to display above the hits.
87
+ */
88
+ banner?: Banner;
85
89
  };
86
90
  export type InfiniteHitsWidgetDescription<THit extends NonNullable<object> = BaseHit> = {
87
91
  $$type: 'ais.infiniteHits';
@@ -149,6 +153,7 @@ declare const _default: <TWidgetParams extends object>(renderFn: Renderer<Infini
149
153
  currentPageHits: Hit<THit>[];
150
154
  sendEvent: SendEventForHits;
151
155
  bindEvent: BindEventForHits;
156
+ banner: Banner | undefined;
152
157
  results: SearchResults<any> | undefined;
153
158
  showPrevious: () => void;
154
159
  showMore: () => void;
@@ -133,6 +133,7 @@ export default (function connectInfiniteHits(renderFn) {
133
133
  });
134
134
  },
135
135
  getWidgetRenderState: function getWidgetRenderState(_ref6) {
136
+ var _results$renderingCon, _results$renderingCon2, _results$renderingCon3;
136
137
  var results = _ref6.results,
137
138
  helper = _ref6.helper,
138
139
  parent = _ref6.parent,
@@ -149,6 +150,7 @@ export default (function connectInfiniteHits(renderFn) {
149
150
  var cachedHits = cache.read({
150
151
  state: normalizeState(state)
151
152
  }) || {};
153
+ var banner = results === null || results === void 0 ? void 0 : (_results$renderingCon = results.renderingContent) === null || _results$renderingCon === void 0 ? void 0 : (_results$renderingCon2 = _results$renderingCon.widgets) === null || _results$renderingCon2 === void 0 ? void 0 : (_results$renderingCon3 = _results$renderingCon2.banners) === null || _results$renderingCon3 === void 0 ? void 0 : _results$renderingCon3[0];
152
154
  if (!results) {
153
155
  showPrevious = getShowPrevious(helper);
154
156
  showMore = getShowMore(helper);
@@ -213,6 +215,7 @@ export default (function connectInfiniteHits(renderFn) {
213
215
  currentPageHits: currentPageHits,
214
216
  sendEvent: sendEvent,
215
217
  bindEvent: bindEvent,
218
+ banner: banner,
216
219
  results: results,
217
220
  showPrevious: showPrevious,
218
221
  showMore: showMore,
@@ -126,6 +126,7 @@ declare const connectInfiniteHitsWithInsights: <TWidgetParams extends object>(re
126
126
  currentPageHits: import("../../types").Hit<THit>[];
127
127
  sendEvent: import("../../lib/utils").SendEventForHits;
128
128
  bindEvent: import("../../lib/utils").BindEventForHits;
129
+ banner: import("algoliasearch-helper").Banner | undefined;
129
130
  results: import("algoliasearch-helper").SearchResults<any> | undefined;
130
131
  showPrevious: () => void;
131
132
  showMore: () => void;
@@ -1,2 +1,2 @@
1
- declare const _default: "4.71.1";
1
+ declare const _default: "4.72.1";
2
2
  export default _default;
package/es/lib/version.js CHANGED
@@ -1 +1 @@
1
- export default '4.71.1';
1
+ export default '4.72.1';
@@ -6,7 +6,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
6
6
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
7
7
  import historyRouter from "../lib/routers/history.js";
8
8
  import simpleStateMapping from "../lib/stateMappings/simple.js";
9
- import { isEqual } from "../lib/utils/index.js";
9
+ import { isEqual, warning } from "../lib/utils/index.js";
10
10
  export var createRouterMiddleware = function createRouterMiddleware() {
11
11
  var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
12
12
  var _props$router = props.router,
@@ -50,6 +50,7 @@ export var createRouterMiddleware = function createRouterMiddleware() {
50
50
  }
51
51
  },
52
52
  subscribe: function subscribe() {
53
+ process.env.NODE_ENV === 'development' ? warning(Object.keys(initialUiState).length === 0, 'Using `initialUiState` together with routing is not recommended. The `initialUiState` will be overwritten by the URL parameters.') : void 0;
53
54
  instantSearchInstance._initialUiState = _objectSpread(_objectSpread({}, initialUiState), stateMapping.routeToState(router.read()));
54
55
  router.onUpdate(function (route) {
55
56
  if (instantSearchInstance.mainIndex.getWidgets().length > 0) {
@@ -170,11 +170,7 @@ declare const _default: <THit extends object = BaseHit>(widgetParams: HitsWidget
170
170
  getWidgetRenderState({ results, helper, instantSearchInstance }: import("../../types").InitOptions | import("../../types").RenderOptions): {
171
171
  hits: never[];
172
172
  items: never[];
173
- results: undefined; /**
174
- * Template to use for each result. This template will receive an object containing a single record.
175
- *
176
- * @default ''
177
- */
173
+ results: undefined;
178
174
  banner: undefined;
179
175
  sendEvent: import("../../lib/utils").SendEventForHits;
180
176
  bindEvent: import("../../lib/utils").BindEventForHits;
@@ -183,22 +179,11 @@ declare const _default: <THit extends object = BaseHit>(widgetParams: HitsWidget
183
179
  hits: Hit<BaseHit>[] | Hit<THit>[];
184
180
  items: Hit<BaseHit>[] | Hit<THit>[];
185
181
  results: SearchResults<any>;
182
+ banner: import("algoliasearch-helper").Banner | undefined;
183
+ sendEvent: import("../../lib/utils").SendEventForHits;
186
184
  /**
187
- * CSS classes to add.
185
+ * Templates to use for the widget.
188
186
  */
189
- banner: {
190
- image: {
191
- urls: {
192
- url: string;
193
- }[];
194
- title?: string | undefined;
195
- };
196
- link?: {
197
- url: string;
198
- target?: "_blank" | "_self" | undefined;
199
- } | undefined;
200
- } | undefined;
201
- sendEvent: import("../../lib/utils").SendEventForHits;
202
187
  bindEvent: import("../../lib/utils").BindEventForHits;
203
188
  widgetParams: Partial<HitsWidgetParams<BaseHit>> & HitsConnectorParams<THit>;
204
189
  };
@@ -213,6 +213,7 @@ declare const _default: <THit extends object = BaseHit>(widgetParams: InfiniteHi
213
213
  currentPageHits: Hit<THit>[];
214
214
  sendEvent: import("../../lib/utils").SendEventForHits;
215
215
  bindEvent: import("../../lib/utils").BindEventForHits;
216
+ banner: import("algoliasearch-helper").Banner | undefined;
216
217
  results: SearchResults<any> | undefined;
217
218
  showPrevious: () => void;
218
219
  showMore: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch.js",
3
- "version": "4.71.1",
3
+ "version": "4.72.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,10 +31,10 @@
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.21.0",
34
+ "algoliasearch-helper": "3.22.1",
35
35
  "hogan.js": "^3.0.2",
36
36
  "htm": "^3.0.0",
37
- "instantsearch-ui-components": "0.6.0",
37
+ "instantsearch-ui-components": "0.7.0",
38
38
  "preact": "^10.10.0",
39
39
  "qs": "^6.5.1 < 6.10",
40
40
  "search-insights": "^2.13.0"
@@ -56,9 +56,9 @@
56
56
  "watch:es": "yarn --silent build:es:base --watch"
57
57
  },
58
58
  "devDependencies": {
59
- "@instantsearch/mocks": "1.47.0",
60
- "@instantsearch/tests": "1.47.0",
61
- "@instantsearch/testutils": "1.36.0",
59
+ "@instantsearch/mocks": "1.49.0",
60
+ "@instantsearch/tests": "1.49.0",
61
+ "@instantsearch/testutils": "1.38.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": "443c2f875bd5ddd5cc94285b49c1e8c05df5e0f6"
69
+ "gitHead": "035e7a8634884096e71dfbd001c485b79f9bbf88"
70
70
  }