react-instantsearch 7.7.1 → 7.7.3
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.
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
var React__default = 'default' in React ? React['default'] : React;
|
|
9
9
|
|
|
10
|
-
var version = '7.7.
|
|
10
|
+
var version = '7.7.3';
|
|
11
11
|
|
|
12
12
|
// Copyright Joyent, Inc. and other Node contributors.
|
|
13
13
|
//
|
|
@@ -335,12 +335,15 @@
|
|
|
335
335
|
* This event contains a {@link SearchResults} object and the
|
|
336
336
|
* {@link SearchParameters} corresponding to this answer.
|
|
337
337
|
* @param {AlgoliaSearchHelper} mainHelper the main helper
|
|
338
|
-
* @param {function} fn the function to create the derived state
|
|
338
|
+
* @param {function} fn the function to create the derived state for search
|
|
339
|
+
* @param {function} recommendFn the function to create the derived state for recommendations
|
|
339
340
|
*/
|
|
340
|
-
function DerivedHelper(mainHelper, fn) {
|
|
341
|
+
function DerivedHelper(mainHelper, fn, recommendFn) {
|
|
341
342
|
this.main = mainHelper;
|
|
342
343
|
this.fn = fn;
|
|
344
|
+
this.recommendFn = recommendFn;
|
|
343
345
|
this.lastResults = null;
|
|
346
|
+
this.lastRecommendResults = null;
|
|
344
347
|
}
|
|
345
348
|
|
|
346
349
|
inherits_1(DerivedHelper, events);
|
|
@@ -359,6 +362,10 @@
|
|
|
359
362
|
return this.fn(parameters);
|
|
360
363
|
};
|
|
361
364
|
|
|
365
|
+
DerivedHelper.prototype.getModifiedRecommendState = function (parameters) {
|
|
366
|
+
return this.recommendFn(parameters);
|
|
367
|
+
};
|
|
368
|
+
|
|
362
369
|
var DerivedHelper_1 = DerivedHelper;
|
|
363
370
|
|
|
364
371
|
/**
|
|
@@ -519,7 +526,18 @@
|
|
|
519
526
|
constructor: RecommendParameters,
|
|
520
527
|
|
|
521
528
|
addParams: function (params) {
|
|
522
|
-
|
|
529
|
+
var newParams = this.params.slice();
|
|
530
|
+
var existingParamsIndex = this.params.findIndex(function (currentParams) {
|
|
531
|
+
return currentParams.$$id === params.$$id;
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
if (existingParamsIndex !== -1) {
|
|
535
|
+
newParams.splice(existingParamsIndex, 1, params);
|
|
536
|
+
} else {
|
|
537
|
+
newParams.push(params);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return new RecommendParameters({ params: newParams });
|
|
523
541
|
},
|
|
524
542
|
|
|
525
543
|
removeParams: function (id) {
|
|
@@ -529,6 +547,45 @@
|
|
|
529
547
|
}),
|
|
530
548
|
});
|
|
531
549
|
},
|
|
550
|
+
|
|
551
|
+
addFrequentlyBoughtTogether: function (params) {
|
|
552
|
+
return this.addParams(
|
|
553
|
+
Object.assign({}, params, { model: 'bought-together' })
|
|
554
|
+
);
|
|
555
|
+
},
|
|
556
|
+
|
|
557
|
+
addRelatedProducts: function (params) {
|
|
558
|
+
return this.addParams(
|
|
559
|
+
Object.assign({}, params, { model: 'related-products' })
|
|
560
|
+
);
|
|
561
|
+
},
|
|
562
|
+
|
|
563
|
+
addTrendingItems: function (params) {
|
|
564
|
+
return this.addParams(
|
|
565
|
+
Object.assign({}, params, { model: 'trending-items' })
|
|
566
|
+
);
|
|
567
|
+
},
|
|
568
|
+
|
|
569
|
+
addTrendingFacets: function (params) {
|
|
570
|
+
return this.addParams(
|
|
571
|
+
Object.assign({}, params, { model: 'trending-facets' })
|
|
572
|
+
);
|
|
573
|
+
},
|
|
574
|
+
|
|
575
|
+
addLookingSimilar: function (params) {
|
|
576
|
+
return this.addParams(
|
|
577
|
+
Object.assign({}, params, { model: 'looking-similar' })
|
|
578
|
+
);
|
|
579
|
+
},
|
|
580
|
+
|
|
581
|
+
_buildQueries: function (indexName) {
|
|
582
|
+
return this.params.map(function (params) {
|
|
583
|
+
var query = Object.assign({}, params, { indexName: indexName });
|
|
584
|
+
delete query.$$id;
|
|
585
|
+
|
|
586
|
+
return query;
|
|
587
|
+
});
|
|
588
|
+
},
|
|
532
589
|
};
|
|
533
590
|
|
|
534
591
|
var RecommendParameters_1 = RecommendParameters;
|
|
@@ -4380,7 +4437,7 @@
|
|
|
4380
4437
|
|
|
4381
4438
|
var SearchResults_1 = SearchResults;
|
|
4382
4439
|
|
|
4383
|
-
var version$1 = '3.
|
|
4440
|
+
var version$1 = '3.19.0';
|
|
4384
4441
|
|
|
4385
4442
|
var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
|
|
4386
4443
|
|
|
@@ -4510,10 +4567,14 @@
|
|
|
4510
4567
|
params: opts.recommendState,
|
|
4511
4568
|
});
|
|
4512
4569
|
this.lastResults = null;
|
|
4570
|
+
this.lastRecommendResults = null;
|
|
4513
4571
|
this._queryId = 0;
|
|
4572
|
+
this._recommendQueryId = 0;
|
|
4514
4573
|
this._lastQueryIdReceived = -1;
|
|
4574
|
+
this._lastRecommendQueryIdReceived = -1;
|
|
4515
4575
|
this.derivedHelpers = [];
|
|
4516
4576
|
this._currentNbQueries = 0;
|
|
4577
|
+
this._currentNbRecommendQueries = 0;
|
|
4517
4578
|
this._searchResultsOptions = searchResultsOptions;
|
|
4518
4579
|
}
|
|
4519
4580
|
|
|
@@ -4540,6 +4601,21 @@
|
|
|
4540
4601
|
return this;
|
|
4541
4602
|
};
|
|
4542
4603
|
|
|
4604
|
+
/**
|
|
4605
|
+
* Sends the recommendation queries set in the state. When the method is
|
|
4606
|
+
* called, it triggers a `fetch` event. The results will be available through
|
|
4607
|
+
* the `result` event. If an error occurs, an `error` will be fired instead.
|
|
4608
|
+
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
4609
|
+
* @fires fetch
|
|
4610
|
+
* @fires result
|
|
4611
|
+
* @fires error
|
|
4612
|
+
* @chainable
|
|
4613
|
+
*/
|
|
4614
|
+
AlgoliaSearchHelper.prototype.recommend = function () {
|
|
4615
|
+
this._recommend();
|
|
4616
|
+
return this;
|
|
4617
|
+
};
|
|
4618
|
+
|
|
4543
4619
|
/**
|
|
4544
4620
|
* Gets the search query parameters that would be sent to the Algolia Client
|
|
4545
4621
|
* for the hits
|
|
@@ -5036,6 +5112,86 @@
|
|
|
5036
5112
|
return this;
|
|
5037
5113
|
};
|
|
5038
5114
|
|
|
5115
|
+
/**
|
|
5116
|
+
* Adds a "frequently bought together" recommendation query.
|
|
5117
|
+
*
|
|
5118
|
+
* @param {FrequentlyBoughtTogetherQuery} params the parameters for the recommendation
|
|
5119
|
+
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5120
|
+
* @fires change
|
|
5121
|
+
* @chainable
|
|
5122
|
+
*/
|
|
5123
|
+
AlgoliaSearchHelper.prototype.addFrequentlyBoughtTogether = function (params) {
|
|
5124
|
+
this._recommendChange({
|
|
5125
|
+
state: this.recommendState.addFrequentlyBoughtTogether(params),
|
|
5126
|
+
});
|
|
5127
|
+
|
|
5128
|
+
return this;
|
|
5129
|
+
};
|
|
5130
|
+
|
|
5131
|
+
/**
|
|
5132
|
+
* Adds a "related products" recommendation query.
|
|
5133
|
+
*
|
|
5134
|
+
* @param {RelatedProductsQuery} params the parameters for the recommendation
|
|
5135
|
+
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5136
|
+
* @fires change
|
|
5137
|
+
* @chainable
|
|
5138
|
+
*/
|
|
5139
|
+
AlgoliaSearchHelper.prototype.addRelatedProducts = function (params) {
|
|
5140
|
+
this._recommendChange({
|
|
5141
|
+
state: this.recommendState.addRelatedProducts(params),
|
|
5142
|
+
});
|
|
5143
|
+
|
|
5144
|
+
return this;
|
|
5145
|
+
};
|
|
5146
|
+
|
|
5147
|
+
/**
|
|
5148
|
+
* Adds a "trending items" recommendation query.
|
|
5149
|
+
*
|
|
5150
|
+
* @param {TrendingItemsQuery} params the parameters for the recommendation
|
|
5151
|
+
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5152
|
+
* @fires change
|
|
5153
|
+
* @chainable
|
|
5154
|
+
*/
|
|
5155
|
+
AlgoliaSearchHelper.prototype.addTrendingItems = function (params) {
|
|
5156
|
+
this._recommendChange({
|
|
5157
|
+
state: this.recommendState.addTrendingItems(params),
|
|
5158
|
+
});
|
|
5159
|
+
|
|
5160
|
+
return this;
|
|
5161
|
+
};
|
|
5162
|
+
|
|
5163
|
+
/**
|
|
5164
|
+
* Adds a "trending facets" recommendation query.
|
|
5165
|
+
*
|
|
5166
|
+
* @param {TrendingFacetsQuery} params the parameters for the recommendation
|
|
5167
|
+
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5168
|
+
* @fires change
|
|
5169
|
+
* @chainable
|
|
5170
|
+
*/
|
|
5171
|
+
AlgoliaSearchHelper.prototype.addTrendingFacets = function (params) {
|
|
5172
|
+
this._recommendChange({
|
|
5173
|
+
state: this.recommendState.addTrendingFacets(params),
|
|
5174
|
+
});
|
|
5175
|
+
|
|
5176
|
+
return this;
|
|
5177
|
+
};
|
|
5178
|
+
|
|
5179
|
+
/**
|
|
5180
|
+
* Adds a "looking similar" recommendation query.
|
|
5181
|
+
*
|
|
5182
|
+
* @param {LookingSimilarQuery} params the parameters for the recommendation
|
|
5183
|
+
* @return {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5184
|
+
* @fires change
|
|
5185
|
+
* @chainable
|
|
5186
|
+
*/
|
|
5187
|
+
AlgoliaSearchHelper.prototype.addLookingSimilar = function (params) {
|
|
5188
|
+
this._recommendChange({
|
|
5189
|
+
state: this.recommendState.addLookingSimilar(params),
|
|
5190
|
+
});
|
|
5191
|
+
|
|
5192
|
+
return this;
|
|
5193
|
+
};
|
|
5194
|
+
|
|
5039
5195
|
/**
|
|
5040
5196
|
* Removes an numeric filter to an attribute with the `operator` and `value` provided. If the
|
|
5041
5197
|
* filter is not set, it doesn't change the filters.
|
|
@@ -5205,6 +5361,86 @@
|
|
|
5205
5361
|
return this;
|
|
5206
5362
|
};
|
|
5207
5363
|
|
|
5364
|
+
/**
|
|
5365
|
+
* Removes a "frequently bought together" recommendation query.
|
|
5366
|
+
*
|
|
5367
|
+
* @param {string} id identifier of the recommendation widget
|
|
5368
|
+
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5369
|
+
* @fires change
|
|
5370
|
+
* @chainable
|
|
5371
|
+
*/
|
|
5372
|
+
AlgoliaSearchHelper.prototype.removeFrequentlyBoughtTogether = function (id) {
|
|
5373
|
+
this._recommendChange({
|
|
5374
|
+
state: this.recommendState.removeParams(id),
|
|
5375
|
+
});
|
|
5376
|
+
|
|
5377
|
+
return this;
|
|
5378
|
+
};
|
|
5379
|
+
|
|
5380
|
+
/**
|
|
5381
|
+
* Removes a "related products" recommendation query.
|
|
5382
|
+
*
|
|
5383
|
+
* @param {string} id identifier of the recommendation widget
|
|
5384
|
+
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5385
|
+
* @fires change
|
|
5386
|
+
* @chainable
|
|
5387
|
+
*/
|
|
5388
|
+
AlgoliaSearchHelper.prototype.removeRelatedProducts = function (id) {
|
|
5389
|
+
this._recommendChange({
|
|
5390
|
+
state: this.recommendState.removeParams(id),
|
|
5391
|
+
});
|
|
5392
|
+
|
|
5393
|
+
return this;
|
|
5394
|
+
};
|
|
5395
|
+
|
|
5396
|
+
/**
|
|
5397
|
+
* Removes a "trending items" recommendation query.
|
|
5398
|
+
*
|
|
5399
|
+
* @param {string} id identifier of the recommendation widget
|
|
5400
|
+
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5401
|
+
* @fires change
|
|
5402
|
+
* @chainable
|
|
5403
|
+
*/
|
|
5404
|
+
AlgoliaSearchHelper.prototype.removeTrendingItems = function (id) {
|
|
5405
|
+
this._recommendChange({
|
|
5406
|
+
state: this.recommendState.removeParams(id),
|
|
5407
|
+
});
|
|
5408
|
+
|
|
5409
|
+
return this;
|
|
5410
|
+
};
|
|
5411
|
+
|
|
5412
|
+
/**
|
|
5413
|
+
* Removes a "trending facets" recommendation query.
|
|
5414
|
+
*
|
|
5415
|
+
* @param {string} id identifier of the recommendation widget
|
|
5416
|
+
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5417
|
+
* @fires change
|
|
5418
|
+
* @chainable
|
|
5419
|
+
*/
|
|
5420
|
+
AlgoliaSearchHelper.prototype.removeTrendingFacets = function (id) {
|
|
5421
|
+
this._recommendChange({
|
|
5422
|
+
state: this.recommendState.removeParams(id),
|
|
5423
|
+
});
|
|
5424
|
+
|
|
5425
|
+
return this;
|
|
5426
|
+
};
|
|
5427
|
+
|
|
5428
|
+
/**
|
|
5429
|
+
* Removes a "looking similar" recommendation query.
|
|
5430
|
+
*
|
|
5431
|
+
* @param {string} id identifier of the recommendation widget
|
|
5432
|
+
* @returns {AlgoliaSearchHelper} Method is chainable, it returns itself
|
|
5433
|
+
* @fires change
|
|
5434
|
+
* @chainable
|
|
5435
|
+
*/
|
|
5436
|
+
AlgoliaSearchHelper.prototype.removeLookingSimilar = function (id) {
|
|
5437
|
+
this._recommendChange({
|
|
5438
|
+
state: this.recommendState.removeParams(id),
|
|
5439
|
+
});
|
|
5440
|
+
|
|
5441
|
+
return this;
|
|
5442
|
+
};
|
|
5443
|
+
|
|
5208
5444
|
/**
|
|
5209
5445
|
* Adds or removes an exclusion filter to a faceted attribute with the `value` provided. If
|
|
5210
5446
|
* the value is set then it removes it, otherwise it adds the filter.
|
|
@@ -5772,6 +6008,85 @@
|
|
|
5772
6008
|
return undefined;
|
|
5773
6009
|
};
|
|
5774
6010
|
|
|
6011
|
+
AlgoliaSearchHelper.prototype._recommend = function () {
|
|
6012
|
+
var searchState = this.state;
|
|
6013
|
+
var recommendState = this.recommendState;
|
|
6014
|
+
var index = this.getIndex();
|
|
6015
|
+
var states = [{ state: recommendState, index: index, helper: this }];
|
|
6016
|
+
|
|
6017
|
+
this.emit('fetch', {
|
|
6018
|
+
recommend: {
|
|
6019
|
+
state: recommendState,
|
|
6020
|
+
results: this.lastRecommendResults,
|
|
6021
|
+
},
|
|
6022
|
+
});
|
|
6023
|
+
|
|
6024
|
+
var derivedQueries = this.derivedHelpers.map(function (derivedHelper) {
|
|
6025
|
+
var derivedIndex = derivedHelper.getModifiedState(searchState).index;
|
|
6026
|
+
if (!derivedIndex) {
|
|
6027
|
+
return [];
|
|
6028
|
+
}
|
|
6029
|
+
|
|
6030
|
+
// Contrary to what is done when deriving the search state, we don't want to
|
|
6031
|
+
// provide the current recommend state to the derived helper, as it would
|
|
6032
|
+
// inherit unwanted queries. We instead provide an empty recommend state.
|
|
6033
|
+
var derivedState = derivedHelper.getModifiedRecommendState(
|
|
6034
|
+
new RecommendParameters_1()
|
|
6035
|
+
);
|
|
6036
|
+
states.push({
|
|
6037
|
+
state: derivedState,
|
|
6038
|
+
index: derivedIndex,
|
|
6039
|
+
helper: derivedHelper,
|
|
6040
|
+
});
|
|
6041
|
+
|
|
6042
|
+
derivedHelper.emit('fetch', {
|
|
6043
|
+
recommend: {
|
|
6044
|
+
state: derivedState,
|
|
6045
|
+
results: derivedHelper.lastRecommendResults,
|
|
6046
|
+
},
|
|
6047
|
+
});
|
|
6048
|
+
|
|
6049
|
+
return derivedState._buildQueries(derivedIndex);
|
|
6050
|
+
});
|
|
6051
|
+
|
|
6052
|
+
var queries = Array.prototype.concat.apply(
|
|
6053
|
+
this.recommendState._buildQueries(index),
|
|
6054
|
+
derivedQueries
|
|
6055
|
+
);
|
|
6056
|
+
|
|
6057
|
+
if (queries.length === 0) {
|
|
6058
|
+
return;
|
|
6059
|
+
}
|
|
6060
|
+
|
|
6061
|
+
if (
|
|
6062
|
+
queries.length > 0 &&
|
|
6063
|
+
typeof this.client.getRecommendations === 'undefined'
|
|
6064
|
+
) {
|
|
6065
|
+
// eslint-disable-next-line no-console
|
|
6066
|
+
console.warn(
|
|
6067
|
+
'Please update algoliasearch/lite to the latest version in order to use recommendations widgets.'
|
|
6068
|
+
);
|
|
6069
|
+
return;
|
|
6070
|
+
}
|
|
6071
|
+
|
|
6072
|
+
var queryId = this._recommendQueryId++;
|
|
6073
|
+
this._currentNbRecommendQueries++;
|
|
6074
|
+
|
|
6075
|
+
try {
|
|
6076
|
+
this.client
|
|
6077
|
+
.getRecommendations(queries)
|
|
6078
|
+
.then(this._dispatchRecommendResponse.bind(this, queryId, states))
|
|
6079
|
+
.catch(this._dispatchRecommendError.bind(this, queryId));
|
|
6080
|
+
} catch (error) {
|
|
6081
|
+
// If we reach this part, we're in an internal error state
|
|
6082
|
+
this.emit('error', {
|
|
6083
|
+
error: error,
|
|
6084
|
+
});
|
|
6085
|
+
}
|
|
6086
|
+
|
|
6087
|
+
return;
|
|
6088
|
+
};
|
|
6089
|
+
|
|
5775
6090
|
/**
|
|
5776
6091
|
* Transform the responses as sent by the server and transform them into a user
|
|
5777
6092
|
* usable object that merge the results of all the batch requests. It will dispatch
|
|
@@ -5831,6 +6146,53 @@
|
|
|
5831
6146
|
});
|
|
5832
6147
|
};
|
|
5833
6148
|
|
|
6149
|
+
AlgoliaSearchHelper.prototype._dispatchRecommendResponse = function (
|
|
6150
|
+
queryId,
|
|
6151
|
+
states,
|
|
6152
|
+
content
|
|
6153
|
+
) {
|
|
6154
|
+
// @TODO remove the number of outdated queries discarded instead of just one
|
|
6155
|
+
|
|
6156
|
+
if (queryId < this._lastRecommendQueryIdReceived) {
|
|
6157
|
+
// Outdated answer
|
|
6158
|
+
return;
|
|
6159
|
+
}
|
|
6160
|
+
|
|
6161
|
+
this._currentNbRecommendQueries -=
|
|
6162
|
+
queryId - this._lastRecommendQueryIdReceived;
|
|
6163
|
+
this._lastRecommendQueryIdReceived = queryId;
|
|
6164
|
+
|
|
6165
|
+
if (this._currentNbRecommendQueries === 0) this.emit('recommendQueueEmpty');
|
|
6166
|
+
|
|
6167
|
+
var results = content.results.slice();
|
|
6168
|
+
|
|
6169
|
+
states.forEach(function (s) {
|
|
6170
|
+
var state = s.state;
|
|
6171
|
+
var helper = s.helper;
|
|
6172
|
+
|
|
6173
|
+
if (!s.index) {
|
|
6174
|
+
// eslint-disable-next-line no-warning-comments
|
|
6175
|
+
// TODO: emit "result" event when events for Recommend are implemented
|
|
6176
|
+
helper.emit('recommend:result', {
|
|
6177
|
+
results: null,
|
|
6178
|
+
state: state,
|
|
6179
|
+
});
|
|
6180
|
+
return;
|
|
6181
|
+
}
|
|
6182
|
+
|
|
6183
|
+
helper.lastRecommendResults = results;
|
|
6184
|
+
|
|
6185
|
+
// eslint-disable-next-line no-warning-comments
|
|
6186
|
+
// TODO: emit "result" event when events for Recommend are implemented
|
|
6187
|
+
helper.emit('recommend:result', {
|
|
6188
|
+
recommend: {
|
|
6189
|
+
results: helper.lastRecommendResults,
|
|
6190
|
+
state: state,
|
|
6191
|
+
},
|
|
6192
|
+
});
|
|
6193
|
+
});
|
|
6194
|
+
};
|
|
6195
|
+
|
|
5834
6196
|
AlgoliaSearchHelper.prototype._dispatchAlgoliaError = function (
|
|
5835
6197
|
queryId,
|
|
5836
6198
|
error
|
|
@@ -5850,6 +6212,26 @@
|
|
|
5850
6212
|
if (this._currentNbQueries === 0) this.emit('searchQueueEmpty');
|
|
5851
6213
|
};
|
|
5852
6214
|
|
|
6215
|
+
AlgoliaSearchHelper.prototype._dispatchRecommendError = function (
|
|
6216
|
+
queryId,
|
|
6217
|
+
error
|
|
6218
|
+
) {
|
|
6219
|
+
if (queryId < this._lastRecommendQueryIdReceived) {
|
|
6220
|
+
// Outdated answer
|
|
6221
|
+
return;
|
|
6222
|
+
}
|
|
6223
|
+
|
|
6224
|
+
this._currentNbRecommendQueries -=
|
|
6225
|
+
queryId - this._lastRecommendQueryIdReceived;
|
|
6226
|
+
this._lastRecommendQueryIdReceived = queryId;
|
|
6227
|
+
|
|
6228
|
+
this.emit('error', {
|
|
6229
|
+
error: error,
|
|
6230
|
+
});
|
|
6231
|
+
|
|
6232
|
+
if (this._currentNbRecommendQueries === 0) this.emit('recommendQueueEmpty');
|
|
6233
|
+
};
|
|
6234
|
+
|
|
5853
6235
|
AlgoliaSearchHelper.prototype.containsRefinement = function (
|
|
5854
6236
|
query,
|
|
5855
6237
|
facetFilters,
|
|
@@ -5900,6 +6282,16 @@
|
|
|
5900
6282
|
|
|
5901
6283
|
// eslint-disable-next-line no-warning-comments
|
|
5902
6284
|
// TODO: emit "change" event when events for Recommend are implemented
|
|
6285
|
+
this.emit('recommend:change', {
|
|
6286
|
+
search: {
|
|
6287
|
+
results: this.lastResults,
|
|
6288
|
+
state: this.state,
|
|
6289
|
+
},
|
|
6290
|
+
recommend: {
|
|
6291
|
+
results: this.lastRecommendResults,
|
|
6292
|
+
state: this.recommendState,
|
|
6293
|
+
},
|
|
6294
|
+
});
|
|
5903
6295
|
}
|
|
5904
6296
|
};
|
|
5905
6297
|
|
|
@@ -5954,10 +6346,11 @@
|
|
|
5954
6346
|
* and the SearchParameters that is returned by the call of the
|
|
5955
6347
|
* parameter function.
|
|
5956
6348
|
* @param {function} fn SearchParameters -> SearchParameters
|
|
6349
|
+
* @param {function} recommendFn RecommendParameters -> RecommendParameters
|
|
5957
6350
|
* @return {DerivedHelper} a new DerivedHelper
|
|
5958
6351
|
*/
|
|
5959
|
-
AlgoliaSearchHelper.prototype.derive = function (fn) {
|
|
5960
|
-
var derivedHelper = new DerivedHelper_1(this, fn);
|
|
6352
|
+
AlgoliaSearchHelper.prototype.derive = function (fn, recommendFn) {
|
|
6353
|
+
var derivedHelper = new DerivedHelper_1(this, fn, recommendFn);
|
|
5961
6354
|
this.derivedHelpers.push(derivedHelper);
|
|
5962
6355
|
return derivedHelper;
|
|
5963
6356
|
};
|
|
@@ -6059,6 +6452,13 @@
|
|
|
6059
6452
|
*/
|
|
6060
6453
|
algoliasearchHelper.SearchParameters = SearchParameters_1;
|
|
6061
6454
|
|
|
6455
|
+
/**
|
|
6456
|
+
* Constructor for the object containing all the parameters for Recommend.
|
|
6457
|
+
* @member module:algoliasearchHelper.RecommendParameters
|
|
6458
|
+
* @type {RecommendParameters}
|
|
6459
|
+
*/
|
|
6460
|
+
algoliasearchHelper.RecommendParameters = RecommendParameters_1;
|
|
6461
|
+
|
|
6062
6462
|
/**
|
|
6063
6463
|
* Constructor for the object containing the results of the search.
|
|
6064
6464
|
* @member module:algoliasearchHelper.SearchResults
|
|
@@ -9347,7 +9747,8 @@
|
|
|
9347
9747
|
return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
9348
9748
|
}, _typeof$g(obj);
|
|
9349
9749
|
}
|
|
9350
|
-
var _excluded$3 = ["initialSearchParameters"]
|
|
9750
|
+
var _excluded$3 = ["initialSearchParameters"],
|
|
9751
|
+
_excluded2$1 = ["initialRecommendParameters"];
|
|
9351
9752
|
function ownKeys$d(object, enumerableOnly) {
|
|
9352
9753
|
var keys = Object.keys(object);
|
|
9353
9754
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -9459,6 +9860,7 @@
|
|
|
9459
9860
|
*/
|
|
9460
9861
|
function privateHelperSetState(helper, _ref) {
|
|
9461
9862
|
var state = _ref.state,
|
|
9863
|
+
recommendState = _ref.recommendState,
|
|
9462
9864
|
isPageReset = _ref.isPageReset,
|
|
9463
9865
|
_uiState = _ref._uiState;
|
|
9464
9866
|
if (state !== helper.state) {
|
|
@@ -9470,7 +9872,14 @@
|
|
|
9470
9872
|
_uiState: _uiState
|
|
9471
9873
|
});
|
|
9472
9874
|
}
|
|
9875
|
+
if (recommendState !== helper.recommendState) {
|
|
9876
|
+
helper.recommendState = recommendState;
|
|
9877
|
+
|
|
9878
|
+
// eslint-disable-next-line no-warning-comments
|
|
9879
|
+
// TODO: emit "change" event when events for Recommend are implemented
|
|
9880
|
+
}
|
|
9473
9881
|
}
|
|
9882
|
+
|
|
9474
9883
|
function getLocalWidgetsUiState(widgets, widgetStateOptions) {
|
|
9475
9884
|
var initialUiState = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
9476
9885
|
return widgets.reduce(function (uiState, widget) {
|
|
@@ -9489,15 +9898,26 @@
|
|
|
9489
9898
|
function getLocalWidgetsSearchParameters(widgets, widgetSearchParametersOptions) {
|
|
9490
9899
|
var initialSearchParameters = widgetSearchParametersOptions.initialSearchParameters,
|
|
9491
9900
|
rest = _objectWithoutProperties$3(widgetSearchParametersOptions, _excluded$3);
|
|
9492
|
-
return widgets.
|
|
9493
|
-
|
|
9494
|
-
}).reduce(function (state, widget) {
|
|
9495
|
-
if (!widget.getWidgetSearchParameters) {
|
|
9901
|
+
return widgets.reduce(function (state, widget) {
|
|
9902
|
+
if (!widget.getWidgetSearchParameters || isIndexWidget(widget)) {
|
|
9496
9903
|
return state;
|
|
9497
9904
|
}
|
|
9905
|
+
if (widget.dependsOn === 'search' && widget.getWidgetParameters) {
|
|
9906
|
+
return widget.getWidgetParameters(state, rest);
|
|
9907
|
+
}
|
|
9498
9908
|
return widget.getWidgetSearchParameters(state, rest);
|
|
9499
9909
|
}, initialSearchParameters);
|
|
9500
9910
|
}
|
|
9911
|
+
function getLocalWidgetsRecommendParameters(widgets, widgetRecommendParametersOptions) {
|
|
9912
|
+
var initialRecommendParameters = widgetRecommendParametersOptions.initialRecommendParameters,
|
|
9913
|
+
rest = _objectWithoutProperties$3(widgetRecommendParametersOptions, _excluded2$1);
|
|
9914
|
+
return widgets.reduce(function (state, widget) {
|
|
9915
|
+
if (!isIndexWidget(widget) && widget.dependsOn === 'recommend' && widget.getWidgetParameters) {
|
|
9916
|
+
return widget.getWidgetParameters(state, rest);
|
|
9917
|
+
}
|
|
9918
|
+
return state;
|
|
9919
|
+
}, initialRecommendParameters);
|
|
9920
|
+
}
|
|
9501
9921
|
function resetPageFromWidgets(widgets) {
|
|
9502
9922
|
var indexWidgets = widgets.filter(isIndexWidget);
|
|
9503
9923
|
if (indexWidgets.length === 0) {
|
|
@@ -9507,6 +9927,7 @@
|
|
|
9507
9927
|
var widgetHelper = widget.getHelper();
|
|
9508
9928
|
privateHelperSetState(widgetHelper, {
|
|
9509
9929
|
state: widgetHelper.state.resetPage(),
|
|
9930
|
+
recommendState: widgetHelper.recommendState,
|
|
9510
9931
|
isPageReset: true
|
|
9511
9932
|
});
|
|
9512
9933
|
resetPageFromWidgets(widget.getWidgets());
|
|
@@ -9565,9 +9986,18 @@
|
|
|
9565
9986
|
},
|
|
9566
9987
|
getScopedResults: function getScopedResults() {
|
|
9567
9988
|
var widgetParent = this.getParent();
|
|
9568
|
-
|
|
9569
|
-
|
|
9570
|
-
|
|
9989
|
+
var widgetSiblings;
|
|
9990
|
+
if (widgetParent) {
|
|
9991
|
+
widgetSiblings = widgetParent.getWidgets();
|
|
9992
|
+
} else if (indexName.length === 0) {
|
|
9993
|
+
// The widget is the root but has no index name:
|
|
9994
|
+
// we resolve results from its children index widgets
|
|
9995
|
+
widgetSiblings = this.getWidgets();
|
|
9996
|
+
} else {
|
|
9997
|
+
// The widget is the root and has an index name:
|
|
9998
|
+
// we consider itself as the only sibling
|
|
9999
|
+
widgetSiblings = [this];
|
|
10000
|
+
}
|
|
9571
10001
|
return resolveScopedResultsFromWidgets(widgetSiblings);
|
|
9572
10002
|
},
|
|
9573
10003
|
getParent: function getParent() {
|
|
@@ -9602,6 +10032,10 @@
|
|
|
9602
10032
|
uiState: localUiState,
|
|
9603
10033
|
initialSearchParameters: helper.state
|
|
9604
10034
|
}),
|
|
10035
|
+
recommendState: getLocalWidgetsRecommendParameters(localWidgets, {
|
|
10036
|
+
uiState: localUiState,
|
|
10037
|
+
initialRecommendParameters: helper.recommendState
|
|
10038
|
+
}),
|
|
9605
10039
|
_uiState: localUiState
|
|
9606
10040
|
});
|
|
9607
10041
|
|
|
@@ -9698,11 +10132,16 @@
|
|
|
9698
10132
|
index: indexName
|
|
9699
10133
|
})
|
|
9700
10134
|
});
|
|
10135
|
+
var recommendParameters = getLocalWidgetsRecommendParameters(localWidgets, {
|
|
10136
|
+
uiState: localUiState,
|
|
10137
|
+
initialRecommendParameters: new algoliasearchHelper_1.RecommendParameters()
|
|
10138
|
+
});
|
|
9701
10139
|
|
|
9702
10140
|
// This Helper is only used for state management we do not care about the
|
|
9703
10141
|
// `searchClient`. Only the "main" Helper created at the `InstantSearch`
|
|
9704
10142
|
// level is aware of the client.
|
|
9705
10143
|
helper = algoliasearchHelper_1({}, parameters.index, parameters);
|
|
10144
|
+
helper.recommendState = recommendParameters;
|
|
9706
10145
|
|
|
9707
10146
|
// We forward the call to `search` to the "main" instance of the Helper
|
|
9708
10147
|
// which is responsible for managing the queries (it's the only one that is
|
|
@@ -9733,6 +10172,8 @@
|
|
|
9733
10172
|
};
|
|
9734
10173
|
derivedHelper = mainHelper.derive(function () {
|
|
9735
10174
|
return mergeSearchParameters.apply(void 0, [mainHelper.state].concat(_toConsumableArray$1(resolveSearchParameters(_this3))));
|
|
10175
|
+
}, function () {
|
|
10176
|
+
return _this3.getHelper().recommendState;
|
|
9736
10177
|
});
|
|
9737
10178
|
var indexInitialResults = (_instantSearchInstanc = instantSearchInstance._initialResults) === null || _instantSearchInstanc === void 0 ? void 0 : _instantSearchInstanc[this.getIndexId()];
|
|
9738
10179
|
if (indexInitialResults) {
|
|
@@ -9775,6 +10216,21 @@
|
|
|
9775
10216
|
lastValidSearchParameters = results === null || results === void 0 ? void 0 : results._state;
|
|
9776
10217
|
});
|
|
9777
10218
|
|
|
10219
|
+
// eslint-disable-next-line no-warning-comments
|
|
10220
|
+
// TODO: listen to "result" event when events for Recommend are implemented
|
|
10221
|
+
derivedHelper.on('recommend:result', function (_ref5) {
|
|
10222
|
+
var recommend = _ref5.recommend;
|
|
10223
|
+
// The index does not render the results it schedules a new render
|
|
10224
|
+
// to let all the other indices emit their own results. It allows us to
|
|
10225
|
+
// run the render process in one pass.
|
|
10226
|
+
instantSearchInstance.scheduleRender();
|
|
10227
|
+
|
|
10228
|
+
// the derived helper is the one which actually searches, but the helper
|
|
10229
|
+
// which is exposed e.g. via instance.helper, doesn't search, and thus
|
|
10230
|
+
// does not have access to lastRecommendResults.
|
|
10231
|
+
helper.lastRecommendResults = recommend.results;
|
|
10232
|
+
});
|
|
10233
|
+
|
|
9778
10234
|
// We compute the render state before calling `init` in a separate loop
|
|
9779
10235
|
// to construct the whole render state object that is then passed to
|
|
9780
10236
|
// `init`.
|
|
@@ -9821,9 +10277,9 @@
|
|
|
9821
10277
|
instantSearchInstance.scheduleRender();
|
|
9822
10278
|
}
|
|
9823
10279
|
},
|
|
9824
|
-
render: function render(
|
|
10280
|
+
render: function render(_ref6) {
|
|
9825
10281
|
var _this4 = this;
|
|
9826
|
-
var instantSearchInstance =
|
|
10282
|
+
var instantSearchInstance = _ref6.instantSearchInstance;
|
|
9827
10283
|
// we can't attach a listener to the error event of search, as the error
|
|
9828
10284
|
// then would no longer be thrown for global handlers.
|
|
9829
10285
|
if (instantSearchInstance.status === 'error' && !instantSearchInstance.mainHelper.hasPendingRequests() && lastValidSearchParameters) {
|
|
@@ -9833,6 +10289,14 @@
|
|
|
9833
10289
|
// We only render index widgets if there are no results.
|
|
9834
10290
|
// This makes sure `render` is never called with `results` being `null`.
|
|
9835
10291
|
var widgetsToRender = this.getResults() ? localWidgets : localWidgets.filter(isIndexWidget);
|
|
10292
|
+
widgetsToRender = widgetsToRender.filter(function (widget) {
|
|
10293
|
+
if (!widget.shouldRender) {
|
|
10294
|
+
return true;
|
|
10295
|
+
}
|
|
10296
|
+
return widget.shouldRender({
|
|
10297
|
+
instantSearchInstance: instantSearchInstance
|
|
10298
|
+
});
|
|
10299
|
+
});
|
|
9836
10300
|
widgetsToRender.forEach(function (widget) {
|
|
9837
10301
|
if (widget.getRenderState) {
|
|
9838
10302
|
var renderState = widget.getRenderState(instantSearchInstance.renderState[_this4.getIndexId()] || {}, createRenderArgs(instantSearchInstance, _this4));
|
|
@@ -9890,8 +10354,8 @@
|
|
|
9890
10354
|
getWidgetState: function getWidgetState(uiState) {
|
|
9891
10355
|
return this.getWidgetUiState(uiState);
|
|
9892
10356
|
},
|
|
9893
|
-
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters,
|
|
9894
|
-
var uiState =
|
|
10357
|
+
getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref7) {
|
|
10358
|
+
var uiState = _ref7.uiState;
|
|
9895
10359
|
return getLocalWidgetsSearchParameters(localWidgets, {
|
|
9896
10360
|
uiState: uiState,
|
|
9897
10361
|
initialSearchParameters: searchParameters
|
|
@@ -9911,10 +10375,10 @@
|
|
|
9911
10375
|
}
|
|
9912
10376
|
};
|
|
9913
10377
|
};
|
|
9914
|
-
function storeRenderState(
|
|
9915
|
-
var renderState =
|
|
9916
|
-
instantSearchInstance =
|
|
9917
|
-
parent =
|
|
10378
|
+
function storeRenderState(_ref8) {
|
|
10379
|
+
var renderState = _ref8.renderState,
|
|
10380
|
+
instantSearchInstance = _ref8.instantSearchInstance,
|
|
10381
|
+
parent = _ref8.parent;
|
|
9918
10382
|
var parentIndexName = parent ? parent.getIndexId() : instantSearchInstance.mainIndex.getIndexId();
|
|
9919
10383
|
instantSearchInstance.renderState = _objectSpread$d(_objectSpread$d({}, instantSearchInstance.renderState), {}, _defineProperty$d({}, parentIndexName, _objectSpread$d(_objectSpread$d({}, instantSearchInstance.renderState[parentIndexName]), renderState)));
|
|
9920
10384
|
}
|
|
@@ -12256,7 +12720,7 @@
|
|
|
12256
12720
|
};
|
|
12257
12721
|
}
|
|
12258
12722
|
|
|
12259
|
-
var version$3 = '4.
|
|
12723
|
+
var version$3 = '4.68.0';
|
|
12260
12724
|
|
|
12261
12725
|
function _typeof$o(obj) {
|
|
12262
12726
|
"@babel/helpers - typeof";
|
|
@@ -12750,7 +13214,7 @@
|
|
|
12750
13214
|
// under the hood, we have a different implementation. It should be
|
|
12751
13215
|
// completely transparent for the rest of the codebase. Only this module
|
|
12752
13216
|
// is impacted.
|
|
12753
|
-
return mainHelper.searchOnlyWithDerivedHelpers();
|
|
13217
|
+
return mainHelper.searchOnlyWithDerivedHelpers() && mainHelper.recommend();
|
|
12754
13218
|
};
|
|
12755
13219
|
if (this._searchFunction) {
|
|
12756
13220
|
// this client isn't used to actually search, but required for the helper
|
|
@@ -14884,6 +15348,7 @@
|
|
|
14884
15348
|
});
|
|
14885
15349
|
},
|
|
14886
15350
|
getWidgetRenderState: function getWidgetRenderState(_ref2) {
|
|
15351
|
+
var _results$renderingCon, _results$renderingCon2, _results$renderingCon3;
|
|
14887
15352
|
var results = _ref2.results,
|
|
14888
15353
|
helper = _ref2.helper,
|
|
14889
15354
|
instantSearchInstance = _ref2.instantSearchInstance;
|
|
@@ -14909,6 +15374,7 @@
|
|
|
14909
15374
|
return {
|
|
14910
15375
|
hits: [],
|
|
14911
15376
|
results: undefined,
|
|
15377
|
+
banner: undefined,
|
|
14912
15378
|
sendEvent: sendEvent,
|
|
14913
15379
|
bindEvent: bindEvent,
|
|
14914
15380
|
widgetParams: widgetParams
|
|
@@ -14922,9 +15388,11 @@
|
|
|
14922
15388
|
var transformedHits = transformItems(hitsWithAbsolutePositionAndQueryID, {
|
|
14923
15389
|
results: results
|
|
14924
15390
|
});
|
|
15391
|
+
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];
|
|
14925
15392
|
return {
|
|
14926
15393
|
hits: transformedHits,
|
|
14927
15394
|
results: results,
|
|
15395
|
+
banner: banner,
|
|
14928
15396
|
sendEvent: sendEvent,
|
|
14929
15397
|
bindEvent: bindEvent,
|
|
14930
15398
|
widgetParams: widgetParams
|
|
@@ -15188,7 +15656,7 @@
|
|
|
15188
15656
|
}, _typeof$y(obj);
|
|
15189
15657
|
}
|
|
15190
15658
|
var _excluded$9 = ["page"],
|
|
15191
|
-
_excluded2$
|
|
15659
|
+
_excluded2$2 = ["clickAnalytics", "userToken"];
|
|
15192
15660
|
function ownKeys$s(object, enumerableOnly) {
|
|
15193
15661
|
var keys = Object.keys(object);
|
|
15194
15662
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -15304,7 +15772,7 @@
|
|
|
15304
15772
|
var _ref2 = state || {},
|
|
15305
15773
|
clickAnalytics = _ref2.clickAnalytics,
|
|
15306
15774
|
userToken = _ref2.userToken,
|
|
15307
|
-
rest = _objectWithoutProperties$9(_ref2, _excluded2$
|
|
15775
|
+
rest = _objectWithoutProperties$9(_ref2, _excluded2$2);
|
|
15308
15776
|
return rest;
|
|
15309
15777
|
}
|
|
15310
15778
|
function getInMemoryCache() {
|
|
@@ -17243,7 +17711,7 @@
|
|
|
17243
17711
|
}, _typeof$F(obj);
|
|
17244
17712
|
}
|
|
17245
17713
|
var _excluded$b = ["name", "escapedValue"],
|
|
17246
|
-
_excluded2$
|
|
17714
|
+
_excluded2$3 = ["escapedValue", "value"];
|
|
17247
17715
|
function ownKeys$y(object, enumerableOnly) {
|
|
17248
17716
|
var keys = Object.keys(object);
|
|
17249
17717
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -17428,7 +17896,7 @@
|
|
|
17428
17896
|
var normalizedFacetValues = transformItems(facetValues.map(function (_ref3) {
|
|
17429
17897
|
var escapedValue = _ref3.escapedValue,
|
|
17430
17898
|
value = _ref3.value,
|
|
17431
|
-
item = _objectWithoutProperties$b(_ref3, _excluded2$
|
|
17899
|
+
item = _objectWithoutProperties$b(_ref3, _excluded2$3);
|
|
17432
17900
|
return _objectSpread$y(_objectSpread$y({}, item), {}, {
|
|
17433
17901
|
value: escapedValue,
|
|
17434
17902
|
label: value
|
|
@@ -18521,6 +18989,14 @@
|
|
|
18521
18989
|
results: results,
|
|
18522
18990
|
scopedResults: searchIndex.getScopedResults()
|
|
18523
18991
|
});
|
|
18992
|
+
} else if (search.mainIndex.getIndexName().length === 0) {
|
|
18993
|
+
// If the main index has no name, we get the scoped results from
|
|
18994
|
+
// the first child index instead.
|
|
18995
|
+
var childIndex = search.mainIndex.getWidgets().find(isIndexWidget);
|
|
18996
|
+
childIndex && setSearchResults({
|
|
18997
|
+
results: getIndexSearchResults(searchIndex).results,
|
|
18998
|
+
scopedResults: childIndex.getScopedResults()
|
|
18999
|
+
});
|
|
18524
19000
|
}
|
|
18525
19001
|
}
|
|
18526
19002
|
search.addListener('render', handleRender);
|
|
@@ -19185,12 +19661,43 @@
|
|
|
19185
19661
|
};
|
|
19186
19662
|
}
|
|
19187
19663
|
|
|
19188
|
-
var _excluded$d = ["classNames", "hits", "itemComponent", "sendEvent", "emptyComponent"];
|
|
19664
|
+
var _excluded$d = ["classNames", "hits", "itemComponent", "sendEvent", "emptyComponent", "banner", "bannerComponent"];
|
|
19189
19665
|
|
|
19190
19666
|
// Should be imported from a shared package in the future
|
|
19191
19667
|
|
|
19192
|
-
function
|
|
19668
|
+
function createDefaultBannerComponent(_ref) {
|
|
19193
19669
|
var createElement = _ref.createElement;
|
|
19670
|
+
return function DefaultBanner(_ref2) {
|
|
19671
|
+
var _banner$link;
|
|
19672
|
+
var classNames = _ref2.classNames,
|
|
19673
|
+
banner = _ref2.banner;
|
|
19674
|
+
if (!banner.image.urls[0].url) {
|
|
19675
|
+
return null;
|
|
19676
|
+
}
|
|
19677
|
+
return createElement("aside", {
|
|
19678
|
+
className: cx('ais-Hits-banner', classNames.bannerRoot)
|
|
19679
|
+
}, (_banner$link = banner.link) !== null && _banner$link !== void 0 && _banner$link.url ? createElement("a", {
|
|
19680
|
+
className: cx('ais-Hits-banner-link', classNames.bannerLink),
|
|
19681
|
+
href: banner.link.url,
|
|
19682
|
+
target: banner.link.target
|
|
19683
|
+
}, createElement("img", {
|
|
19684
|
+
className: cx('ais-Hits-banner-image', classNames.bannerImage),
|
|
19685
|
+
src: banner.image.urls[0].url,
|
|
19686
|
+
alt: banner.image.title
|
|
19687
|
+
})) : createElement("img", {
|
|
19688
|
+
className: cx('ais-Hits-banner-image', classNames.bannerImage),
|
|
19689
|
+
src: banner.image.urls[0].url,
|
|
19690
|
+
alt: banner.image.title
|
|
19691
|
+
}));
|
|
19692
|
+
};
|
|
19693
|
+
}
|
|
19694
|
+
function createHitsComponent(_ref3) {
|
|
19695
|
+
var createElement = _ref3.createElement,
|
|
19696
|
+
Fragment = _ref3.Fragment;
|
|
19697
|
+
var DefaultBannerComponent = createDefaultBannerComponent({
|
|
19698
|
+
createElement: createElement,
|
|
19699
|
+
Fragment: Fragment
|
|
19700
|
+
});
|
|
19194
19701
|
return function Hits(userProps) {
|
|
19195
19702
|
var _userProps$classNames = userProps.classNames,
|
|
19196
19703
|
classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames,
|
|
@@ -19198,15 +19705,18 @@
|
|
|
19198
19705
|
ItemComponent = userProps.itemComponent,
|
|
19199
19706
|
sendEvent = userProps.sendEvent,
|
|
19200
19707
|
EmptyComponent = userProps.emptyComponent,
|
|
19708
|
+
banner = userProps.banner,
|
|
19709
|
+
BannerComponent = userProps.bannerComponent,
|
|
19201
19710
|
props = _objectWithoutProperties$d(userProps, _excluded$d);
|
|
19202
|
-
if (hits.length === 0 && EmptyComponent) {
|
|
19203
|
-
return createElement(EmptyComponent, {
|
|
19204
|
-
className: cx('ais-Hits', classNames.root, cx('ais-Hits--empty', classNames.emptyRoot), props.className)
|
|
19205
|
-
});
|
|
19206
|
-
}
|
|
19207
19711
|
return createElement("div", _extends$2({}, props, {
|
|
19208
19712
|
className: cx('ais-Hits', classNames.root, hits.length === 0 && cx('ais-Hits--empty', classNames.emptyRoot), props.className)
|
|
19209
|
-
}), createElement(
|
|
19713
|
+
}), banner && (BannerComponent ? createElement(BannerComponent, {
|
|
19714
|
+
className: cx('ais-Hits-banner', classNames.bannerRoot),
|
|
19715
|
+
banner: banner
|
|
19716
|
+
}) : createElement(DefaultBannerComponent, {
|
|
19717
|
+
classNames: classNames,
|
|
19718
|
+
banner: banner
|
|
19719
|
+
})), hits.length === 0 && EmptyComponent ? createElement(EmptyComponent, null) : createElement("ol", {
|
|
19210
19720
|
className: cx('ais-Hits-list', classNames.list)
|
|
19211
19721
|
}, hits.map(function (hit, index) {
|
|
19212
19722
|
return createElement(ItemComponent, {
|
|
@@ -19592,7 +20102,7 @@
|
|
|
19592
20102
|
}
|
|
19593
20103
|
|
|
19594
20104
|
var _excluded$p = ["escapeHTML", "transformItems", "hitComponent"],
|
|
19595
|
-
_excluded2$
|
|
20105
|
+
_excluded2$4 = ["hit", "index"];
|
|
19596
20106
|
// @MAJOR: Move default hit component back to the UI library
|
|
19597
20107
|
// once flavour specificities are erased
|
|
19598
20108
|
function DefaultHitComponent(_ref) {
|
|
@@ -19624,7 +20134,7 @@
|
|
|
19624
20134
|
var itemComponent = function itemComponent(_ref3) {
|
|
19625
20135
|
var hit = _ref3.hit,
|
|
19626
20136
|
index = _ref3.index,
|
|
19627
|
-
itemProps = _objectWithoutProperties$c(_ref3, _excluded2$
|
|
20137
|
+
itemProps = _objectWithoutProperties$c(_ref3, _excluded2$4);
|
|
19628
20138
|
return /*#__PURE__*/React__default.createElement("li", _extends$1({
|
|
19629
20139
|
key: hit.objectID
|
|
19630
20140
|
}, itemProps), /*#__PURE__*/React__default.createElement(HitComponent, {
|
|
@@ -19872,7 +20382,7 @@
|
|
|
19872
20382
|
}
|
|
19873
20383
|
|
|
19874
20384
|
var _excluded$w = ["pages", "currentPage", "nbPages", "isFirstPage", "isLastPage", "showFirst", "showPrevious", "showNext", "showLast", "createURL", "onNavigate", "translations", "classNames"],
|
|
19875
|
-
_excluded2$
|
|
20385
|
+
_excluded2$5 = ["isDisabled", "className", "classNames", "href", "onClick"];
|
|
19876
20386
|
function Pagination(_ref) {
|
|
19877
20387
|
var pages = _ref.pages,
|
|
19878
20388
|
currentPage = _ref.currentPage,
|
|
@@ -19963,7 +20473,7 @@
|
|
|
19963
20473
|
classNames = _ref2.classNames,
|
|
19964
20474
|
href = _ref2.href,
|
|
19965
20475
|
_onClick = _ref2.onClick,
|
|
19966
|
-
props = _objectWithoutProperties$c(_ref2, _excluded2$
|
|
20476
|
+
props = _objectWithoutProperties$c(_ref2, _excluded2$5);
|
|
19967
20477
|
if (isDisabled) {
|
|
19968
20478
|
return /*#__PURE__*/React__default.createElement("li", {
|
|
19969
20479
|
className: cx('ais-Pagination-item', classNames.item, 'ais-Pagination-item--disabled', classNames.disabledItem, className)
|