create-instantsearch-app 5.2.2 → 6.2.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.
Files changed (39) hide show
  1. package/README.md +1 -3
  2. package/package.json +4 -5
  3. package/src/api/__tests__/__snapshots__/index.test.js.snap +4 -4
  4. package/src/templates/Angular InstantSearch/src/app/app.component.html.hbs +4 -1
  5. package/src/templates/InstantSearch.js/index.html.hbs +2 -4
  6. package/src/templates/InstantSearch.js/package.json +5 -11
  7. package/src/templates/InstantSearch.js/src/app.js.hbs +12 -6
  8. package/src/templates/React InstantSearch/package.json +2 -2
  9. package/src/templates/React InstantSearch/public/index.html +1 -1
  10. package/src/templates/React InstantSearch/src/App.js.hbs +10 -4
  11. package/src/templates/React InstantSearch/src/index.js +2 -2
  12. package/src/templates/React InstantSearch Hooks/.editorconfig +8 -0
  13. package/src/templates/React InstantSearch Hooks/.gitignore.template +23 -0
  14. package/src/templates/React InstantSearch Hooks/.prettierrc +5 -0
  15. package/src/templates/React InstantSearch Hooks/.template.js +24 -0
  16. package/src/templates/React InstantSearch Hooks/README.md +19 -0
  17. package/src/templates/React InstantSearch Hooks/favicon.png +0 -0
  18. package/src/templates/React InstantSearch Hooks/index.html +31 -0
  19. package/src/templates/React InstantSearch Hooks/package.json +22 -0
  20. package/src/templates/React InstantSearch Hooks/src/App.css +71 -0
  21. package/src/templates/React InstantSearch Hooks/src/App.tsx.hbs +111 -0
  22. package/src/templates/React InstantSearch Hooks/src/Panel.tsx +16 -0
  23. package/src/templates/React InstantSearch Hooks/src/index.tsx +6 -0
  24. package/src/templates/React InstantSearch widget/README.md +1 -1
  25. package/src/templates/React InstantSearch widget/package.json.hbs +2 -1
  26. package/src/templates/React InstantSearch widget/src/lib/connector.ts.hbs +6 -3
  27. package/src/templates/React InstantSearch widget/src/lib/widget.tsx.hbs +4 -4
  28. package/src/templates/React InstantSearch widget/src/types/connector.ts +17 -0
  29. package/src/templates/Vue InstantSearch/public/index.html +1 -1
  30. package/src/templates/Vue InstantSearch/src/App.vue +18 -6
  31. package/src/templates/Vue InstantSearch with Vue 3/README.md +2 -2
  32. package/src/templates/Vue InstantSearch with Vue 3/index.html +1 -1
  33. package/src/templates/Vue InstantSearch with Vue 3/package.json +1 -0
  34. package/src/templates/Vue InstantSearch with Vue 3/src/App.vue +9 -2
  35. package/src/utils/__tests__/__snapshots__/index.test.js.snap +1 -1
  36. package/src/utils/__tests__/index.test.js +2 -2
  37. package/CHANGELOG.md +0 -527
  38. package/src/templates/InstantSearch.js/manifest.webmanifest +0 -15
  39. package/src/templates/React InstantSearch widget/.gitignore +0 -5
package/README.md CHANGED
@@ -162,11 +162,9 @@ Create InstantSearch App is [MIT licensed](LICENSE).
162
162
 
163
163
  [version-svg]: https://img.shields.io/npm/v/create-instantsearch-app.svg?style=flat-square
164
164
  [package-url]: https://npmjs.org/package/create-instantsearch-app
165
- [ci-svg]: https://img.shields.io/travis/algolia/create-instantsearch-app/master.svg?style=flat-square
166
- [ci-url]: https://travis-ci.org/algolia/create-instantsearch-app
167
165
  [ci-svg]: https://img.shields.io/circleci/project/github/algolia/create-instantsearch-app.svg?style=flat-square
168
166
  [ci-url]: https://circleci.com/gh/algolia/create-instantsearch-app
169
- [license-image]: http://img.shields.io/badge/license-MIT-green.svg?style=flat-square
167
+ [license-image]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
170
168
  [license-url]: LICENSE
171
169
 
172
170
  <!-- Links -->
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-instantsearch-app",
3
- "version": "5.2.2",
3
+ "version": "6.2.0",
4
4
  "license": "MIT",
