react-instantsearch 7.7.0 → 7.7.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.
@@ -31,7 +31,7 @@ function RefinementList(_ref) {
31
31
  translations = _ref.translations,
32
32
  props = _objectWithoutProperties(_ref, _excluded);
33
33
  return /*#__PURE__*/_react.default.createElement("div", _extends({}, props, {
34
- className: (0, _instantsearchUiComponents.cx)('ais-RefinementList', classNames.root, !canRefine && (0, _instantsearchUiComponents.cx)('ais-RefinementList--noRefinement', classNames.noRefinementRoot), className)
34
+ className: (0, _instantsearchUiComponents.cx)('ais-RefinementList', classNames.root, items.length === 0 && (0, _instantsearchUiComponents.cx)('ais-RefinementList--noRefinement', classNames.noRefinementRoot), className)
35
35
  }), searchBox && /*#__PURE__*/_react.default.createElement("div", {
36
36
  className: (0, _instantsearchUiComponents.cx)('ais-RefinementList-searchBox', classNames.searchBox)
37
37
  }, searchBox), noResults ? /*#__PURE__*/_react.default.createElement("div", {
@@ -24,7 +24,7 @@ export function RefinementList(_ref) {
24
24
  translations = _ref.translations,
25
25
  props = _objectWithoutProperties(_ref, _excluded);
26
26
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
27
- className: cx('ais-RefinementList', classNames.root, !canRefine && cx('ais-RefinementList--noRefinement', classNames.noRefinementRoot), className)
27
+ className: cx('ais-RefinementList', classNames.root, items.length === 0 && cx('ais-RefinementList--noRefinement', classNames.noRefinementRoot), className)
28
28
  }), searchBox && /*#__PURE__*/React.createElement("div", {
29
29
  className: cx('ais-RefinementList-searchBox', classNames.searchBox)
30
30
  }, searchBox), noResults ? /*#__PURE__*/React.createElement("div", {
@@ -7,7 +7,7 @@
7
7
 
8
8
  var React__default = 'default' in React ? React['default'] : React;
9
9
 
10
- var version = '7.7.0';
10
+ var version = '7.7.1';
11
11
 
12
12
  // Copyright Joyent, Inc. and other Node contributors.
13
13
  //
@@ -497,6 +497,42 @@
497
497
 
498
498
  var omit = _objectWithoutPropertiesLoose;
499
499
 
500
+ /**
501
+ * RecommendParameters is the data structure that contains all the information
502
+ * usable for getting recommendations from the Algolia API. It doesn't do the
503
+ * search itself, nor does it contains logic about the parameters.
504
+ * It is an immutable object, therefore it has been created in a way that each
505
+ * changes does not change the object itself but returns a copy with the
506
+ * modification.
507
+ * This object should probably not be instantiated outside of the helper. It
508
+ * will be provided when needed.
509
+ * @constructor
510
+ * @classdesc contains all the parameters for recommendations
511
+ * @param {RecommendParametersOptions} opts the options to create the object
512
+ */
513
+ function RecommendParameters(opts) {
514
+ opts = opts || {};
515
+ this.params = opts.params || [];
516
+ }
517
+
518
+ RecommendParameters.prototype = {
519
+ constructor: RecommendParameters,
520
+
521
+ addParams: function (params) {
522
+ return new RecommendParameters({ params: this.params.concat(params) });
523
+ },
524
+
525
+ removeParams: function (id) {
526
+ return new RecommendParameters({
527
+ params: this.params.filter(function (param) {
528
+ return param.$$id !== id;
529
+ }),
530
+ });
531
+ },
532
+ };
533
+
534
+ var RecommendParameters_1 = RecommendParameters;
535
+
500
536
  function sortObject(obj) {
501
537
  return Object.keys(obj)
502
538
  .sort()
@@ -4344,7 +4380,7 @@
4344
4380
 
4345
4381
  var SearchResults_1 = SearchResults;
4346
4382
 
4347
- var version$1 = '3.16.3';
4383
+ var version$1 = '3.17.0';
4348
4384
 
4349
4385
  var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
4350
4386
 
@@ -4356,6 +4392,7 @@
4356
4392
 
4357
4393
 
4358
4394
 
4395
+
4359
4396
  /**
4360
4397
  * Event triggered when a parameter is set or updated
4361
4398
  * @event AlgoliaSearchHelper#event:change
@@ -4469,6 +4506,9 @@
4469
4506
  var opts = options || {};
4470
4507
  opts.index = index;
4471
4508
  this.state = SearchParameters_1.make(opts);
4509
+ this.recommendState = new RecommendParameters_1({
4510
+ params: opts.recommendState,
4511
+ });
4472
4512
  this.lastResults = null;
4473
4513
  this._queryId = 0;
4474
4514
  this._lastQueryIdReceived = -1;
@@ -5852,6 +5892,17 @@
5852
5892
  }
5853
5893
  };
5854
5894
 
5895
+ AlgoliaSearchHelper.prototype._recommendChange = function (event) {
5896
+ var state = event.state;
5897
+
5898
+ if (state !== this.recommendState) {
5899
+ this.recommendState = state;
5900
+
5901
+ // eslint-disable-next-line no-warning-comments
5902
+ // TODO: emit "change" event when events for Recommend are implemented
5903
+ }
5904
+ };
5905
+
5855
5906
  /**
5856
5907
  * Clears the cache of the underlying Algolia client.
5857
5908
  * @return {AlgoliaSearchHelper} Method is chainable, it returns itself
@@ -8631,7 +8682,7 @@
8631
8682
 
8632
8683
  // Scenario 1: the widget is added for the first time.
8633
8684
  if (!cleanupTimerRef.current) {
8634
- if (!shouldAddWidgetEarly) {
8685
+ if (!shouldSsr) {
8635
8686
  parentIndex.addWidgets([widget]);
8636
8687
  }
8637
8688
  }
@@ -8668,7 +8719,7 @@
8668
8719
  });
8669
8720
  });
8670
8721
  };
8671
- }, [parentIndex, widget, shouldAddWidgetEarly, search, props]);
8722
+ }, [parentIndex, widget, shouldSsr, search, props]);
8672
8723
  if (shouldAddWidgetEarly || (waitingForResultsRef === null || waitingForResultsRef === void 0 ? void 0 : (_waitingForResultsRef = waitingForResultsRef.current) === null || _waitingForResultsRef === void 0 ? void 0 : _waitingForResultsRef.status) === 'pending') {
8673
8724
  parentIndex.addWidgets([widget]);
8674
8725
  }
@@ -12205,7 +12256,7 @@
12205
12256
  };
12206
12257
  }
12207
12258
 
12208
- var version$3 = '4.66.0';
12259
+ var version$3 = '4.66.1';
12209
12260
 
12210
12261
  function _typeof$o(obj) {
12211
12262
  "@babel/helpers - typeof";
@@ -14893,6 +14944,8 @@
14893
14944
  if (!escapeHTML) {
14894
14945
  return state;
14895
14946
  }
14947
+
14948
+ // @MAJOR: set this globally, not in the Hits widget to allow Hits to be conditionally used
14896
14949
  return state.setQueryParameters(TAG_PLACEHOLDER);
14897
14950
  }
14898
14951
  };
@@ -15472,6 +15525,7 @@
15472
15525
  var uiState = _ref10.uiState;
15473
15526
  var widgetSearchParameters = searchParameters;
15474
15527
  if (escapeHTML) {
15528
+ // @MAJOR: set this globally, not in the InfiniteHits widget to allow InfiniteHits to be conditionally used
15475
15529
  widgetSearchParameters = searchParameters.setQueryParameters(TAG_PLACEHOLDER);
15476
15530
  }
15477
15531
 
@@ -20185,7 +20239,7 @@
20185
20239
  translations = _ref.translations,
20186
20240
  props = _objectWithoutProperties$c(_ref, _excluded$B);
20187
20241
  return /*#__PURE__*/React__default.createElement("div", _extends$1({}, props, {
20188
- className: cx('ais-RefinementList', classNames.root, !canRefine && cx('ais-RefinementList--noRefinement', classNames.noRefinementRoot), className)
20242
+ className: cx('ais-RefinementList', classNames.root, items.length === 0 && cx('ais-RefinementList--noRefinement', classNames.noRefinementRoot), className)
20189
20243
  }), searchBox && /*#__PURE__*/React__default.createElement("div", {
20190
20244
  className: cx('ais-RefinementList-searchBox', classNames.searchBox)
20191
20245
  }, searchBox), noResults ? /*#__PURE__*/React__default.createElement("div", {