react-instantsearch 6.38.2 → 6.39.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/dist/README.md CHANGED
@@ -4,20 +4,22 @@
4
4
  </a>
5
5
 
6
6
  <p align="center">
7
- InstantSearch.js is a JavaScript library for building performant and instant search experiences with <a href="https://www.algolia.com/?utm_source=instantsearch.js&utm_campaign=repository">Algolia</a>.
7
+ InstantSearch is a JavaScript library for building performant and instant search experiences in vanilla JS, React, Vue and Angular with <a href="https://www.algolia.com/?utm_source=instantsearch.js&utm_campaign=repository">Algolia</a>.
8
8
  </p>
9
9
  </p>
10
10
 
11
11
  ---
12
12
 
13
- [![Version][version-svg]][package-url]
14
13
  [![License][license-image]][license-url]
15
14
  [![Build Status][ci-svg]][ci-url]
16
- [![Pull reminders][pull-reminders-svg]][pull-reminders-url]
17
15
 
18
- InstantSearch.js is a vanilla JavaScript library that lets you create an instant-search result experience using [Algolia][algolia-website]’s search API. It is part of the InstantSearch family:
16
+ [InstantSearch][instantsearch-docs] is a JavaScript library that lets you create an instant-search result experience using [Algolia][algolia-website]’s search API.
19
17
 
20
- **InstantSearch.js** | [React InstantSearch][react-instantsearch-github] | [Vue InstantSearch][vue-instantsearch-github] | [Angular InstantSearch][instantsearch-angular-github] | [React InstantSearch Native][react-instantsearch-github] | [InstantSearch Android][instantsearch-android-github] | [InstantSearch iOS][instantsearch-ios-github]
18
+ There are multiple wrappers for popular frameworks, such as [React InstantSearch][react-instantsearch-docs], [Vue InstantSearch][vue-instantsearch-docs], and [Angular InstantSearch][angular-instantsearch-docs].
19
+
20
+ It is part of the InstantSearch family which is designed for different platforms:
21
+
22
+ **InstantSearch** | [Angular InstantSearch][instantsearch-angular-github] | [InstantSearch Android][instantsearch-android-github] | [InstantSearch iOS][instantsearch-ios-github]
21
23
 
22
24
  <details>
23
25
  <summary><strong>Table of contents</strong></summary>
@@ -26,15 +28,7 @@ InstantSearch.js is a vanilla JavaScript library that lets you create an instant
26
28
  <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
27
29
 
28
30
 