5
5
  "description": "⚡️ Build InstantSearch apps at the speed of thought",
6
6
  "keywords": [
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "scripts": {
17
17
  "start": "node src/cli/index.js",
18
- "test": "jest src",
18
+ "test": "jest --no-color src",
19
19
  "test:e2e:templates": "jest e2e/templates.test.js",
20
20
  "test:e2e:installs": "jest e2e/installs.test.js",
21
21
  "test:e2e": "yarn run test:e2e:templates && yarn run test:e2e:installs",
@@ -25,8 +25,7 @@
25
25
  "doctoc": "doctoc --maxlevel 3 README.md CONTRIBUTING.md docs/",
26
26
  "changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
27
27
  "release-templates": "node ./scripts/release-templates",
28
- "release": "release-it",
29
- "release:beta": "release-it --preRelease=beta"
28
+ "release": "shipjs prepare"
30
29
  },
31
30
  "files": [
32
31
  "index.js",
@@ -67,7 +66,7 @@
67
66
  "eslint-plugin-prettier": "3.1.2",
68
67
  "jest": "25.1.0",
69
68
  "jest-image-snapshot": "2.12.0",
70
- "release-it": "10.4.5",
69
+ "shipjs": "0.24.4",
71
70
  "walk-sync": "2.0.2"
72
71
  }
73
72
  }
@@ -1,15 +1,15 @@
1
1
  // Jest Snapshot v1, https://goo.gl/fbAQLP
2
2
 
3
3
  exports[`Options with invalid name throws 1`] = `
4
- "Could not create a project called \\"./WrongNpmName\\" because of npm naming restrictions.
4
+ "Could not create a project called \\"./WrongNpmName\\" because of npm naming restrictions.
5
5
  - name cannot start with a period
6
6
  - name can only contain URL-friendly characters"
7
7
  `;
8
8
 
