diff --git a/dev/app/builtin/stories/search-box.stories.js b/dev/app/builtin/stories/search-box.stories.js index 038f8549fa..bfd44c3cf8 100644 --- a/dev/app/builtin/stories/search-box.stories.js +++ b/dev/app/builtin/stories/search-box.stories.js @@ -14,110 +14,77 @@ export default () => { window.search.addWidget( instantsearch.widgets.searchBox({ container, - placeholder: 'Search for products', - poweredBy: true, }) ); }) ) .add( - 'display loading indicator', + 'with a custom placeholder', wrapWithHits(container => { window.search.addWidget( instantsearch.widgets.searchBox({ container, placeholder: 'Search for products', - poweredBy: true, - loadingIndicator: true, }) ); }) ) .add( - 'display loading indicator with a template', + 'with autofocus', wrapWithHits(container => { window.search.addWidget( instantsearch.widgets.searchBox({ container, - placeholder: 'Search for products', - poweredBy: true, - loadingIndicator: { - template: '⚡️', - }, + autofocus: true, }) ); }) ) .add( - 'with custom templates', + 'do not display the loading indicator', wrapWithHits(container => { window.search.addWidget( instantsearch.widgets.searchBox({ container, - placeholder: 'Search for products', - poweredBy: true, - magnifier: { - template: '
🔍
', - }, - reset: { - template: '
✖️
', - }, - templates: { - poweredBy: 'Algolia', - }, + showLoadingIndicator: false, }) ); }) ) .add( - 'search on enter', + 'display loading indicator with a template', wrapWithHits(container => { window.search.addWidget( instantsearch.widgets.searchBox({ container, - placeholder: 'Search for products', - poweredBy: true, - searchOnEnterKeyPressOnly: true, - }) - ); - }) - ) - .add( - 'input with initial value', - wrapWithHits(container => { - container.innerHTML = ''; - const input = container.firstChild; - container.appendChild(input); - window.search.addWidget( - instantsearch.widgets.searchBox({ - container: input, + templates: { + loadingIndicator: '⚡️', + }, }) ); }) ) .add( - 'with a provided input', + 'with custom templates', wrapWithHits(container => { - container.innerHTML = ''; - const input = container.firstChild; - container.appendChild(input); window.search.addWidget( instantsearch.widgets.searchBox({ - container: input, + container, + templates: { + submit: '
🔍
', + reset: '
✖️
', + }, }) ); }) ) .add( - 'with a provided input and the loading indicator', + 'search on enter', wrapWithHits(container => { - container.innerHTML = ''; - const input = container.firstChild; - container.appendChild(input); window.search.addWidget( instantsearch.widgets.searchBox({ - container: input, - loadingIndicator: true, + container, + searchAsYouType: false, }) ); }) diff --git a/docgen/assets/js/bindRunExamples.js b/docgen/assets/js/bindRunExamples.js index 3a84d66d60..731c6e0e68 100644 --- a/docgen/assets/js/bindRunExamples.js +++ b/docgen/assets/js/bindRunExamples.js @@ -113,7 +113,6 @@ function appendDefaultSearchWidgets(index) { instantsearch.widgets.searchBox({ container: `#search-box-container-${index}`, placeholder: "Search for products", - autofocus: false }) ); diff --git a/docgen/src/examples/tourism/search.js b/docgen/src/examples/tourism/search.js index 1ccedcc389..963551dfbe 100644 --- a/docgen/src/examples/tourism/search.js +++ b/docgen/src/examples/tourism/search.js @@ -11,7 +11,7 @@ window.addEventListener('load', function() { instantsearch.widgets.searchBox({ container: '#q', placeholder: 'Where are you going?', - magnifier: false + showSubmit: false }) ); diff --git a/docgen/src/guides/v3-migration.md b/docgen/src/guides/v3-migration.md index 207b5125a3..45ceeeecb6 100644 --- a/docgen/src/guides/v3-migration.md +++ b/docgen/src/guides/v3-migration.md @@ -51,8 +51,8 @@ search.addWidget( item: data => { data.count = 0; return data; - } - } + }, + }, }) ); ``` @@ -311,7 +311,7 @@ With the redo button: | ------------ | ------------ | | `escapeHits` | `escapeHTML` | -* `escapeHTML` defaults to `true` +- `escapeHTML` defaults to `true` #### CSS classes @@ -1015,6 +1015,86 @@ Widget removed. ``` +### SearchBox + +#### Options + +| Before | After | +| --------------------------- | ---------------------------------------- | +| `poweredBy` | use the `poweredBy` widget | +| `wrapInput` | use the `connectSearchBox` connector | +| `searchOnEnterKeyPressOnly` | `searchAsYouType` (default: `true`) | +| `reset` | `showReset` | +| `magnifier` | `showSubmit` | +| `loadingIndicator` | `showLoadingIndicator` (default: `true`) | + +With the drop of `wrapInput`, we decided not to accept `input`s as containers anymore. If you want complete control over the rendering, you should use the `connectSearchBox` connector. + +The search box does not support `powered-by`. If you're using a community plan, you need to use the `poweredBy` widget to display the Algolia logo. + +Configuration options for `reset`, `submit` and `loadingIndicator` have been moved to `templates` and `cssClasses`. For example, in the case of `reset`: + +- `reset.template` => `templates.reset` +- `reset.cssClasses.root` => `cssClasses.reset` + +Finally, `autofocus` is now set to `false` by default and does not support the `"auto"` value anymore. + +#### CSS classes + +| Before | After | +| ------------------------------------------- | -------------------------------- | +| `ais-search-box` | `ais-SearchBox` | +| | `ais-SearchBox-form` | +| `ais-search-box--input` | `ais-SearchBox-input` | +| `ais-search-box--magnifier-wrapper` | | +| `ais-search-box--magnifier` | `ais-SearchBox-submit` | +| | `ais-SearchBox-submitIcon` | +| `ais-search-box--reset-wrapper` | | +| `ais-search-box--reset` | `ais-SearchBox-reset` | +| | `ais-SearchBox-resetIcon` | +| `ais-search-box--loading-indicator-wrapper` | | +| `ais-search-box--loading-indicator` | `ais-SearchBox-loadingIndicator` | +| | `ais-SearchBox-loadingIcon` | + +#### Markup + +```html +