29
- - [Why](#why)
30
- - [Getting started](#getting-started)
31
- - [Installation](#installation)
32
- - [TypeScript users](#typescript-users)
33
- - [Documentation](#documentation)
34
- - [Demos](#demos)
35
- - [Playground](#playground)
36
- - [Browser support](#browser-support)
37
- - [Troubleshooting](#troubleshooting)
31
+ - [Packages](#packages)
38
32
  - [Contributing](#contributing)
39
33
  - [License](#license)
40
34
 
@@ -42,116 +36,22 @@ InstantSearch.js is a vanilla JavaScript library that lets you create an instant
42
36
 
43
37
  </details>
44
38
 
45
- ## Why
46
-
47
- You should be using InstantSearch if you want to:
48
-
49
- - Design search experiences with best practices
50
- - Customize your components at will
51
- - Remain independent from external frameworks
52
-
53
- ## Getting started
54
-
55
- Using InstantSearch.js is as simple as adding this JavaScript code to your page:
56
-
57
- ```javascript
58
- // 1. Instantiate the search
59
- const search = instantsearch({
60
- indexName: 'instant_search',
61
- searchClient: algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76'),
62
- });
63
-
64
- search.addWidgets([
65
- // 2. Create an interactive search box
66
- instantsearch.widgets.searchBox({
67
- container: '#searchbox',
68
- placeholder: 'Search for products',
69
- }),
70
-
71
- // 3. Plug the search results into the product container
72
- instantsearch.widgets.hits({
73
- container: '#products',
74
- templates: {
75
- item: '{{#helpers.highlight}}{ "attribute": "name" }{{/helpers.highlight}}',
76
- },
77
- }),
78
-
79
- // 4. Make the brands refinable
80
- instantsearch.widgets.refinementList({
81
- container: '#brand',
82
- attribute: 'brand',
83
- }),
84
- ]);
85
-
86
- // 5. Start the search!
87
- search.start();
88
- ```
89
-
90
- <p align="center">
91
- <a href="https://codesandbox.io/s/github/algolia/doc-code-samples/tree/master/InstantSearch.js/getting-started" title="Edit on CodeSandbox">
92
- <img alt="Edit on CodeSandbox" src="https://codesandbox.io/static/img/play-codesandbox.svg">
93
- </a>
94
- </p>
95
-
96
- To learn more about the library, follow the [getting started](https://www.algolia.com/doc/guides/building-search-ui/getting-started/js/) guide or check how to [add it to your own project](https://www.algolia.com/doc/guides/building-search-ui/installation/js/).
97
-
98
- ## Installation
99
-
100
- ```sh
101
- npm install instantsearch.js algoliasearch
102
- # or
103
- yarn add instantsearch.js algoliasearch
104
- ```
105
-
106
- ### TypeScript users
107
-
108
- To use InstantSearch.js in a TypeScript environment, depending on your [`algoliasearch`](https://github.com/algolia/algoliasearch-client-javascript) version, you need to import different types.
109
-
110
- >You still need to import these types even if you don't use InstantSearch.js with [`algoliasearch`](https://github.com/algolia/algoliasearch-client-javascript).
111
-
112
- #### `algoliasearch` v4.x
113
-
114
- This version uses types provided by both `algoliasearch` and `@algolia/client-search`.
115
-
116
- ```bash
117
- yarn add algoliasearch@4 @algolia/client-search
118
- ```
119
-
120
- #### `algoliasearch` v3.x
121
-
122
- ```bash
123
- yarn add @types/algoliasearch@3
124
- ```
125
-
126
- >v3.x is deprecated and will soon no longer be supported.
127
-
128
- ## Documentation
129
-
130
- The documentation is available on the [Algolia website](https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/).
131
-
132
- ## Demos
133
-
134
- | E-commerce | Media | Travel |
135
- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
136
- | <a href="https://instantsearchjs.netlify.com/examples/e-commerce/"><img src="https://www.algolia.com/doc/assets/images/build-search-ui/demos/e-commerce-2c7ed6b6.png" width="250" alt="E-commerce demo preview"></a> | <a href="https://instantsearchjs.netlify.com/examples/media/"><img src="https://www.algolia.com/doc/assets/images/build-search-ui/demos/media-articles-abc153ab.png" width="250" alt="Media demo preview"></a> | <a href="https://instantsearchjs.netlify.com/examples/tourism/"><img src="https://instantsearchjs.netlify.com/examples/tourism/capture.png" width="250" alt="Tourism demo preview"></a> |
137
-
138
- See more demos [on the website](https://www.algolia.com/doc/guides/building-search-ui/resources/demos/js/).
139
-
140
- ## Playground
141
-
142
- You can get to know InstantSearch.js on [this playground](https://codesandbox.io/s/github/algolia/instantsearch.js/tree/templates/instantsearch.js).
143
-
144
- Start by [adding widgets](https://www.algolia.com/doc/guides/building-search-ui/widgets/showcase/js/) and tweaking the display. Once you feel familiar with the library, we recommend following the [getting started guide](https://www.algolia.com/doc/guides/building-search-ui/getting-started/js/).
145
-
146
- ## Browser support
147
-
148
- We support the **last two versions of major browsers** (Chrome, Edge, Firefox, Safari).
149
-
150
- Please refer to the [browser support](https://www.algolia.com/doc/guides/building-search-ui/installation/js/#browser-support) section in the documentation to use InstantSearch.js on other browsers.
151
-
152
- ## Troubleshooting
153
-
154
- Encountering an issue? Before reaching out to support, we recommend heading to our [FAQ](https://www.algolia.com/doc/guides/building-search-ui/troubleshooting/faq/js/) where you will find answers for the most common issues and gotchas with the library.
39
+ ## Packages
40
+
41
+ | Package | Version | Description |
42
+ | --- | --- | --- |
43
+ | [`create-instantsearch-app`](packages/create-instantsearch-app) | [![create-instantsearch-app npm version](https://img.shields.io/npm/v/create-instantsearch-app.svg?style=flat-square)](https://npmjs.org/package/create-instantsearch-app) | Command-line utility to quickly bootstrap a project with InstantSearch |
44
+ | [`instantsearch.css`](packages/instantsearch.css) | [![instantsearch.css npm version](https://img.shields.io/npm/v/instantsearch.css.svg?style=flat-square)](https://npmjs.org/package/instantsearch.css) | Default CSS themes for InstantSearch |
45
+ | [`instantsearch.js`](packages/instantsearch.js) | [![instantsearch.js npm version](https://img.shields.io/npm/v/instantsearch.js.svg?style=flat-square)](https://npmjs.org/package/instantsearch.js) | InstantSearch.js |
46
+ | [`react-instantsearch`](packages/react-instantsearch) | [![react-instantsearch npm version](https://img.shields.io/npm/v/react-instantsearch.svg?style=flat-square)](https://npmjs.org/package/react-instantsearch)| React InstantSearch (prefer using `react-instantsearch-hooks-web` instead) |
47
+ | [`react-instantsearch-core`](packages/react-instantsearch-core) | [![react-instantsearch-core npm version](https://img.shields.io/npm/v/react-instantsearch-core.svg?style=flat-square)](https://npmjs.org/package/react-instantsearch-core) | React InstantSearch Core (prefer using `react-instantsearch-hooks` instead) |
48
+ | [`react-instantsearch-dom`](packages/react-instantsearch-dom) | [![react-instantsearch-dom npm version](https://img.shields.io/npm/v/react-instantsearch-dom.svg?style=flat-square)](https://npmjs.org/package/react-instantsearch-dom) | React InstantSearch DOM (prefer using `react-instantsearch-hooks-web` instead) |
49
+ | [`react-instantsearch-dom-maps`](packages/react-instantsearch-dom-maps) | [![react-instantsearch-dom-maps npm version](https://img.shields.io/npm/v/react-instantsearch-dom-maps.svg?style=flat-square)](https://npmjs.org/package/react-instantsearch-dom-maps)| GeoSearch widget for React InstantSearch DOM |
50
+ | [`react-instantsearch-hooks`](packages/react-instantsearch-hooks) | [![react-instantsearch-hooks npm version](https://img.shields.io/npm/v/react-instantsearch-hooks?style=flat-square)](https://npmjs.org/package/react-instantsearch-hooks) | React InstantSearch Hooks |
51
+ | [`react-instantsearch-hooks-server`](packages/react-instantsearch-hooks-server) | [![react-instantsearch-hooks-server npm version](https://img.shields.io/npm/v/react-instantsearch-hooks-server.svg?style=flat-square)](https://npmjs.org/package/react-instantsearch-hooks-server) | Utilities to do server-side rendering with React InstantSearch Hooks |
52
+ | [`react-instantsearch-hooks-web`](packages/react-instantsearch-hooks-web) | [![react-instantsearch-hooks-web npm version](https://img.shields.io/npm/v/react-instantsearch-hooks-web.svg?style=flat-square)](https://npmjs.org/package/react-instantsearch-hooks-web) | React InstantSearch Hooks bundled with UI components |
53
+ | [`react-instantsearch-native`](packages/react-instantsearch-native) | [![react-instantsearch-native npm version](https://img.shields.io/npm/v/react-instantsearch-native.svg?style=flat-square)](https://npmjs.org/package/react-instantsearch-native) | React InstantSearch Native (prefer using `react-instantsearch-hooks` instead) |
54
+ | [`vue-instantsearch`](packages/vue-instantsearch) | [![vue-instantsearch npm version](https://img.shields.io/npm/v/vue-instantsearch.svg?style=flat-square)](https://npmjs.org/package/vue-instantsearch) | Vue InstantSearch |
155
55
 
156
56
  ## Contributing
157
57
 
@@ -167,31 +67,28 @@ To start contributing to code, you need to:
167
67
  1. [Fork the project](https://help.github.com/articles/fork-a-repo/)
168
68
  1. [Clone the repository](https://help.github.com/articles/cloning-a-repository/)
169
69
  1. Install the dependencies: `yarn`
170
- 1. Run the development mode: `cd packages/instantsearch.js && yarn storybook`
171
- 1. [Open the stories](http://localhost:6006)
70
+ 1. [Pick a package to work on](#packages) and cd into it (e.g. `cd packages/react-instantsearch-hooks`)
172
71
 
173
72
  Please read [our contribution process](CONTRIBUTING.md) to learn more.
174
73
 
175
74
  ## License
176
75
 
177
- InstantSearch.js is [MIT licensed][license-url].
76
+ InstantSearch is [MIT licensed][license-url].
178
77
 
179
78
  <!-- Badges -->
180
79
 
181
- [version-svg]: https://img.shields.io/npm/v/instantsearch.js.svg?style=flat-square
182
- [package-url]: https://npmjs.org/package/instantsearch.js
183
- [ci-svg]: https://img.shields.io/circleci/project/github/algolia/instantsearch.js.svg?style=flat-square
184
- [ci-url]: https://circleci.com/gh/algolia/instantsearch.js
185
- [pull-reminders-svg]: https://img.shields.io/badge/pull%20reminders-✓-success.svg?style=flat-square
186
- [pull-reminders-url]: https://pullreminders.com?ref=badge
80
+ [ci-svg]: https://img.shields.io/circleci/project/github/algolia/instantsearch.svg?style=flat-square
81
+ [ci-url]: https://circleci.com/gh/algolia/instantsearch
187
82
  [license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square
188
83
  [license-url]: LICENSE
189
84
 
190
85
  <!-- Links -->
191
86
 
192
- [algolia-website]: https://www.algolia.com/?utm_source=instantsearch.js&utm_campaign=repository
193
- [react-instantsearch-github]: https://github.com/algolia/instantsearch.js
194
- [vue-instantsearch-github]: https://github.com/algolia/vue-instantsearch
87
+ [algolia-website]: https://www.algolia.com/?utm_source=instantsearch.js&utm_campaign=repository "Algolia's website"
88
+ [instantsearch-docs]: https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/?utm_source=instantsearch.js&utm_campaign=repository "InstantSearch.js documentation"
89
+ [react-instantsearch-docs]: https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/react-hooks/?utm_source=instantsearch.js&utm_campaign=repository "React InstantSearch documentation"
90
+ [vue-instantsearch-docs]: https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/vue/?utm_source=instantsearch.js&utm_campaign=repository "Vue InstantSearch documentation"
91
+ [angular-instantsearch-docs]: https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/angular/?utm_source=instantsearch.js&utm_campaign=repository "Angular InstantSearch documentation"
195
92
  [instantsearch-android-github]: https://github.com/algolia/instantsearch-android
196
93
  [instantsearch-ios-github]: https://github.com/algolia/instantsearch-ios
197
94
  [instantsearch-angular-github]: https://github.com/algolia/angular-instantsearch
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-instantsearch",
3
- "version": "6.38.2",
3
+ "version": "6.39.0",
4
4
  "description": "⚡ Lightning-fast search for React and React Native apps, by Algolia",
5
5
  "main": "index.js",
6
6
  "module": "dist/es/index.js",
@@ -44,13 +44,13 @@
44
44
  },
45
45
  "dependencies": {
46
46
  "@babel/runtime": "^7.1.2",
47
- "react-instantsearch-core": "6.38.2",
48
- "react-instantsearch-dom": "6.38.2",
49
- "react-instantsearch-native": "6.38.2"
47
+ "react-instantsearch-core": "6.39.0",
48
+ "react-instantsearch-dom": "6.39.0",
49
+ "react-instantsearch-native": "6.39.0"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "algoliasearch": ">= 3.1 < 5",
53
53
  "react": ">= 16.3.0 < 19"
54
54
  },
55
- "gitHead": "54e18a6e7cfebc2c7c7326676c56c71ee39eb1c2"
55
+ "gitHead": "9c696ab3244d701c05d314bb765f086a50ff481b"
56
56
  }
@@ -1301,7 +1301,8 @@
1301
1301
  for (var key in source) {
1302
1302
  if (
1303
1303
  !Object.prototype.hasOwnProperty.call(source, key) ||
1304
- key === '__proto__'
1304
+ key === '__proto__' ||
1305
+ key === 'constructor'
1305
1306
  ) {
1306
1307
  continue;
1307
1308
  }
@@ -4117,7 +4118,33 @@
4117
4118
  };
4118
4119
  });
4119
4120
  } else if (results._state.isHierarchicalFacet(attribute)) {
4120
- return find$1(results.hierarchicalFacets, predicate);
4121
+ var hierarchicalFacetValues = find$1(results.hierarchicalFacets, predicate);
4122
+ if (!hierarchicalFacetValues) return hierarchicalFacetValues;
4123
+
4124
+ var hierarchicalFacet = results._state.getHierarchicalFacetByName(attribute);
4125
+ var currentRefinementSplit = unescapeFacetValue$3(
4126
+ results._state.getHierarchicalRefinement(attribute)[0] || ''
4127
+ ).split(results._state._getHierarchicalFacetSeparator(hierarchicalFacet));
4128
+ currentRefinementSplit.unshift(attribute);
4129
+
4130
+ setIsRefined(hierarchicalFacetValues, currentRefinementSplit, 0);
4131
+
4132
+ return hierarchicalFacetValues;
4133
+ }
4134
+ }
4135
+
4136
+ /**
4137
+ * Set the isRefined of a hierarchical facet result based on the current state.
4138
+ * @param {SearchResults.HierarchicalFacet} item Hierarchical facet to fix
4139
+ * @param {string[]} currentRefinementSplit array of parts of the current hierarchical refinement
4140
+ * @param {number} depth recursion depth in the currentRefinement
4141
+ */
4142
+ function setIsRefined(item, currentRefinement, depth) {
4143
+ item.isRefined = item.name === currentRefinement[depth];
4144
+ if (item.data) {
4145
+ item.data.forEach(function(child) {
4146
+ setIsRefined(child, currentRefinement, depth + 1);
4147
+ });
4121
4148
  }
4122
4149
  }
4123
4150
 
@@ -5206,7 +5233,7 @@
5206
5233
 
5207
5234
  var requestBuilder_1 = requestBuilder;
5208
5235
 
5209
- var version = '3.11.1';
5236
+ var version = '3.11.3';
5210
5237
 
5211
5238
  var escapeFacetValue$3 = escapeFacetValue_1.escapeFacetValue;
5212
5239
 
@@ -5456,8 +5483,10 @@
5456
5483
  * @param {number} options.nbHits - Maximum number of answers to retrieve from the Answers Engine. Cannot be greater than 1000.
5457
5484
  *
5458
5485
  * @return {promise} the answer results
5486
+ * @deprecated answers is deprecated and will be replaced with new initiatives
5459
5487
  */
5460
5488
  AlgoliaSearchHelper.prototype.findAnswers = function(options) {
5489
+ console.warn('[algoliasearch-helper] answers is no longer supported');
5461
5490
  var state = this.state;
5462
5491
  var derivedHelper = this.derivedHelpers[0];
5463
5492
  if (!derivedHelper) {