instantsearch.js 4.55.0 → 4.56.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 (62) hide show
  1. package/cjs/components/Breadcrumb/Breadcrumb.js +2 -2
  2. package/cjs/components/RangeInput/RangeInput.js +22 -11
  3. package/cjs/components/RefinementList/RefinementList.js +34 -52
  4. package/cjs/components/Slider/Rheostat.js +163 -249
  5. package/cjs/connectors/infinite-hits/connectInfiniteHits.js +22 -7
  6. package/cjs/lib/InstantSearch.js +2 -4
  7. package/cjs/lib/routers/history.js +54 -1
  8. package/cjs/lib/utils/render-args.js +3 -2
  9. package/cjs/lib/version.js +1 -1
  10. package/cjs/widgets/hits-per-page/hits-per-page.js +3 -1
  11. package/cjs/widgets/index/index.js +8 -8
  12. package/dist/instantsearch.development.d.ts +76 -76
  13. package/dist/instantsearch.development.js +345 -341
  14. package/dist/instantsearch.development.js.map +1 -1
  15. package/dist/instantsearch.production.d.ts +76 -76
  16. package/dist/instantsearch.production.min.d.ts +76 -76
  17. package/dist/instantsearch.production.min.js +2 -2
  18. package/dist/instantsearch.production.min.js.map +1 -1
  19. package/es/components/Breadcrumb/Breadcrumb.d.ts +2 -2
  20. package/es/components/Breadcrumb/Breadcrumb.js +2 -2
  21. package/es/components/GeoSearchControls/GeoSearchButton.d.ts +1 -1
  22. package/es/components/GeoSearchControls/GeoSearchControls.d.ts +3 -3
  23. package/es/components/GeoSearchControls/GeoSearchToggle.d.ts +1 -1
  24. package/es/components/Pagination/Pagination.d.ts +2 -2
  25. package/es/components/RangeInput/RangeInput.d.ts +7 -4
  26. package/es/components/RangeInput/RangeInput.js +22 -11
  27. package/es/components/RefinementList/RefinementList.d.ts +0 -1
  28. package/es/components/RefinementList/RefinementList.js +34 -52
  29. package/es/components/RelevantSort/RelevantSort.d.ts +1 -1
  30. package/es/components/Selector/Selector.d.ts +2 -2
  31. package/es/components/Slider/Rheostat.d.ts +23 -17
  32. package/es/components/Slider/Rheostat.js +163 -249
  33. package/es/components/Slider/Slider.d.ts +1 -1
  34. package/es/connectors/current-refinements/connectCurrentRefinements.d.ts +2 -2
  35. package/es/connectors/dynamic-widgets/connectDynamicWidgets.d.ts +2 -2
  36. package/es/connectors/geo-search/connectGeoSearch.d.ts +7 -7
  37. package/es/connectors/infinite-hits/connectInfiniteHits.js +23 -8
  38. package/es/connectors/menu/connectMenu.d.ts +2 -2
  39. package/es/connectors/pagination/connectPagination.d.ts +1 -1
  40. package/es/connectors/range/connectRange.d.ts +3 -3
  41. package/es/connectors/refinement-list/connectRefinementList.d.ts +3 -3
  42. package/es/connectors/relevant-sort/connectRelevantSort.d.ts +1 -1
  43. package/es/lib/InstantSearch.d.ts +13 -13
  44. package/es/lib/InstantSearch.js +3 -5
  45. package/es/lib/routers/history.d.ts +2 -2
  46. package/es/lib/routers/history.js +55 -2
  47. package/es/lib/utils/defer.d.ts +2 -2
  48. package/es/lib/utils/render-args.js +3 -2
  49. package/es/lib/version.d.ts +1 -1
  50. package/es/lib/version.js +1 -1
  51. package/es/types/middleware.d.ts +6 -6
  52. package/es/types/router.d.ts +7 -7
  53. package/es/types/widget.d.ts +1 -1
  54. package/es/widgets/dynamic-widgets/dynamic-widgets.d.ts +2 -2
  55. package/es/widgets/geo-search/createHTMLMarker.d.ts +1 -1
  56. package/es/widgets/geo-search/geo-search.d.ts +1 -1
  57. package/es/widgets/hits-per-page/hits-per-page.js +3 -1
  58. package/es/widgets/index/index.d.ts +20 -20
  59. package/es/widgets/index/index.js +8 -8
  60. package/es/widgets/panel/panel.d.ts +2 -2
  61. package/es/widgets/range-slider/range-slider.d.ts +1 -1
  62. package/package.json +6 -6