9
- exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, Autocomplete.js 0, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Hooks Native, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2, Vue InstantSearch with Vue 3"`;
9
+ exports[`Options with unknown template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, Autocomplete.js 0, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Hooks, React InstantSearch Hooks Native, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2, Vue InstantSearch with Vue 3"`;
10
10
 
11
- exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, Autocomplete.js 0, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Hooks Native, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2, Vue InstantSearch with Vue 3"`;
11
+ exports[`Options with wrong template path throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, Autocomplete.js 0, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Hooks, React InstantSearch Hooks Native, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2, Vue InstantSearch with Vue 3"`;
12
12
 
13
13
  exports[`Options without path throws 1`] = `"The option \`path\` is required."`;
14
14
 
15
- exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, Autocomplete.js 0, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Hooks Native, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2, Vue InstantSearch with Vue 3"`;
15
+ exports[`Options without template throws 1`] = `"The template directory must contain a configuration file \`.template.js\` or must be one of those: Angular InstantSearch, Autocomplete, Autocomplete.js 0, InstantSearch Android, InstantSearch iOS, InstantSearch.js, InstantSearch.js 2, InstantSearch.js widget, JavaScript Client, JavaScript Helper, JavaScript Helper 2, React InstantSearch, React InstantSearch Hooks, React InstantSearch Hooks Native, React InstantSearch Native, React InstantSearch widget, Vue InstantSearch, Vue InstantSearch 1, Vue InstantSearch 2, Vue InstantSearch with Vue 3"`;
@@ -12,11 +12,14 @@
12
12
 
13
13
  <div class="container">
14
14
  <ais-instantsearch [config]="config">
15
+ <ais-configure [searchParameters]="{ hitsPerPage: 8 }"></ais-configure>
15
16
  <div class="search-panel">
16
17
  {{#if attributesForFaceting}}
17
18
  <div class="search-panel__filters">
18
19
  {{#each attributesForFaceting}}
19
- <ais-refinement-list attribute="{{this}}"></ais-refinement-list>
20
+ <ais-panel header="{{this}}">
21
+ <ais-refinement-list attribute="{{this}}"></ais-refinement-list>
22
+ </ais-panel>
20
23
  {{/each}}
21
24
  </div>
22
25
 
@@ -6,10 +6,9 @@
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
7
7
  <meta name="theme-color" content="#000000">
8
8
 
9
- <link rel="manifest" href="./manifest.webmanifest">
10
9
  <link rel="shortcut icon" href="./favicon.png">
11
10
 
12
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7/themes/algolia-min.css">
11
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7/themes/satellite-min.css">
13
12
  <link rel="stylesheet" href="./src/index.css">
14
13
  <link rel="stylesheet" href="./src/app.css">
15
14
 
@@ -44,10 +43,9 @@
44
43
  <div class="search-panel__results">
45
44
  <div id="searchbox"></div>
46
45
  <div id="hits"></div>
46
+ <div id="pagination"></div>
47
47
  </div>
48
48
  </div>
49
-
50
- <div id="pagination"></div>
51
49
  </div>
52
50
 
53
51
  <script src="https://cdn.jsdelivr.net/npm/algoliasearch@4.10.5/dist/algoliasearch-lite.umd.js"></script>
@@ -2,22 +2,16 @@
2
2
  "name": "{{name}}",
3
3
  "version": "1.0.0",
4
4
  "private": true,
5
- "main": "src/app.js",
6
5
  "scripts": {
7
6
  "start": "parcel index.html --port 3000",
8
7
  "build": "parcel build index.html",
9
- "lint": "eslint .",
10
- "lint:fix": "npm run lint -- --fix"
8
+ "lint": "eslint . && prettier --check .",
9
+ "lint:fix": "eslint . --fix && prettier --write ."
11
10
  },
12
11
  "devDependencies": {
13
- "babel-eslint": "10.0.3",
14
- "eslint": "5.7.0",
15
- "eslint-config-algolia": "13.2.3",
16
- "eslint-config-prettier": "3.6.0",
17
- "eslint-plugin-import": "2.19.1",
18
- "eslint-plugin-prettier": "3.1.2",
19
- "parcel-bundler": "1.12.5",
20
- "prettier": "1.19.1"
12
+ "eslint": "8.15.0",
13
+ "parcel": "2.0.1",
14
+ "prettier": "2.6.2"
21
15
  },
22
16
  "dependencies": {
23
17
  "algoliasearch": "4",
@@ -31,22 +31,26 @@ search.addWidgets([
31
31
  },
32
32
  {{/if}}
33
33
  }),
34
- {{#if flags.dynamicWidgets}}
35
34
  instantsearch.widgets.configure({
36
- facets: ['*'],
37
- maxValuesPerFacet: 20,
35
+ hitsPerPage: 8,
38
36
  }),
37
+ {{#if flags.dynamicWidgets}}
39
38
  instantsearch.widgets.dynamicWidgets({
40
39
  container: '#dynamic-widgets',
41
40
  fallbackWidget({ container, attribute }) {
42
- return instantsearch.widgets.refinementList({
41
+ return instantsearch.widgets.panel({ templates: { header: attribute } })(
42
+ instantsearch.widgets.refinementList
43
+ )({
43
44
  container,
44
45
  attribute,
45
46
  });
46
47
  },
47
48
  widgets: [
48
49
  {{#each attributesForFaceting}}
49
- container => instantsearch.widgets.refinementList({
50
+ container =>
51
+ instantsearch.widgets.panel({
52
+ templates: { header: '{{this}}' },
53
+ })(instantsearch.widgets.refinementList)({
50
54
  container,
51
55
  attribute: '{{this}}',
52
56
  }),
@@ -55,7 +59,9 @@ search.addWidgets([
55
59
  }),
56
60
  {{else}}
57
61
  {{#each attributesForFaceting}}
58
- instantsearch.widgets.refinementList({
62
+ instantsearch.widgets.panel({
63
+ templates: { header: '{{this}}' },
64
+ })(instantsearch.widgets.refinementList)({
59
65
  container: '#{{this}}-list',
60
66
  attribute: '{{this}}',
61
67
  }),
@@ -10,8 +10,8 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "algoliasearch": "4",
13
- "react": "16.12.0",
14
- "react-dom": "16.12.0",
13
+ "react": "18.1.0",
14
+ "react-dom": "18.1.0",
15
15
  "react-instantsearch-dom": "{{libraryVersion}}",
16
16
  "react-scripts": "2.1.1"
17
17
  },
@@ -13,7 +13,7 @@
13
13
  Do not use @7 in production, use a complete version like x.x.x, see website for latest version:
14
14
  https://www.algolia.com/doc/guides/building-search-ui/installation/react/#load-the-style
15
15
  -->
16
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7/themes/algolia-min.css">
16
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/instantsearch.css@7/themes/satellite-min.css">
17
17
 
18
18
  <title>{{name}}</title>
19
19
  </head>
@@ -2,14 +2,16 @@ import React from 'react';
2
2
  import algoliasearch from 'algoliasearch/lite';
3
3
  import {
4
4
  InstantSearch,
5
+ Configure,
5
6
  Hits,
6
7
  SearchBox,
7
8
  {{#if flags.dynamicWidgets}}
8
- Configure,
9
9
  DynamicWidgets,
10
+ Panel,
10
11
  RefinementList,
11
12
  {{else}}
12
13
  {{#if attributesForFaceting}}
14
+ Panel,
13
15
  RefinementList,
14
16
  {{/if}}
15
17
  {{/if}}
@@ -40,18 +42,22 @@ function App() {
40
42
 
41
43
  <div className="container">
42
44
  <InstantSearch searchClient={searchClient} indexName="{{indexName}}">
45
+ <Configure hitsPerPage={8} />
43
46
  <div className="search-panel">
44
47
  <div className="search-panel__filters">
45
48
  {{#if flags.dynamicWidgets}}
46
- <Configure facets={['*']} maxValuesPerFacet={20} />
47
49
  <DynamicWidgets fallbackWidget={RefinementList}>
48
50
  {{#each attributesForFaceting}}
49
- <RefinementList attribute="{{this}}" />
51
+ <Panel header="{{this}}">
52
+ <RefinementList attribute="{{this}}" />
53
+ </Panel>
50
54
  {{/each}}
51
55
  </DynamicWidgets>
52
56
  {{else}}
53
57
  {{#each attributesForFaceting}}
54
- <RefinementList attribute="{{this}}" />
58
+ <Panel header="{{this}}">
59
+ <RefinementList attribute="{{this}}" />
60
+ </Panel>
55
61
  {{/each}}
56
62
  {{/if}}
57
63
  </div>
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import ReactDOM from 'react-dom';
2
+ import { createRoot } from 'react-dom/client';
3
3
  import './index.css';
4
4
  import App from './App';
5
5
 
6
- ReactDOM.render(<App />, document.getElementById('root'));
6
+ createRoot(document.getElementById('root')).render(<App />);
@@ -0,0 +1,8 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = space
5
+ indent_size = 2
6
+ end_of_line = lf
7
+ insert_final_newline = true
8
+ trim_trailing_whitespace = true
@@ -0,0 +1,23 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ .parcel-cache
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode
17
+ .idea
18
+ .DS_Store
19
+ *.suo
20
+ *.ntvs*
21
+ *.njsproj
22
+ *.sln
23
+ *.sw?
@@ -0,0 +1,5 @@
1
+ {
2
+ "singleQuote": true,
3
+ "proseWrap": "never",
4
+ "trailingComma": "es5"
5
+ }
@@ -0,0 +1,24 @@
1
+ const install = require('../../tasks/node/install');
2
+ const teardown = require('../../tasks/node/teardown');
3
+
4
+ module.exports = {
5
+ category: 'Web',
6
+ libraryName: 'react-instantsearch-hooks-web',
7
+ supportedVersion: '>= 6.0.0 < 7.0.0',
8
+ flags: {
9
+ dynamicWidgets: '>=6.16',
10
+ },
11
+ templateName: 'react-instantsearch-hooks',
12
+ appName: 'react-instantsearch-hooks-app',
13
+ keywords: [
14
+ 'algolia',
15
+ 'InstantSearch',
16
+ 'React',
17
+ 'Hooks',
18
+ 'react-instantsearch-hooks',
19
+ ],
20
+ tasks: {
21
+ install,
22
+ teardown,
23
+ },
24
+ };
@@ -0,0 +1,19 @@
1
+ # {{name}}
2
+
3
+ _This project was generated with [create-instantsearch-app](https://github.com/algolia/create-instantsearch-app) by [Algolia](https://algolia.com)._
4
+
5
+ ## Get started
6
+
7
+ To run this project locally, install the dependencies and run the local server:
8
+
9
+ ```sh
10
+ npm install
11
+ npm start
12
+ ```
13
+
14
+ Alternatively, you may use [Yarn](https://http://yarnpkg.com/):
15
+
16
+ ```sh
17
+ yarn
18
+ yarn start
19
+ ```
@@ -0,0 +1,31 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta
6
+ name="viewport"
7
+ content="width=device-width, initial-scale=1, shrink-to-fit=no"
8
+ />
9
+
10
+ <link rel="shortcut icon" href="favicon.png">
11
+
12
+ <!--
13
+ Do not use @7 in production, use a complete version like x.x.x, see website for latest version:
14
+ https://www.algolia.com/doc/guides/building-search-ui/installation/react/#load-the-style
15
+ -->
16
+ <link
17
+ rel="stylesheet"
18
+ href="https://cdn.jsdelivr.net/npm/instantsearch.css@7/themes/satellite-min.css"
19
+ />
20
+
21
+ <title>{{name}}</title>
22
+ </head>
23
+
24
+ <body>
25
+ <noscript> You need to enable JavaScript to run this app. </noscript>
26
+
27
+ <div id="root"></div>
28
+
29
+ <script type="module" src="src/index.tsx"></script>
30
+ </body>
31
+ </html>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "{{name}}",
3
+ "version": "1.0.0",
4
+ "private": true,
5
+ "scripts": {
6
+ "build": "parcel build index.html",
7
+ "start": "parcel index.html"
8
+ },
9
+ "dependencies": {
10
+ "algoliasearch": "4",
11
+ "instantsearch.js": "4.43.1",
12
+ "react": "18.1.0",
13
+ "react-dom": "18.1.0",
14
+ "react-instantsearch-hooks-web": "{{libraryVersion}}"
15
+ },
16
+ "devDependencies": {
17
+ "@types/react": "18.0.15",
18
+ "@types/react-dom": "18.0.6",
19
+ "parcel": "2.5.0",
20
+ "typescript": "4.7.4"
21
+ }
22
+ }
@@ -0,0 +1,71 @@
1
+ body,
2
+ h1 {
3
+ margin: 0;
4
+ padding: 0;
5
+ }
6
+
7
+ body {
8
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
9
+ Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
10
+ }
11
+
12
+ em {
13
+ background: cyan;
14
+ font-style: normal;
15
+ }
16
+
17
+ .header {
18
+ display: flex;
19
+ align-items: center;
20
+ min-height: 50px;
21
+ padding: 0.5rem 1rem;
22
+ background-image: linear-gradient(to right, #8e43e7, #00aeff);
23
+ color: #fff;
24
+ margin-bottom: 1rem;
25
+ }
26
+
27
+ .header a {
28
+ color: #fff;
29
+ text-decoration: none;
30
+ }
31
+
32
+ .header-title {
33
+ font-size: 1.2rem;
34
+ font-weight: normal;
35
+ }
36
+
37
+ .header-title::after {
38
+ content: ' ▸ ';
39
+ padding: 0 0.5rem;
40
+ }
41
+
42
+ .header-subtitle {
43
+ font-size: 1.2rem;
44
+ }
45
+
46
+ .container {
47
+ max-width: 1200px;
48
+ margin: 0 auto;
49
+ padding: 1rem;
50
+ }
51
+
52
+ .search-panel {
53
+ display: flex;
54
+ }
55
+
56
+ .search-panel__filters {
57
+ flex: 1;
58
+ }
59
+
60
+ .search-panel__results {
61
+ flex: 3;
62
+ }
63
+
64
+ .searchbox {
65
+ margin-bottom: 2rem;
66
+ }
67
+
68
+ .pagination {
69
+ margin: 2rem auto;
70
+ text-align: center;
71
+ }
@@ -0,0 +1,111 @@
1
+ import React from 'react';
2
+ import algoliasearch from 'algoliasearch/lite';
3
+ import {
4
+ Configure,
5
+ {{#if flags.dynamicWidgets}}
6
+ DynamicWidgets,
7
+ {{#unless attributesForFaceting}}
8
+ RefinementList,
9
+ {{/unless}}
10
+ {{/if}}
11
+ {{#if attributesToDisplay}}
12
+ Highlight,
13
+ {{/if}}
14
+ Hits,
15
+ InstantSearch,
16
+ Pagination,
17
+ {{#if attributesForFaceting}}
18
+ RefinementList,
19
+ {{/if}}
20
+ SearchBox,
21
+ } from 'react-instantsearch-hooks-web';
22
+
23
+ import { Panel } from './Panel';
24
+
25
+ import type { Hit } from 'instantsearch.js';
26
+
27
+ import './App.css';
28
+
29
+ const searchClient = algoliasearch(
30
+ '{{appId}}',
31
+ '{{apiKey}}'
32
+ );
33
+
34
+ export function App() {
35
+ return (
36
+ <div>
37
+ <header className="header">
38
+ <h1 className="header-title">
39
+ <a href="/">{{name}}</a>
40
+ </h1>
41
+ <p className="header-subtitle">
42
+ using{' '}
43
+ <a href="https://github.com/algolia/react-instantsearch">
44
+ React InstantSearch Hooks
45
+ </a>
46
+ </p>
47
+ </header>
48
+
49
+ <div className="container">
50
+ <InstantSearch searchClient={searchClient} indexName="{{indexName}}">
51
+ <Configure hitsPerPage={8} />
52
+ <div className="search-panel">
53
+ <div className="search-panel__filters">
54
+ {{#if flags.dynamicWidgets}}
55
+ <DynamicWidgets fallback={RefinementList}>
56
+ {{#each attributesForFaceting}}
57
+ <Panel header="{{this}}">
58
+ <RefinementList attribute="{{this}}" />
59
+ </Panel>
60
+ {{/each}}
61
+ </DynamicWidgets>
62
+ {{else}}
63
+ {{#each attributesForFaceting}}
64
+ <Panel header="{{this}}">
65
+ <RefinementList attribute="{{this}}" />
66
+ </Panel>
67
+ {{/each}}
68
+ {{/if}}
69
+ </div>
70
+
71
+ <div className="search-panel__results">
72
+ <SearchBox placeholder="{{searchPlaceholder}}" className="searchbox" />
73
+ <Hits hitComponent={Hit} />
74
+
75
+ <div className="pagination">
76
+ <Pagination />
77
+ </div>
78
+ </div>
79
+ </div>
80
+ </InstantSearch>
81
+ </div>
82
+ </div>
83
+ );
84
+ }
85
+
86
+ type HitProps = {
87
+ hit: Hit;
88
+ };
89
+
90
+ function Hit({ hit }: HitProps) {
91
+ return (
92
+ <article>
93
+ {{#if attributesToDisplay}}
94
+ <h1>
95
+ <Highlight attribute="{{attributesToDisplay.[0]}}" hit={hit} />
96
+ </h1>
97
+ {{#each attributesToDisplay}}
98
+ {{#unless @first}}
99
+ <p>
100
+ <Highlight attribute="{{this}}" hit={hit} />
101
+ </p>
102
+ {{/unless}}
103
+ {{/each}}
104
+ {{else}}
105
+ <p>
106
+ <code>{JSON.stringify(hit).slice(0, 100)}...</code>
107
+ </p>
108
+ {{/if}}
109
+ </article>
110
+ );
111
+ }
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+
3
+ type PanelProps = React.PropsWithChildren<{
4
+ header: string;
5
+ }>;
6
+
7
+ export function Panel({ header, children }: PanelProps) {
8
+ return (
9
+ <div className="ais-Panel">
10
+ <div className="ais-Panel-header">
11
+ <span>{header}</span>
12
+ </div>
13
+ <div className="ais-Panel-body">{children}</div>
14
+ </div>
15
+ );
16
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ import { createRoot } from 'react-dom/client';
3
+
4
+ import { App } from './App';
5
+
6
+ createRoot(document.getElementById('root')!).render(<App />);
@@ -19,8 +19,8 @@ yarn add {{ packageName }}
19
19
  ### Usage
20
20
 
21
21
  ```jsx
22
- import instantsearch from 'instantsearch.js';
23
22
  import algoliasearch from 'algoliasearch/lite';
23
+ import { InstantSearch } from 'react-instantsearch-dom';
24
24
  import { {{ pascalCaseName }} } from '{{ packageName }}';
25
25
 
26
26
  const searchClient = algoliasearch('appId', 'apiKey');
@@ -42,7 +42,7 @@
42
42
  "algoliasearch": "4",
43
43
  "react": "^16.8.0",
44
44
  "react-dom": "^16.8.0",
45
- "react-instantsearch-dom": "^6.11.0"
45
+ "react-instantsearch-dom": "^6.26.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@babel/core": "7.14.3",
@@ -54,6 +54,7 @@
54
54
  "@types/node": "15.3.0",
55
55
  "@types/react": "17.0.0",
56
56
  "@types/react-dom": "17.0.0",
57
+ "@types/react-instantsearch-core": "6.26.0",
57
58
  "@types/react-instantsearch-dom": "6.10.0",
58
59
  "@typescript-eslint/eslint-plugin": "4.24.0",
59
60
  "@typescript-eslint/parser": "4.24.0",