instantsearch.js 4.67.0 → 4.68.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/cjs/components/Template/Template.js +11 -2
- package/cjs/connectors/hits/connectHits.js +4 -0
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/hits/hits.js +14 -3
- package/cjs/widgets/index/index.js +12 -3
- package/dist/instantsearch.development.d.ts +13 -0
- package/dist/instantsearch.development.js +86 -19
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +13 -0
- package/dist/instantsearch.production.min.d.ts +13 -0
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/Template/Template.js +11 -2
- package/es/connectors/hits/connectHits.d.ts +5 -0
- package/es/connectors/hits/connectHits.js +4 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/widgets/hits/defaultTemplates.d.ts +1 -1
- package/es/widgets/hits/hits.d.ts +8 -1
- package/es/widgets/hits/hits.js +14 -3
- package/es/widgets/index/index.js +12 -3
- package/package.json +7 -7
|
@@ -42,7 +42,7 @@ var RawHtml = /*#__PURE__*/function (_Component) {
|
|
|
42
42
|
var fragment = new DocumentFragment();
|
|
43
43
|
var root = document.createElement('div');
|
|
44
44
|
root.innerHTML = this.props.content;
|
|
45
|
-
this.nodes = _toConsumableArray(root.
|
|
45
|
+
this.nodes = _toConsumableArray(root.childNodes);
|
|
46
46
|
this.nodes.forEach(function (node) {
|
|
47
47
|
return fragment.appendChild(node);
|
|
48
48
|
});
|
|
@@ -52,8 +52,17 @@ var RawHtml = /*#__PURE__*/function (_Component) {
|
|
|
52
52
|
key: "componentWillUnmount",
|
|
53
53
|
value: function componentWillUnmount() {
|
|
54
54
|
this.nodes.forEach(function (node) {
|
|
55
|
-
|
|
55
|
+
if (node instanceof Element) {
|
|
56
|
+
node.outerHTML = '';
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
node.nodeValue = '';
|
|
56
60
|
});
|
|
61
|
+
// if there is one TextNode first and one TextNode last, the
|
|
62
|
+
// last one's nodeValue will be assigned to the first.
|
|
63
|
+
if (this.nodes[0].nodeValue) {
|
|
64
|
+
this.nodes[0].nodeValue = '';
|
|
65
|
+
}
|
|
57
66
|
}
|
|
58
67
|
}, {
|
|
59
68
|
key: "render",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SendEventForHits, BindEventForHits } from '../../lib/utils';
|
|
2
2
|
import type { TransformItems, Connector, Hit, WidgetRenderState, BaseHit } from '../../types';
|
|
3
3
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
4
|
+
type Banner = NonNullable<NonNullable<Required<SearchResults<Hit>['renderingContent']>>['widgets']['banners']>[number];
|
|
4
5
|
export type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
5
6
|
/**
|
|
6
7
|
* The matched hits from Algolia API.
|
|
@@ -10,6 +11,10 @@ export type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
|
10
11
|
* The response from the Algolia API.
|
|
11
12
|
*/
|
|
12
13
|
results?: SearchResults<Hit<THit>>;
|
|
14
|
+
/**
|
|
15
|
+
* The banner to display above the hits.
|
|
16
|
+
*/
|
|
17
|
+
banner?: Banner;
|
|
13
18
|
/**
|
|
14
19
|
* Sends an event to the Insights middleware.
|
|
15
20
|
*/
|
|
@@ -42,6 +42,7 @@ var connectHits = function connectHits(renderFn) {
|
|
|
42
42
|
});
|
|
43
43
|
},
|
|
44
44
|
getWidgetRenderState: function getWidgetRenderState(_ref2) {
|
|
45
|
+
var _results$renderingCon, _results$renderingCon2, _results$renderingCon3;
|
|
45
46
|
var results = _ref2.results,
|
|
46
47
|
helper = _ref2.helper,
|
|
47
48
|
instantSearchInstance = _ref2.instantSearchInstance;
|
|
@@ -67,6 +68,7 @@ var connectHits = function connectHits(renderFn) {
|
|
|
67
68
|
return {
|
|
68
69
|
hits: [],
|
|
69
70
|
results: undefined,
|
|
71
|
+
banner: undefined,
|
|
70
72
|
sendEvent: sendEvent,
|
|
71
73
|
bindEvent: bindEvent,
|
|
72
74
|
widgetParams: widgetParams
|
|
@@ -80,9 +82,11 @@ var connectHits = function connectHits(renderFn) {
|
|
|
80
82
|
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
81
83
|
results: results
|
|
82
84
|
});
|
|
85
|
+
var banner = (_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];
|
|
83
86
|
return {
|
|
84
87
|
hits: transformedHits,
|
|
85
88
|
results: results,
|
|
89
|
+
banner: banner,
|
|
86
90
|
sendEvent: sendEvent,
|
|
87
91
|
bindEvent: bindEvent,
|
|
88
92
|
widgetParams: widgetParams
|
package/es/lib/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "4.
|
|
1
|
+
declare const _default: "4.68.0";
|
|
2
2
|
export default _default;
|
package/es/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '4.
|
|
1
|
+
export default '4.68.0';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import type { HitsConnectorParams, HitsWidgetDescription } from '../../connectors/hits/connectHits';
|
|
2
|
+
import type { HitsConnectorParams, HitsRenderState, HitsWidgetDescription } from '../../connectors/hits/connectHits';
|
|
3
3
|
import type { Template, TemplateWithBindEvent, Hit, WidgetFactory } from '../../types';
|
|
4
4
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
5
5
|
import type { HitsClassNames as HitsUiComponentClassNames } from 'instantsearch-ui-components';
|
|
@@ -20,6 +20,13 @@ export type HitsTemplates = Partial<{
|
|
|
20
20
|
/** @deprecated the index in the hits array, use __position instead, which is the absolute position */
|
|
21
21
|
__hitIndex: number;
|
|
22
22
|
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Template to use for the banner.
|
|
25
|
+
*/
|
|
26
|
+
banner: Template<{
|
|
27
|
+
banner: Required<HitsRenderState['banner']>;
|
|
28
|
+
className: string;
|
|
29
|
+
}>;
|
|
23
30
|
}>;
|
|
24
31
|
export type HitsWidgetParams = {
|
|
25
32
|
/**
|
package/es/widgets/hits/hits.js
CHANGED
|
@@ -36,7 +36,8 @@ var renderer = function renderer(_ref) {
|
|
|
36
36
|
instantSearchInstance = _ref2.instantSearchInstance,
|
|
37
37
|
insights = _ref2.insights,
|
|
38
38
|
bindEvent = _ref2.bindEvent,
|
|
39
|
-
sendEvent = _ref2.sendEvent
|
|
39
|
+
sendEvent = _ref2.sendEvent,
|
|
40
|
+
banner = _ref2.banner;
|
|
40
41
|
if (isFirstRendering) {
|
|
41
42
|
renderState.templateProps = prepareTemplateProps({
|
|
42
43
|
defaultTemplates: defaultTemplates,
|
|
@@ -54,7 +55,8 @@ var renderer = function renderer(_ref) {
|
|
|
54
55
|
return h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
55
56
|
rootProps: rootProps,
|
|
56
57
|
templateKey: "empty",
|
|
57
|
-
data: results
|
|
58
|
+
data: results,
|
|
59
|
+
rootTagName: "fragment"
|
|
58
60
|
}));
|
|
59
61
|
};
|
|
60
62
|
|
|
@@ -87,12 +89,21 @@ var renderer = function renderer(_ref) {
|
|
|
87
89
|
sendEvent: sendEvent
|
|
88
90
|
}));
|
|
89
91
|
};
|
|
92
|
+
var bannerComponent = function bannerComponent(props) {
|
|
93
|
+
return h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
94
|
+
templateKey: "banner",
|
|
95
|
+
data: props,
|
|
96
|
+
rootTagName: "fragment"
|
|
97
|
+
}));
|
|
98
|
+
};
|
|
90
99
|
render(h(Hits, {
|
|
91
100
|
hits: receivedHits,
|
|
92
101
|
itemComponent: itemComponent,
|
|
93
102
|
sendEvent: sendEvent,
|
|
94
103
|
classNames: cssClasses,
|
|
95
|
-
emptyComponent: emptyComponent
|
|
104
|
+
emptyComponent: emptyComponent,
|
|
105
|
+
banner: banner,
|
|
106
|
+
bannerComponent: templates.banner ? bannerComponent : undefined
|
|
96
107
|
}), containerNode);
|
|
97
108
|
};
|
|
98
109
|
};
|
|
@@ -152,9 +152,18 @@ var index = function index(widgetParams) {
|
|
|
152
152
|
},
|
|
153
153
|
getScopedResults: function getScopedResults() {
|
|
154
154
|
var widgetParent = this.getParent();
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
var widgetSiblings;
|
|
156
|
+
if (widgetParent) {
|
|
157
|
+
widgetSiblings = widgetParent.getWidgets();
|
|
158
|
+
} else if (indexName.length === 0) {
|
|
159
|
+
// The widget is the root but has no index name:
|
|
160
|
+
// we resolve results from its children index widgets
|
|
161
|
+
widgetSiblings = this.getWidgets();
|
|
162
|
+
} else {
|
|
163
|
+
// The widget is the root and has an index name:
|
|
164
|
+
// we consider itself as the only sibling
|
|
165
|
+
widgetSiblings = [this];
|
|
166
|
+
}
|
|
158
167
|
return resolveScopedResultsFromWidgets(widgetSiblings);
|
|
159
168
|
},
|
|
160
169
|
getParent: function getParent() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "instantsearch.js",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.68.0",
|
|
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.
|
|
34
|
+
"algoliasearch-helper": "3.19.0",
|
|
35
35
|
"hogan.js": "^3.0.2",
|
|
36
36
|
"htm": "^3.0.0",
|
|
37
|
-
"instantsearch-ui-components": "0.
|
|
37
|
+
"instantsearch-ui-components": "0.5.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.
|
|
60
|
-
"@instantsearch/tests": "1.
|
|
61
|
-
"@instantsearch/testutils": "1.
|
|
59
|
+
"@instantsearch/mocks": "1.42.0",
|
|
60
|
+
"@instantsearch/tests": "1.42.0",
|
|
61
|
+
"@instantsearch/testutils": "1.31.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": "68fe2ee8544096eff8c2fbafe01a50a8acbca2b9"
|
|
70
70
|
}
|