@@ -19,39 +19,39 @@ export type IndexWidgetDescription = {
19
19
  export type IndexWidget<TUiState extends UiState = UiState> = Omit<Widget<IndexWidgetDescription & {
20
20
  widgetParams: IndexWidgetParams;
21
21
  }>, 'getWidgetUiState' | 'getWidgetState'> & {
22
- getIndexName(): string;
23
- getIndexId(): string;
24
- getHelper(): Helper | null;
25
- getResults(): SearchResults | null;
26
- getPreviousState(): SearchParameters | null;
27
- getScopedResults(): ScopedResult[];
28
- getParent(): IndexWidget | null;
29
- getWidgets(): Array<Widget | IndexWidget>;
30
- createURL(state: SearchParameters): string;
31
- addWidgets(widgets: Array<Widget | IndexWidget>): IndexWidget;
32
- removeWidgets(widgets: Array<Widget | IndexWidget>): IndexWidget;
33
- init(options: IndexInitOptions): void;
34
- render(options: IndexRenderOptions): void;
35
- dispose(): void;
22
+ getIndexName: () => string;
23
+ getIndexId: () => string;
24
+ getHelper: () => Helper | null;
25
+ getResults: () => SearchResults | null;
26
+ getPreviousState: () => SearchParameters | null;
27
+ getScopedResults: () => ScopedResult[];
28
+ getParent: () => IndexWidget | null;
29
+ getWidgets: () => Array<Widget | IndexWidget>;
30
+ createURL: (state: SearchParameters) => string;
31
+ addWidgets: (widgets: Array<Widget | IndexWidget>) => IndexWidget;
32
+ removeWidgets: (widgets: Array<Widget | IndexWidget>) => IndexWidget;
33
+ init: (options: IndexInitOptions) => void;
34
+ render: (options: IndexRenderOptions) => void;
35
+ dispose: () => void;
36
36
  /**
37
37
  * @deprecated
38
38
  */
39
- getWidgetState(uiState: UiState): UiState;
40
- getWidgetUiState<TSpecificUiState extends UiState = TUiState>(uiState: TSpecificUiState): TSpecificUiState;
41
- getWidgetSearchParameters(searchParameters: SearchParameters, searchParametersOptions: {
39
+ getWidgetState: (uiState: UiState) => UiState;
40
+ getWidgetUiState: <TSpecificUiState extends UiState = TUiState>(uiState: TSpecificUiState) => TSpecificUiState;
41
+ getWidgetSearchParameters: (searchParameters: SearchParameters, searchParametersOptions: {
42
42
  uiState: IndexUiState;
43
- }): SearchParameters;
43
+ }) => SearchParameters;
44
44
  /**
45
45
  * Set this index' UI state back to the state defined by the widgets.
46
46
  * Can only be called after `init`.
47
47
  */
48
- refreshUiState(): void;
48
+ refreshUiState: () => void;
49
49
  /**
50
50
  * Set this index' UI state and search. This is the equivalent of calling
51
51
  * a spread `setUiState` on the InstantSearch instance.
52
52
  * Can only be called after `init`.
53
53
  */
54
- setIndexUiState(indexUiState: TUiState[string] | ((previousIndexUiState: TUiState[string]) => TUiState[string])): void;
54
+ setIndexUiState: (indexUiState: TUiState[string] | ((previousIndexUiState: TUiState[string]) => TUiState[string])) => void;
55
55
  };
56
56
  declare const index: (widgetParams: IndexWidgetParams) => IndexWidget;
57
57
  export default index;
@@ -332,7 +332,7 @@ var index = function index(widgetParams) {
332
332
  // does not have access to lastResults, which it used to in pre-federated
333
333
  // search behavior.
334
334
  helper.lastResults = results;
335
- lastValidSearchParameters = results._state;
335
+ lastValidSearchParameters = results === null || results === void 0 ? void 0 : results._state;
336
336
  });
337
337
 
338
338
  // We compute the render state before calling `init` in a separate loop
