react-instantsearch 7.0.1 → 7.0.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <!-- START doctoc generated TOC please keep comment here to allow auto update -->
2
2
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3
- **Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
3
+
4
4
 
5
5
  - [react-instantsearch](#react-instantsearch)
6
6
  - [Why](#why)
@@ -17,15 +17,15 @@
17
17
 
18
18
  React InstantSearch is an open-source React library that lets you create an instant search result experience using [Algolia][algolia-website]’s search API. It is part of the InstantSearch family:
19
19
 
20
- **React InstantSearch** | [InstantSearch.js][instantsearch.js-github] | [Angular InstantSearch][instantsearch-angular-github] | [Vue InstantSearch][instantsearch-vue-github] | [InstantSearch Android][instantsearch-android-github] | [InstantSearch iOS][instantsearch-ios-github]
20
+ **React InstantSearch** | [InstantSearch.js][instantsearch-github] | [Angular InstantSearch][instantsearch-angular-github] | [Vue InstantSearch][instantsearch-github] | [InstantSearch Android][instantsearch-android-github] | [InstantSearch iOS][instantsearch-ios-github]
21
21
 
22
22
  ## Why
23
23
 
24
24
  You should be using React InstantSearch if you want to:
25
25
 
26
- * Design search experiences with best practices
27
- * Customize your components at will
28
- * Follow React principles
26
+ - Design search experiences with best practices
27
+ - Customize your components at will
28
+ - Follow React principles
29
29
 
30
30
  Note: If you are working with React Native, or otherwise do not use the DOM, check out `react-instantsearch-core` instead.
31
31
 
@@ -55,10 +55,7 @@ const searchClient = algoliasearch(
55
55
  );
56
56
 
57
57
  const App = () => (
58
- <InstantSearch
59
- indexName="bestbuy"
60
- searchClient={searchClient}
61
- >
58
+ <InstantSearch indexName="bestbuy" searchClient={searchClient}>
62
59
  <SearchBox />
63
60
  <Hits />
64
61
  </InstantSearch>
@@ -66,7 +63,7 @@ const App = () => (
66
63
  ```
67
64
 
68
65
  <p align="center">
69
- <a href="https://codesandbox.io/s/github/algolia/instantsearch.js/tree/master/examples/react/default-theme" title="Edit on CodeSandbox">
66
+ <a href="https://codesandbox.io/s/github/algolia/instantsearch/tree/master/examples/react/default-theme" title="Edit on CodeSandbox">
70
67
  <img alt="Edit on CodeSandbox" src="https://codesandbox.io/static/img/play-codesandbox.svg">
71
68
  </a>
72
69
  </p>
@@ -98,7 +95,7 @@ To start contributing to code, you need to:
98
95
  1. [Clone the repository](https://help.github.com/articles/cloning-a-repository/)
99
96
  1. Install the dependencies: `yarn`
100
97
 
101
- Please read [our contribution process](https://github.com/algolia/instantsearch.js/blob/master/CONTRIBUTING.md) to learn more.
98
+ Please read [our contribution process](https://github.com/algolia/instantsearch/blob/master/CONTRIBUTING.md) to learn more.
102
99
 
103
100
  ## License
104
101
 
@@ -111,14 +108,13 @@ React InstantSearch is [MIT licensed](../../LICENSE).
111
108
  [doc-guides]: https://www.algolia.com/doc/guides/building-search-ui/going-further/server-side-rendering/react/
112
109
  [doc-playground]: https://codesandbox.io/s/github/algolia/instantsearch/tree/master/examples/react/default-theme
113
110
  [algolia-website]: https://www.algolia.com/
114
- [instantsearch.js-github]: https://github.com/algolia/instantsearch.js
111
+ [instantsearch-github]: https://github.com/algolia/instantsearch
115
112
  [instantsearch-android-github]: https://github.com/algolia/instantsearch-android
116
113
  [instantsearch-ios-github]: https://github.com/algolia/instantsearch-ios
117
- [instantsearch-vue-github]: https://github.com/algolia/vue-instantsearch
118
114
  [instantsearch-angular-github]: https://github.com/algolia/angular-instantsearch
119
- [contributing-bugreport]: https://github.com/algolia/instantsearch.js/issues/new?template=BUG_REPORT.yml&labels=triage,Library%3A%20React+InstantSearch
120
- [contributing-featurerequest]: https://github.com/algolia/instantsearch.js/discussions/new?category=ideas&labels=triage,Library%3A%20React+InstantSearch&title=Feature%20request%3A%20
121
- [contributing-newissue]: https://github.com/algolia/instantsearch.js/issues/new?labels=triage,Library%3A%20React+InstantSearch
122
- [contributing-label-easy]: https://github.com/algolia/instantsearch.js/issues?q=is%3Aopen+is%3Aissue+label%3A%22Difficulty%3A+Easy%22+label%3A%22Library%3A%20React+InstantSearch%22
123
- [contributing-label-bug]: https://github.com/algolia/instantsearch.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug%22+label%3A%22Library%3A%20React+InstantSearch%22
124
- [contributing-label-chore]: https://github.com/algolia/instantsearch.js/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Chore%22+label%3A%22Library%3A%20React+InstantSearch%22
115
+ [contributing-bugreport]: https://github.com/algolia/instantsearch/issues/new?template=BUG_REPORT.yml&labels=triage,Library%3A%20React+InstantSearch
116
+ [contributing-featurerequest]: https://github.com/algolia/instantsearch/discussions/new?category=ideas&labels=triage,Library%3A%20React+InstantSearch&title=Feature%20request%3A%20
117
+ [contributing-newissue]: https://github.com/algolia/instantsearch/issues/new?labels=triage,Library%3A%20React+InstantSearch
118
+ [contributing-label-easy]: https://github.com/algolia/instantsearch/issues?q=is%3Aopen+is%3Aissue+label%3A%22Difficulty%3A+Easy%22+label%3A%22Library%3A%20React+InstantSearch%22
119
+ [contributing-label-bug]: https://github.com/algolia/instantsearch/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Bug%22+label%3A%22Library%3A%20React+InstantSearch%22
120
+ [contributing-label-chore]: https://github.com/algolia/instantsearch/issues?q=is%3Aissue+is%3Aopen+label%3A%22Type%3A+Chore%22+label%3A%22Library%3A%20React+InstantSearch%22
@@ -5,8 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.CurrentRefinements = CurrentRefinements;
7
7
  var _react = _interopRequireDefault(require("react"));
8
- var _cx = require("./lib/cx");
9
- var _isModifierClick = require("./lib/isModifierClick");
8
+ var _lib = require("./lib");
10
9
  var _excluded = ["classNames", "items", "onRemove", "hasRefinements"];
11
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
11
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
@@ -23,30 +22,31 @@ function CurrentRefinements(_ref) {
23
22
  hasRefinements = _ref$hasRefinements === void 0 ? false : _ref$hasRefinements,
24
23
  props = _objectWithoutProperties(_ref, _excluded);
25
24
  return /*#__PURE__*/_react.default.createElement("div", _extends({}, props, {
26
- className: (0, _cx.cx)('ais-CurrentRefinements', classNames.root, !hasRefinements && (0, _cx.cx)('ais-CurrentRefinements--noRefinement', classNames.noRefinementRoot), props.className)
25
+ className: (0, _lib.cx)('ais-CurrentRefinements', classNames.root, !hasRefinements && (0, _lib.cx)('ais-CurrentRefinements--noRefinement', classNames.noRefinementRoot), props.className)
27
26
  }), /*#__PURE__*/_react.default.createElement("ul", {
28
- className: (0, _cx.cx)('ais-CurrentRefinements-list', classNames.list, !hasRefinements && (0, _cx.cx)('ais-CurrentRefinements-list--noRefinement', classNames.noRefinementList))
27
+ className: (0, _lib.cx)('ais-CurrentRefinements-list', classNames.list, /* @MAJOR remove to ensure conformity with InstantSearch.css specs */
28
+ !hasRefinements && (0, _lib.cx)('ais-CurrentRefinements-list--noRefinement', classNames.noRefinementList))
29
29
  }, items.map(function (item) {
30
30
  return /*#__PURE__*/_react.default.createElement("li", {
31
31
  key: [item.indexName, item.label].join('/'),
32
- className: (0, _cx.cx)('ais-CurrentRefinements-item', classNames.item)
32
+ className: (0, _lib.cx)('ais-CurrentRefinements-item', classNames.item)
33
33
  }, /*#__PURE__*/_react.default.createElement("span", {
34
- className: (0, _cx.cx)('ais-CurrentRefinements-label', classNames.label)
35
- }, item.label, ":"), item.refinements.map(function (refinement) {
34
+ className: (0, _lib.cx)('ais-CurrentRefinements-label', classNames.label)
35
+ }, (0, _lib.capitalize)(item.label), ":", ' '), item.refinements.map(function (refinement) {
36
36
  return /*#__PURE__*/_react.default.createElement("span", {
37
37
  key: refinement.label,
38
- className: (0, _cx.cx)('ais-CurrentRefinements-category', classNames.category)
38
+ className: (0, _lib.cx)('ais-CurrentRefinements-category', classNames.category)
39
39
  }, /*#__PURE__*/_react.default.createElement("span", {
40
- className: (0, _cx.cx)('ais-CurrentRefinements-categoryLabel', classNames.categoryLabel)
40
+ className: (0, _lib.cx)('ais-CurrentRefinements-categoryLabel', classNames.categoryLabel)
41
41
  }, refinement.label), /*#__PURE__*/_react.default.createElement("button", {
42
42
  type: "button",
43
43
  onClick: function onClick(event) {
44
- if ((0, _isModifierClick.isModifierClick)(event)) {
44
+ if ((0, _lib.isModifierClick)(event)) {
45
45
  return;
46
46
  }
47
47
  onRemove(refinement);
48
48
  },
49
- className: (0, _cx.cx)('ais-CurrentRefinements-delete', classNames.delete)
49
+ className: (0, _lib.cx)('ais-CurrentRefinements-delete', classNames.delete)
50
50
  }, "\u2715"));
51
51
  }));
52
52
  })));
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.capitalize = capitalize;
7
+ function capitalize(text) {
8
+ return text.toString().charAt(0).toUpperCase() + text.toString().slice(1);
9
+ }
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _capitalize = require("./capitalize");
7
+ Object.keys(_capitalize).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _capitalize[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function get() {
13
+ return _capitalize[key];
14
+ }
15
+ });
16
+ });
17
+ var _cx = require("./cx");
18
+ Object.keys(_cx).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _cx[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function get() {
24
+ return _cx[key];
25
+ }
26
+ });
27
+ });
28
+ var _isModifierClick = require("./isModifierClick");
29
+ Object.keys(_isModifierClick).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _isModifierClick[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _isModifierClick[key];
36
+ }
37
+ });
38
+ });
@@ -3,8 +3,7 @@ function _extends() { _extends = Object.assign ? Object.assign.bind() : function
3
3
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
4
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
5
  import React from 'react';
6
- import { cx } from "./lib/cx.js";
7
- import { isModifierClick } from "./lib/isModifierClick.js";
6
+ import { capitalize, cx, isModifierClick } from "./lib/index.js";
8
7
  export function CurrentRefinements(_ref) {
9
8
  var _ref$classNames = _ref.classNames,
10
9
  classNames = _ref$classNames === void 0 ? {} : _ref$classNames,
@@ -18,14 +17,15 @@ export function CurrentRefinements(_ref) {
18
17
  return /*#__PURE__*/React.createElement("div", _extends({}, props, {
19
18
  className: cx('ais-CurrentRefinements', classNames.root, !hasRefinements && cx('ais-CurrentRefinements--noRefinement', classNames.noRefinementRoot), props.className)
20
19
  }), /*#__PURE__*/React.createElement("ul", {
21
- className: cx('ais-CurrentRefinements-list', classNames.list, !hasRefinements && cx('ais-CurrentRefinements-list--noRefinement', classNames.noRefinementList))
20
+ className: cx('ais-CurrentRefinements-list', classNames.list, /* @MAJOR remove to ensure conformity with InstantSearch.css specs */
21
+ !hasRefinements && cx('ais-CurrentRefinements-list--noRefinement', classNames.noRefinementList))
22
22
  }, items.map(function (item) {
23
23
  return /*#__PURE__*/React.createElement("li", {
24
24
  key: [item.indexName, item.label].join('/'),
25
25
  className: cx('ais-CurrentRefinements-item', classNames.item)
26
26
  }, /*#__PURE__*/React.createElement("span", {
27
27
  className: cx('ais-CurrentRefinements-label', classNames.label)
28
- }, item.label, ":"), item.refinements.map(function (refinement) {
28
+ }, capitalize(item.label), ":", ' '), item.refinements.map(function (refinement) {
29
29
  return /*#__PURE__*/React.createElement("span", {
30
30
  key: refinement.label,
31
31
  className: cx('ais-CurrentRefinements-category', classNames.category)
@@ -0,0 +1 @@
1
+ export declare function capitalize(text: string): string;
@@ -0,0 +1,3 @@
1
+ export function capitalize(text) {
2
+ return text.toString().charAt(0).toUpperCase() + text.toString().slice(1);
3
+ }
@@ -0,0 +1,3 @@
1
+ export * from './capitalize';
2
+ export * from './cx';
3
+ export * from './isModifierClick';
@@ -0,0 +1,3 @@
1
+ export * from "./capitalize.js";
2
+ export * from "./cx.js";
3
+ export * from "./isModifierClick.js";
@@ -1,4 +1,4 @@
1
- /*! React InstantSearch UNRELEASED | © Algolia, inc. | https://github.com/algolia/instantsearch.js */
1
+ /*! React InstantSearch UNRELEASED | © Algolia, inc. | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
4
4
  typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
@@ -7,7 +7,7 @@
7
7
 
8
8
  var React__default = 'default' in React ? React['default'] : React;
9
9
 
10
- var version = '7.0.1';
10
+ var version = '7.0.3';
11
11
 
12
12
  // Copyright Joyent, Inc. and other Node contributors.
13
13
  //
@@ -4327,7 +4327,7 @@
4327
4327
 
4328
4328
  var SearchResults_1 = SearchResults;
4329
4329
 
4330
- var version$1 = '3.14.0';
4330
+ var version$1 = '3.14.1';
4331
4331
 
4332
4332
  var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
4333
4333
 
@@ -8522,7 +8522,7 @@
8522
8522
 
8523
8523
  // We get the widget render state by providing the same parameters as
8524
8524
  // InstantSearch provides to the widget's `render` method.
8525
- // See https://github.com/algolia/instantsearch.js/blob/019cd18d0de6dd320284aa4890541b7fe2198c65/src/widgets/index/index.ts#L604-L617
8525
+ // See https://github.com/algolia/instantsearch/blob/019cd18d0de6dd320284aa4890541b7fe2198c65/src/widgets/index/index.ts#L604-L617
8526
8526
  var _widget$getWidgetRend = widget.getWidgetRenderState({
8527
8527
  helper: helper,
8528
8528
  parent: parentIndex,
@@ -9369,7 +9369,7 @@
9369
9369
  // configuration step. This is mainly for backward compatibility with custom
9370
9370
  // widgets. When the subscription happens before the `init` step, the (static)
9371
9371
  // configuration of the widget is pushed in the URL. That's what we want to avoid.
9372
- // https://github.com/algolia/instantsearch.js/pull/994/commits/4a672ae3fd78809e213de0368549ef12e9dc9454
9372
+ // https://github.com/algolia/instantsearch/pull/994/commits/4a672ae3fd78809e213de0368549ef12e9dc9454
9373
9373
  helper.on('change', function (event) {
9374
9374
  var state = event.state;
9375
9375
  var _uiState = event._uiState;
@@ -11271,7 +11271,7 @@
11271
11271
  *
11272
11272
  * It always generates the full URL, not a relative one.
11273
11273
  * This allows to handle cases like using a <base href>.
11274
- * See: https://github.com/algolia/instantsearch.js/issues/790
11274
+ * See: https://github.com/algolia/instantsearch/issues/790
11275
11275
  */
11276
11276
  }, {
11277
11277
  key: "createURL",
@@ -11760,7 +11760,7 @@
11760
11760
  };
11761
11761
  }
11762
11762
 
11763
- var version$3 = '4.56.9';
11763
+ var version$3 = '4.56.11';
11764
11764
 
11765
11765
  function _typeof$n(obj) {
11766
11766
  "@babel/helpers - typeof";
@@ -12350,7 +12350,7 @@
12350
12350
  /**
12351
12351
  * Removes all widgets without triggering a search afterwards. This is an **EXPERIMENTAL** feature,
12352
12352
  * if you find an issue with it, please
12353
- * [open an issue](https://github.com/algolia/instantsearch.js/issues/new?title=Problem%20with%20dispose).
12353
+ * [open an issue](https://github.com/algolia/instantsearch/issues/new?title=Problem%20with%20dispose).
12354
12354
  * @return {undefined} This method does not return anything
12355
12355
  */
12356
12356
  }, {
@@ -12498,7 +12498,7 @@
12498
12498
  if (searchRef.current === null) {
12499
12499
  // We don't use the `instantsearch()` function because it comes with other
12500
12500
  // top-level APIs that we don't need.
12501
- // See https://github.com/algolia/instantsearch.js/blob/5b529f43d8acc680f85837eaaa41f7fd03a3f833/src/index.es.ts#L63-L86
12501
+ // See https://github.com/algolia/instantsearch/blob/5b529f43d8acc680f85837eaaa41f7fd03a3f833/src/index.es.ts#L63-L86
12502
12502
  var search = new InstantSearch(props);
12503
12503
  search._schedule = function _schedule(cb) {
12504
12504
  search._schedule.queue.push(cb);
@@ -17865,7 +17865,7 @@
17865
17865
 
17866
17866
  // Results can be `null` when the first search is stalled.
17867
17867
  // In this case, we skip the update.
17868
- // See: https://github.com/algolia/instantsearch.js/blob/20996c7a159988c58e00ff24d2d2dc98af8b980f/src/widgets/index/index.ts#L652-L657
17868
+ // See: https://github.com/algolia/instantsearch/blob/20996c7a159988c58e00ff24d2d2dc98af8b980f/src/widgets/index/index.ts#L652-L657
17869
17869
  if (results !== null) {
17870
17870
  setSearchResults({
17871
17871
  results: results,
@@ -18107,13 +18107,18 @@
18107
18107
  var initialResults = {};
18108
18108
  walkIndex(rootIndex, function (widget) {
18109
18109
  var searchResults = widget.getResults();
18110
- initialResults[widget.getIndexId()] = {
18111
- // We convert the Helper state to a plain object to pass parsable data
18112
- // structures from server to client.
18113
- state: _objectSpread$z({}, searchResults._state),
18114
- results: searchResults._rawResults
18115
- };
18110
+ if (searchResults) {
18111
+ initialResults[widget.getIndexId()] = {
18112
+ // We convert the Helper state to a plain object to pass parsable data
18113
+ // structures from server to client.
18114
+ state: _objectSpread$z({}, searchResults._state),
18115
+ results: searchResults._rawResults
18116
+ };
18117
+ }
18116
18118
  });
18119
+ if (Object.keys(initialResults).length === 0) {
18120
+ throw new Error('The root index does not have any results. Make sure you have at least one widget that provides results.');
18121
+ }
18117
18122
  return initialResults;
18118
18123
  }
18119
18124
 
@@ -18475,6 +18480,10 @@
18475
18480
  return /*#__PURE__*/React__default.createElement(ClearRefinements, _extends$1({}, props, uiProps));
18476
18481
  }
18477
18482
 
18483
+ function capitalize(text) {
18484
+ return text.toString().charAt(0).toUpperCase() + text.toString().slice(1);
18485
+ }
18486
+
18478
18487
  var _excluded$g = ["classNames", "items", "onRemove", "hasRefinements"];
18479
18488
  function CurrentRefinements(_ref) {
18480
18489
  var _ref$classNames = _ref.classNames,
@@ -18489,14 +18498,15 @@
18489
18498
  return /*#__PURE__*/React__default.createElement("div", _extends$1({}, props, {
18490
18499
  className: cx('ais-CurrentRefinements', classNames.root, !hasRefinements && cx('ais-CurrentRefinements--noRefinement', classNames.noRefinementRoot), props.className)
18491
18500
  }), /*#__PURE__*/React__default.createElement("ul", {
18492
- className: cx('ais-CurrentRefinements-list', classNames.list, !hasRefinements && cx('ais-CurrentRefinements-list--noRefinement', classNames.noRefinementList))
18501
+ className: cx('ais-CurrentRefinements-list', classNames.list, /* @MAJOR remove to ensure conformity with InstantSearch.css specs */
18502
+ !hasRefinements && cx('ais-CurrentRefinements-list--noRefinement', classNames.noRefinementList))
18493
18503
  }, items.map(function (item) {
18494
18504
  return /*#__PURE__*/React__default.createElement("li", {
18495
18505
  key: [item.indexName, item.label].join('/'),
18496
18506
  className: cx('ais-CurrentRefinements-item', classNames.item)
18497
18507
  }, /*#__PURE__*/React__default.createElement("span", {
18498
18508
  className: cx('ais-CurrentRefinements-label', classNames.label)
18499
- }, item.label, ":"), item.refinements.map(function (refinement) {
18509
+ }, capitalize(item.label), ":", ' '), item.refinements.map(function (refinement) {
18500
18510
  return /*#__PURE__*/React__default.createElement("span", {
18501
18511
  key: refinement.label,
18502
18512
  className: cx('ais-CurrentRefinements-category', classNames.category)