instantsearch.js 4.67.0 → 4.68.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/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 +13 -4
- package/dist/instantsearch.development.d.ts +13 -0
- package/dist/instantsearch.development.js +87 -20
- 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 +13 -4
- package/package.json +7 -7
|
@@ -48,7 +48,7 @@ var RawHtml = /*#__PURE__*/function (_Component) {
|
|
|
48
48
|
var fragment = new DocumentFragment();
|
|
49
49
|
var root = document.createElement('div');
|
|
50
50
|
root.innerHTML = this.props.content;
|
|
51
|
-
this.nodes = _toConsumableArray(root.
|
|
51
|
+
this.nodes = _toConsumableArray(root.childNodes);
|
|
52
52
|
this.nodes.forEach(function (node) {
|
|
53
53
|
return fragment.appendChild(node);
|
|
54
54
|
});
|
|
@@ -58,8 +58,17 @@ var RawHtml = /*#__PURE__*/function (_Component) {
|
|
|
58
58
|
key: "componentWillUnmount",
|
|
59
59
|
value: function componentWillUnmount() {
|
|
60
60
|
this.nodes.forEach(function (node) {
|
|
61
|
-
|
|
61
|
+
if (node instanceof Element) {
|
|
62
|
+
node.outerHTML = '';
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
node.nodeValue = '';
|
|
62
66
|
});
|
|
67
|
+
// if there is one TextNode first and one TextNode last, the
|
|
68
|
+
// last one's nodeValue will be assigned to the first.
|
|
69
|
+
if (this.nodes[0].nodeValue) {
|
|
70
|
+
this.nodes[0].nodeValue = '';
|
|
71
|
+
}
|
|
63
72
|
}
|
|
64
73
|
}, {
|
|
65
74
|
key: "render",
|
|
@@ -48,6 +48,7 @@ var connectHits = function connectHits(renderFn) {
|
|
|
48
48
|
});
|
|
49
49
|
},
|
|
50
50
|
getWidgetRenderState: function getWidgetRenderState(_ref2) {
|
|
51
|
+
var _results$renderingCon, _results$renderingCon2, _results$renderingCon3;
|
|
51
52
|
var results = _ref2.results,
|
|
52
53
|
helper = _ref2.helper,
|
|
53
54
|
instantSearchInstance = _ref2.instantSearchInstance;
|
|
@@ -73,6 +74,7 @@ var connectHits = function connectHits(renderFn) {
|
|
|
73
74
|
return {
|
|
74
75
|
hits: [],
|
|
75
76
|
results: undefined,
|
|
77
|
+
banner: undefined,
|
|
76
78
|
sendEvent: sendEvent,
|
|
77
79
|
bindEvent: bindEvent,
|
|
78
80
|
widgetParams: widgetParams
|
|
@@ -86,9 +88,11 @@ var connectHits = function connectHits(renderFn) {
|
|
|
86
88
|
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
87
89
|
results: results
|
|
88
90
|
});
|
|
91
|
+
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];
|
|
89
92
|
return {
|
|
90
93
|
hits: transformedHits,
|
|
91
94
|
results: results,
|
|
95
|
+
banner: banner,
|
|
92
96
|
sendEvent: sendEvent,
|
|
93
97
|
bindEvent: bindEvent,
|
|
94
98
|
widgetParams: widgetParams
|
package/cjs/lib/version.js
CHANGED
package/cjs/widgets/hits/hits.js
CHANGED
|
@@ -43,7 +43,8 @@ var renderer = function renderer(_ref) {
|
|
|
43
43
|
instantSearchInstance = _ref2.instantSearchInstance,
|
|
44
44
|
insights = _ref2.insights,
|
|
45
45
|
bindEvent = _ref2.bindEvent,
|
|
46
|
-
sendEvent = _ref2.sendEvent
|
|
46
|
+
sendEvent = _ref2.sendEvent,
|
|
47
|
+
banner = _ref2.banner;
|
|
47
48
|
if (isFirstRendering) {
|
|
48
49
|
renderState.templateProps = (0, _templating.prepareTemplateProps)({
|
|
49
50
|
defaultTemplates: _defaultTemplates.default,
|
|
@@ -61,7 +62,8 @@ var renderer = function renderer(_ref) {
|
|
|
61
62
|
return (0, _preact.h)(_Template.default, _extends({}, renderState.templateProps, {
|
|
62
63
|
rootProps: rootProps,
|
|
63
64
|
templateKey: "empty",
|
|
64
|
-
data: results
|
|
65
|
+
data: results,
|
|
66
|
+
rootTagName: "fragment"
|
|
65
67
|
}));
|
|
66
68
|
};
|
|
67
69
|
|
|
@@ -94,12 +96,21 @@ var renderer = function renderer(_ref) {
|
|
|
94
96
|
sendEvent: sendEvent
|
|
95
97
|
}));
|
|
96
98
|
};
|
|
99
|
+
var bannerComponent = function bannerComponent(props) {
|
|
100
|
+
return (0, _preact.h)(_Template.default, _extends({}, renderState.templateProps, {
|
|
101
|
+
templateKey: "banner",
|
|
102
|
+
data: props,
|
|
103
|
+
rootTagName: "fragment"
|
|
104
|
+
}));
|
|
105
|
+
};
|
|
97
106
|
(0, _preact.render)((0, _preact.h)(Hits, {
|
|
98
107
|
hits: receivedHits,
|
|
99
108
|
itemComponent: itemComponent,
|
|
100
109
|
sendEvent: sendEvent,
|
|
101
110
|
classNames: cssClasses,
|
|
102
|
-
emptyComponent: emptyComponent
|
|
111
|
+
emptyComponent: emptyComponent,
|
|
112
|
+
banner: banner,
|
|
113
|
+
bannerComponent: templates.banner ? bannerComponent : undefined
|
|
103
114
|
}), containerNode);
|
|
104
115
|
};
|
|
105
116
|
};
|
|
@@ -159,9 +159,18 @@ var index = function index(widgetParams) {
|
|
|
159
159
|
},
|
|
160
160
|
getScopedResults: function getScopedResults() {
|
|
161
161
|
var widgetParent = this.getParent();
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
162
|
+
var widgetSiblings;
|
|
163
|
+
if (widgetParent) {
|
|
164
|
+
widgetSiblings = widgetParent.getWidgets();
|
|
165
|
+
} else if (indexName.length === 0) {
|
|
166
|
+
// The widget is the root but has no index name:
|
|
167
|
+
// we resolve results from its children index widgets
|
|
168
|
+
widgetSiblings = this.getWidgets();
|
|
169
|
+
} else {
|
|
170
|
+
// The widget is the root and has an index name:
|
|
171
|
+
// we consider itself as the only sibling
|
|
172
|
+
widgetSiblings = [this];
|
|
173
|
+
}
|
|
165
174
|
return resolveScopedResultsFromWidgets(widgetSiblings);
|
|
166
175
|
},
|
|
167
176
|
getParent: function getParent() {
|
|
@@ -499,7 +508,7 @@ var index = function index(widgetParams) {
|
|
|
499
508
|
_helper,
|
|
500
509
|
_derivedHelper2;
|
|
501
510
|
localWidgets.forEach(function (widget) {
|
|
502
|
-
if (widget.dispose) {
|
|
511
|
+
if (widget.dispose && helper) {
|
|
503
512
|
// The dispose function is always called once the instance is started
|
|
504
513
|
// (it's an effect of `removeWidgets`). The index is initialized and
|
|
505
514
|
// the Helper is available. We don't care about the return value of
|
|
@@ -303,6 +303,8 @@ declare type AutocompleteWidgetDescription = {
|
|
|
303
303
|
};
|
|
304
304
|
};
|
|
305
305
|
|
|
306
|
+
declare type Banner = NonNullable<NonNullable<Required<SearchResults<Hit>['renderingContent']>>['widgets']['banners']>[number];
|
|
307
|
+
|
|
306
308
|
declare type BaseHit = Record<string, unknown>;
|
|
307
309
|
|
|
308
310
|
declare type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits;
|
|
@@ -1994,6 +1996,10 @@ declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
|
1994
1996
|
* The response from the Algolia API.
|
|
1995
1997
|
*/
|
|
1996
1998
|
results?: SearchResults<Hit<THit>>;
|
|
1999
|
+
/**
|
|
2000
|
+
* The banner to display above the hits.
|
|
2001
|
+
*/
|
|
2002
|
+
banner?: Banner;
|
|
1997
2003
|
/**
|
|
1998
2004
|
* Sends an event to the Insights middleware.
|
|
1999
2005
|
*/
|
|
@@ -2020,6 +2026,13 @@ declare type HitsTemplates = Partial<{
|
|
|
2020
2026
|
/** @deprecated the index in the hits array, use __position instead, which is the absolute position */
|
|
2021
2027
|
__hitIndex: number;
|
|
2022
2028
|
}>;
|
|
2029
|
+
/**
|
|
2030
|
+
* Template to use for the banner.
|
|
2031
|
+
*/
|
|
2032
|
+
banner: Template<{
|
|
2033
|
+
banner: Required<HitsRenderState['banner']>;
|
|
2034
|
+
className: string;
|
|
2035
|
+
}>;
|
|
2023
2036
|
}>;
|
|
2024
2037
|
|
|
2025
2038
|
declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! InstantSearch.js 4.
|
|
1
|
+
/*! InstantSearch.js 4.68.1 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
@@ -2666,6 +2666,7 @@
|
|
|
2666
2666
|
});
|
|
2667
2667
|
},
|
|
2668
2668
|
getWidgetRenderState: function getWidgetRenderState(_ref2) {
|
|
2669
|
+
var _results$renderingCon, _results$renderingCon2, _results$renderingCon3;
|
|
2669
2670
|
var results = _ref2.results,
|
|
2670
2671
|
helper = _ref2.helper,
|
|
2671
2672
|
instantSearchInstance = _ref2.instantSearchInstance;
|
|
@@ -2691,6 +2692,7 @@
|
|
|
2691
2692
|
return {
|
|
2692
2693
|
hits: [],
|
|
2693
2694
|
results: undefined,
|
|
2695
|
+
banner: undefined,
|
|
2694
2696
|
sendEvent: sendEvent,
|
|
2695
2697
|
bindEvent: bindEvent,
|
|
2696
2698
|
widgetParams: widgetParams
|
|
@@ -2704,9 +2706,11 @@
|
|
|
2704
2706
|
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
2705
2707
|
results: results
|
|
2706
2708
|
});
|
|
2709
|
+
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];
|
|
2707
2710
|
return {
|
|
2708
2711
|
hits: transformedHits,
|
|
2709
2712
|
results: results,
|
|
2713
|
+
banner: banner,
|
|
2710
2714
|
sendEvent: sendEvent,
|
|
2711
2715
|
bindEvent: bindEvent,
|
|
2712
2716
|
widgetParams: widgetParams
|
|
@@ -10203,7 +10207,7 @@
|
|
|
10203
10207
|
|
|
10204
10208
|
var SearchResults_1 = SearchResults;
|
|
10205
10209
|
|
|
10206
|
-
var version = '3.
|
|
10210
|
+
var version = '3.19.0';
|
|
10207
10211
|
|
|
10208
10212
|
var escapeFacetValue$4 = escapeFacetValue_1.escapeFacetValue;
|
|
10209
10213
|
|
|
@@ -14951,9 +14955,18 @@
|
|
|
14951
14955
|
},
|
|
14952
14956
|
getScopedResults: function getScopedResults() {
|
|
14953
14957
|
var widgetParent = this.getParent();
|
|
14954
|
-
|
|
14955
|
-
|
|
14956
|
-
|
|
14958
|
+
var widgetSiblings;
|
|
14959
|
+
if (widgetParent) {
|
|
14960
|
+
widgetSiblings = widgetParent.getWidgets();
|
|
14961
|
+
} else if (indexName.length === 0) {
|
|
14962
|
+
// The widget is the root but has no index name:
|
|
14963
|
+
// we resolve results from its children index widgets
|
|
14964
|
+
widgetSiblings = this.getWidgets();
|
|
14965
|
+
} else {
|
|
14966
|
+
// The widget is the root and has an index name:
|
|
14967
|
+
// we consider itself as the only sibling
|
|
14968
|
+
widgetSiblings = [this];
|
|
14969
|
+
}
|
|
14957
14970
|
return resolveScopedResultsFromWidgets(widgetSiblings);
|
|
14958
14971
|
},
|
|
14959
14972
|
getParent: function getParent() {
|
|
@@ -15291,7 +15304,7 @@
|
|
|
15291
15304
|
_helper,
|
|
15292
15305
|
_derivedHelper2;
|
|
15293
15306
|
localWidgets.forEach(function (widget) {
|
|
15294
|
-
if (widget.dispose) {
|
|
15307
|
+
if (widget.dispose && helper) {
|
|
15295
15308
|
// The dispose function is always called once the instance is started
|
|
15296
15309
|
// (it's an effect of `removeWidgets`). The index is initialized and
|
|
15297
15310
|
// the Helper is available. We don't care about the return value of
|
|
@@ -15415,7 +15428,7 @@
|
|
|
15415
15428
|
};
|
|
15416
15429
|
}
|
|
15417
15430
|
|
|
15418
|
-
var version$1 = '4.
|
|
15431
|
+
var version$1 = '4.68.1';
|
|
15419
15432
|
|
|
15420
15433
|
var withUsage$r = createDocumentationMessageGenerator({
|
|
15421
15434
|
name: 'instantsearch'
|
|
@@ -16185,12 +16198,43 @@
|
|
|
16185
16198
|
};
|
|
16186
16199
|
}
|
|
16187
16200
|
|
|
16188
|
-
var _excluded$a = ["classNames", "hits", "itemComponent", "sendEvent", "emptyComponent"];
|
|
16201
|
+
var _excluded$a = ["classNames", "hits", "itemComponent", "sendEvent", "emptyComponent", "banner", "bannerComponent"];
|
|
16189
16202
|
|
|
16190
16203
|
// Should be imported from a shared package in the future
|
|
16191
16204
|
|
|
16192
|
-
function
|
|
16205
|
+
function createDefaultBannerComponent(_ref) {
|
|
16193
16206
|
var createElement = _ref.createElement;
|
|
16207
|
+
return function DefaultBanner(_ref2) {
|
|
16208
|
+
var _banner$link;
|
|
16209
|
+
var classNames = _ref2.classNames,
|
|
16210
|
+
banner = _ref2.banner;
|
|
16211
|
+
if (!banner.image.urls[0].url) {
|
|
16212
|
+
return null;
|
|
16213
|
+
}
|
|
16214
|
+
return createElement("aside", {
|
|
16215
|
+
className: cx('ais-Hits-banner', classNames.bannerRoot)
|
|
16216
|
+
}, (_banner$link = banner.link) !== null && _banner$link !== void 0 && _banner$link.url ? createElement("a", {
|
|
16217
|
+
className: cx('ais-Hits-banner-link', classNames.bannerLink),
|
|
16218
|
+
href: banner.link.url,
|
|
16219
|
+
target: banner.link.target
|
|
16220
|
+
}, createElement("img", {
|
|
16221
|
+
className: cx('ais-Hits-banner-image', classNames.bannerImage),
|
|
16222
|
+
src: banner.image.urls[0].url,
|
|
16223
|
+
alt: banner.image.title
|
|
16224
|
+
})) : createElement("img", {
|
|
16225
|
+
className: cx('ais-Hits-banner-image', classNames.bannerImage),
|
|
16226
|
+
src: banner.image.urls[0].url,
|
|
16227
|
+
alt: banner.image.title
|
|
16228
|
+
}));
|
|
16229
|
+
};
|
|
16230
|
+
}
|
|
16231
|
+
function createHitsComponent(_ref3) {
|
|
16232
|
+
var createElement = _ref3.createElement,
|
|
16233
|
+
Fragment = _ref3.Fragment;
|
|
16234
|
+
var DefaultBannerComponent = createDefaultBannerComponent({
|
|
16235
|
+
createElement: createElement,
|
|
16236
|
+
Fragment: Fragment
|
|
16237
|
+
});
|
|
16194
16238
|
return function Hits(userProps) {
|
|
16195
16239
|
var _userProps$classNames = userProps.classNames,
|
|
16196
16240
|
classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames,
|
|
@@ -16198,15 +16242,18 @@
|
|
|
16198
16242
|
ItemComponent = userProps.itemComponent,
|
|
16199
16243
|
sendEvent = userProps.sendEvent,
|
|
16200
16244
|
EmptyComponent = userProps.emptyComponent,
|
|
16245
|
+
banner = userProps.banner,
|
|
16246
|
+
BannerComponent = userProps.bannerComponent,
|
|
16201
16247
|
props = _objectWithoutProperties$1(userProps, _excluded$a);
|
|
16202
|
-
if (hits.length === 0 && EmptyComponent) {
|
|
16203
|
-
return createElement(EmptyComponent, {
|
|
16204
|
-
className: cx('ais-Hits', classNames.root, cx('ais-Hits--empty', classNames.emptyRoot), props.className)
|
|
16205
|
-
});
|
|
16206
|
-
}
|
|
16207
16248
|
return createElement("div", _extends$1({}, props, {
|
|
16208
16249
|
className: cx('ais-Hits', classNames.root, hits.length === 0 && cx('ais-Hits--empty', classNames.emptyRoot), props.className)
|
|
16209
|
-
}), createElement(
|
|
16250
|
+
}), banner && (BannerComponent ? createElement(BannerComponent, {
|
|
16251
|
+
className: cx('ais-Hits-banner', classNames.bannerRoot),
|
|
16252
|
+
banner: banner
|
|
16253
|
+
}) : createElement(DefaultBannerComponent, {
|
|
16254
|
+
classNames: classNames,
|
|
16255
|
+
banner: banner
|
|
16256
|
+
})), hits.length === 0 && EmptyComponent ? createElement(EmptyComponent, null) : createElement("ol", {
|
|
16210
16257
|
className: cx('ais-Hits-list', classNames.list)
|
|
16211
16258
|
}, hits.map(function (hit, index) {
|
|
16212
16259
|
return createElement(ItemComponent, {
|
|
@@ -17267,7 +17314,7 @@
|
|
|
17267
17314
|
var fragment = new DocumentFragment();
|
|
17268
17315
|
var root = document.createElement('div');
|
|
17269
17316
|
root.innerHTML = this.props.content;
|
|
17270
|
-
this.nodes = _toConsumableArray(root.
|
|
17317
|
+
this.nodes = _toConsumableArray(root.childNodes);
|
|
17271
17318
|
this.nodes.forEach(function (node) {
|
|
17272
17319
|
return fragment.appendChild(node);
|
|
17273
17320
|
});
|
|
@@ -17277,8 +17324,17 @@
|
|
|
17277
17324
|
key: "componentWillUnmount",
|
|
17278
17325
|
value: function componentWillUnmount() {
|
|
17279
17326
|
this.nodes.forEach(function (node) {
|
|
17280
|
-
|
|
17327
|
+
if (node instanceof Element) {
|
|
17328
|
+
node.outerHTML = '';
|
|
17329
|
+
return;
|
|
17330
|
+
}
|
|
17331
|
+
node.nodeValue = '';
|
|
17281
17332
|
});
|
|
17333
|
+
// if there is one TextNode first and one TextNode last, the
|
|
17334
|
+
// last one's nodeValue will be assigned to the first.
|
|
17335
|
+
if (this.nodes[0].nodeValue) {
|
|
17336
|
+
this.nodes[0].nodeValue = '';
|
|
17337
|
+
}
|
|
17282
17338
|
}
|
|
17283
17339
|
}, {
|
|
17284
17340
|
key: "render",
|
|
@@ -19310,7 +19366,8 @@
|
|
|
19310
19366
|
instantSearchInstance = _ref2.instantSearchInstance,
|
|
19311
19367
|
insights = _ref2.insights,
|
|
19312
19368
|
bindEvent = _ref2.bindEvent,
|
|
19313
|
-
sendEvent = _ref2.sendEvent
|
|
19369
|
+
sendEvent = _ref2.sendEvent,
|
|
19370
|
+
banner = _ref2.banner;
|
|
19314
19371
|
if (isFirstRendering) {
|
|
19315
19372
|
renderState.templateProps = prepareTemplateProps({
|
|
19316
19373
|
defaultTemplates: defaultTemplates$5,
|
|
@@ -19328,7 +19385,8 @@
|
|
|
19328
19385
|
return h(Template, _extends({}, renderState.templateProps, {
|
|
19329
19386
|
rootProps: rootProps,
|
|
19330
19387
|
templateKey: "empty",
|
|
19331
|
-
data: results
|
|
19388
|
+
data: results,
|
|
19389
|
+
rootTagName: "fragment"
|
|
19332
19390
|
}));
|
|
19333
19391
|
};
|
|
19334
19392
|
|
|
@@ -19361,12 +19419,21 @@
|
|
|
19361
19419
|
sendEvent: sendEvent
|
|
19362
19420
|
}));
|
|
19363
19421
|
};
|
|
19422
|
+
var bannerComponent = function bannerComponent(props) {
|
|
19423
|
+
return h(Template, _extends({}, renderState.templateProps, {
|
|
19424
|
+
templateKey: "banner",
|
|
19425
|
+
data: props,
|
|
19426
|
+
rootTagName: "fragment"
|
|
19427
|
+
}));
|
|
19428
|
+
};
|
|
19364
19429
|
P(h(Hits, {
|
|
19365
19430
|
hits: receivedHits,
|
|
19366
19431
|
itemComponent: itemComponent,
|
|
19367
19432
|
sendEvent: sendEvent,
|
|
19368
19433
|
classNames: cssClasses,
|
|
19369
|
-
emptyComponent: emptyComponent
|
|
19434
|
+
emptyComponent: emptyComponent,
|
|
19435
|
+
banner: banner,
|
|
19436
|
+
bannerComponent: templates.banner ? bannerComponent : undefined
|
|
19370
19437
|
}), containerNode);
|
|
19371
19438
|
};
|
|
19372
19439
|
};
|