@@ -388,16 +388,16 @@ var index = function index(widgetParams) {
388
388
  render: function render(_ref5) {
389
389
  var _this4 = this;
390
390
  var instantSearchInstance = _ref5.instantSearchInstance;
391
- if (!this.getResults()) {
392
- return;
393
- }
394
-
395
391
  // we can't attach a listener to the error event of search, as the error
396
392
  // then would no longer be thrown for global handlers.
397
- if (instantSearchInstance.status === 'error' && !instantSearchInstance.mainHelper.hasPendingRequests()) {
393
+ if (instantSearchInstance.status === 'error' && !instantSearchInstance.mainHelper.hasPendingRequests() && lastValidSearchParameters) {
398
394
  helper.setState(lastValidSearchParameters);
399
395
  }
400
- localWidgets.forEach(function (widget) {
396
+
397
+ // We only render index widgets if there are no results.
398
+ // This makes sure `render` is never called with `results` being `null`.
399
+ var widgetsToRender = this.getResults() ? localWidgets : localWidgets.filter(isIndexWidget);
400
+ widgetsToRender.forEach(function (widget) {
401
401
  if (widget.getRenderState) {
402
402
  var renderState = widget.getRenderState(instantSearchInstance.renderState[_this4.getIndexId()] || {}, createRenderArgs(instantSearchInstance, _this4));
403
403
  storeRenderState({
@@ -407,7 +407,7 @@ var index = function index(widgetParams) {
407
407
  });
408
408
  }
409
409
  });
410
- localWidgets.forEach(function (widget) {
410
+ widgetsToRender.forEach(function (widget) {
411
411
  // At this point, all the variables used below are set. Both `helper`
412
412
  // and `derivedHelper` have been created at the `init` step. The attribute
413
413
  // `lastResults` might be `null` though. It's possible that a stalled render
@@ -65,12 +65,12 @@ export type PanelWidgetParams<TWidgetFactory extends AnyWidgetFactory> = {
65
65
  * A function that is called on each render to determine if the
66
66
  * panel should be hidden based on the render options.
67
67
  */
68
- hidden?(options: PanelRenderOptions<TWidgetFactory>): boolean;
68
+ hidden?: (options: PanelRenderOptions<TWidgetFactory>) => boolean;
69
69
  /**
70
70
  * A function that is called on each render to determine if the
71
71
  * panel should be collapsed based on the render options.
72
72
  */
73
- collapsed?(options: PanelRenderOptions<TWidgetFactory>): boolean;
73
+ collapsed?: (options: PanelRenderOptions<TWidgetFactory>) => boolean;
74
74
  /**
75
75
  * The templates to use for the widget.
76
76
  */
@@ -18,7 +18,7 @@ type RangeSliderTooltipOptions = {
18
18
  * @example
19
19
  * { format(rawValue) {return '$' + Math.round(rawValue).toLocaleString() } }
20
20
  */
21
- format(value: number): string;
21
+ format: (value: number) => string;
22
22
  };
23
23
  export type RangeSliderWidgetParams = {
24
24
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch.js",
3
- "version": "4.55.0",
3
+ "version": "4.56.0",
4
4
  "description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
5
5
  "homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
6
6
  "types": "es/index.d.ts",
@@ -33,7 +33,7 @@
33
33
  "@types/google.maps": "^3.45.3",
34
34
  "@types/hogan.js": "^3.0.0",
35
35
  "@types/qs": "^6.5.3",
36
- "algoliasearch-helper": "^3.11.3",
36
+ "algoliasearch-helper": "^3.13.0",
37
37
  "hogan.js": "^3.0.2",
38
38
  "htm": "^3.0.0",
39
39
  "preact": "^10.10.0",
@@ -55,9 +55,9 @@
55
55
  "version": "./scripts/version/update-version.js"
56
56
  },
57
57
  "devDependencies": {
58
- "@instantsearch/mocks": "1.12.0",
59
- "@instantsearch/tests": "1.12.0",
60
- "@instantsearch/testutils": "1.1.0",
58
+ "@instantsearch/mocks": "1.13.0",
59
+ "@instantsearch/tests": "1.13.0",
60
+ "@instantsearch/testutils": "1.2.0",
61
61
  "@storybook/html": "5.3.9",
62
62
  "@types/scriptjs": "0.0.2",
63
63
  "algoliasearch": "4.14.3",
@@ -65,5 +65,5 @@
65
65
  "scriptjs": "2.5.9",
66
66
  "webpack": "4.41.5"
67
67
  },
68
- "gitHead": "c483ae31e1e615be61dffb5d0bc04a4927960a67"
68
+ "gitHead": "ea054eab1484a3d167db83bc768f6ea134add5f9"
69
69
  }